akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
using namespace std;


int main(){
    int m,n,x;
    cin >> n >> m >> x;
    int c[n+1],a[n+1][m+1];
    int result=10000000;

    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    //購入する参考書の組み合わせについて全探索
    for(int bit=0;bit<(1<<n);bit++){
        //参考書の組み合わせにおける、値段とスキルの合計値を計算
        int skill_sum[15]={0};
        int price = 0;
        //購入する参考書でマスクがけ
        for(int i=0;i<n;i++){
            int mask = 1<<i; //1,2,4,...2の累乗を生成
            if(bit&mask){
                price += c[i];
                for(int j=0;j<m;j++){
                    skill_sum[j] += a[i][j];
                }
            }
        }
        bool skill = true;
        for(int i=0;i<m;i++){
            if(skill_sum[i]<x){
                skill = false;
            }
        }
        if(skill){
            result = min(result,price);
        }
    }
    if(result!=10000000){
        cout << result << endl;
    }
    else{
        cout << "-1" << endl;
    }
    return 0;
}








Measured memory_bytes: 3596
#include <iostream>

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

int C[510];// Cost to reach next station
int S[510];// Time of start
int F[510];// TIme of next train start
// S[i] % F[i] = 0

int main() {
	// Input
	int N;// Number of stations.
	cin >> N;
	for(int i = 0; i < N - 1; ++i) {
		cin >> C[i] >> S[i] >> F[i];
	}
	// Calculation
	for(int i = 0; i < N; ++i) {
		int t = 0;
		for(int j = i; j < N - 1; ++j) {
			if(t < S[j]) t = S[j];
			else if(t % F[j] == 0);
			else t += F[j] - t % F[j];
			t += C[j];
		}
		// Output
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    cin >> a >> f;
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<int>());
    cout << bsearch<ll>(-1, 1'000'000'000'000ll, [&](ll score) {
        ll cost = 0;
        for(int i = 0; i < n; i++) {
            cost += max(0ll, a[i] - score / f[i]);
        }
        return cost <= k;
    }, false) << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main() {
	int n;scanf("%d",&n);
	int cnt=0;
	rep(i,n){
		int l,r;scanf("%d%d",&l,&r);
		cnt+=r-l+1;
	}
	cout<<cnt<<endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w, d;
  cin >> h >> w >> d;
  ll a[h][w];
  vector< pair<int, int> > v(h*w+10);
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      cin >> a[i][j];
      v[a[i][j]] = make_pair(i+1, j+1);
    }
  }
  vector<ll> dp(h*w+1);
  for(int i=1;i<=d;i++) {
    int idx = i;
    dp[idx] = 0;
    idx += d;
    while(idx <= h*w) {
      dp[idx] = dp[idx-d] + abs(v[idx].first-v[idx-d].first) + abs(v[idx].second-v[idx-d].second);
      idx += d;
    }
  }

  ll q;
  cin >> q;
  for(int i=0;i<q;i++) {
    int li, ri;
    cin >> li >> ri;
    cout << dp[ri] - dp[li] << endl;
  }
}


Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
L=[-1]*n
if n==1 and m==0:
    print(0)
    sys.exit()
for i in range(m):
    s,c=map(int,input().split())
    s-=1
    if L[s]==-1 or L[s]==c:
        L[s] = c
    else:
        print(-1)
        sys.exit()
if L[0]==0 and n>1:
    print(-1)
    sys.exit()
    
for i in range(n):
    if L[i]==-1:
        if i==0:
            L[i]=1
        else:
            L[i]=0
print(*L,sep="")


Measured memory_bytes: 61268
#include<stdio.h>
int main()
{
    int N,A,B,eachCost;
    scanf("%d %d %d",&N,&A,&B);
    eachCost=N*A;
    if(eachCost<B)
    {
        printf("%d\n",eachCost);
    }
    else
    {
        printf("%d",B);
    }
    return 0;

}


Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    var l = 0
    var r = s.length - 1
    var ans = 0
    while (l < r) {
        val sl = s[l]
        val sr = s[r]
        if (sl == sr) {
            l++
            r--
        } else {
            when {
                sl == 'x' -> l++
                sr == 'x' -> r--
                else -> {
                    out.println(-1)
                    return
                }
            }
            ans++
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
}
const int N=20;
int L,n=20;
struct EDGE {
    int x,y,v;
    inline void print() {
        printf("%d %d %d\n",x,y,v);
    }
}e[66]; int E=0;
inline void add(int u,int v,int w) {
    e[++E]=(EDGE) {u,v,w};
}
signed main() {
    read(L);
    int tmp=L,V=0;
    while(tmp) {
        ++V; tmp>>=1;
    }
    for(int i=1;i<V;i++) {
        add(i,i+1,0);
        add(i,i+1,1<<(V-i-1));
    }
    int now=1<<(V-1);
    for(int i=V-1;i>=1;i--) {
        if(L&(1<<(i-1))) {
            add(1,V-i+1,now);
            now+=1<<(i-1);
            // L-=1<<i;
        }
    }
    printf("%d %d\n",V,E);
    for(int i=1;i<=E;i++) {
        e[i].print();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N, K, r = 1;
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++){
    if(r < K){
      r *= 2;
    } else {
      r += K;
    }
  }
  
  printf("%d\n", r);
  
  return 0;
}

Measured memory_bytes: 128
using System;

namespace ABC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var result = 0L;

            for (var i = 1; i <= n; i++)
            {
                result += i * sumI(n / i);
            }

            Console.WriteLine(result);
        }

        static long sumI(long i)
        {
            return (i * (i + 1)) / 2;
        }
    }
}


Measured memory_bytes: 27548
#include<iostream>
#include<vector>
#include<utility>
#include<string>
using namespace std;

typedef pair<char,int> card;

bool isStable( vector<card> &deck, vector<card> &original ){
	bool stable = true;
	int n = deck.size();
	for( int i=0; i<n-1; i++ ){
		if( deck[i].second == deck[i+1].second ){
			for( int j=0; j<n; j++ ){
				if( original[j].second == deck[i].second ){
					if( original[j].first == deck[i].first ){
						break;
					}else if( original[j].first == deck[i+1].first ){
						stable = false;
						break;
					}
				}
			}
			if( !stable )
				break;
		}
	}
	return stable;
}

int main(){
	int n;
	cin >> n;
	vector<card> original(n), deck(n);
	for( int i=0; i<n; i++ ){
		string in;
		cin >> in;
		original[i].first = in[0];
		original[i].second = in[1]-'0';
	}
	deck = original;
	for( int i=0; i<n; i++ ){
		for( int j=n-2; j>=i; j-- ){
			if( deck[j].second > deck[j+1].second ){
				card tmp = deck[j];
				deck[j] = deck[j+1];
				deck[j+1] = tmp;
			}
		}
	}
	cout << deck[0].first << deck[0].second;
	for( int i=1; i<n; i++ ){
		cout << " " << deck[i].first << deck[i].second;
	}
	cout << endl;
	cout << (isStable(deck,original) ? "Stable" : "Not stable") << endl;

	deck = original;
	for( int i=0; i<n; i++ ){
		int mini = i;
		for( int j=i+1; j<n; j++ ){
			if( deck[mini].second > deck[j].second ){
				mini = j;
			}
		}
		card tmp = deck[mini];
		deck[mini] = deck[i];
		deck[i] = tmp;
	}
	cout << deck[0].first << deck[0].second;
	for( int i=1; i<n; i++ ){
		cout << " " << deck[i].first << deck[i].second;
	}
	cout << endl;
	cout << (isStable(deck,original) ? "Stable" : "Not stable") << endl;
	return 0;
}

Measured memory_bytes: 1212
n,k=map(int, input().split(" "))
X=list(map(int, input().split(" ")))
#import bisect
maxvalue=100000000000000000000000
#place=bisect.bisect_left(X,0)

#if k<place:
#    X=X[place-k:]
#if k<n-place:
#    X=X[:-(n-place-k)]

#print(X)
#print(place)
for i in range(n-k+1):
    low=X[i]
    high=X[i+k-1]
    if high*low<0:
        low=abs(low)
        high=abs(high)
        value=min(low,high)*2+max(low,high)
    else:
        low=abs(low)
        high=abs(high)
        value=max(low,high)
    #print(value)
    if value<maxvalue:
        maxvalue=value
print(maxvalue)


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int h, w; cin >> h >> w;
    V<string> v(h);
    for(int i = 0; i < h; i++) cin >> v[i];

    int sum = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(v[i][j] == '#') sum++;
        }
    }

    int now = 0, cnt = 0;
    for(int i = 0; i < h; i++){
        if(v[i][now] == '.') break;
        for(int j = now; j < w; j++){
            if(v[i][j] == '#'){
                now = j;
                cnt++;
            }
            else break;
        }
    }

    if(sum == cnt) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> pii;
int n;
vector<int> E[101010];
int isleaf[101010];
int vis[101010];
vector<int> leafs[101010];
vector<int> stem;
pii dfs(int v){
    if (E[v].size() > 2)return pii(0,v);
    vis[v] = 1;
    pii c = pii(-1,-1);
    for(auto u : E[v]){
        if (!vis[u]){
            c = dfs(u);
        }
    }

    if (c == pii(-1, -1)){
        return pii(0, v);
    }
    isleaf[v] = 1;
    return pii(c.first+1, c.second);
}
void dfs_stem(int v){
    vis[v] = 1;
    stem.push_back(v);
    for(auto u : E[v]){
        if (!vis[u] && !isleaf[u]){
            dfs_stem(u);
        }
    }
}
void solve(vector<int> &v, vector<int> &ans){
    int c = 1;
    for(auto x:v){
        for(int i=1;i<=x;i++){
            ans.push_back(c+i);
        }
        ans.push_back(c);
        c+=x+1;
    }
}
int main(){
    scanf("%d", &n);
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }

    for(int i=1;i<=n;i++){
        if (E[i].size() == 1 && !vis[i]){
            auto p = dfs(i);
            leafs[p.second].push_back(p.first);
        }
    }
    int flag = 0;
    for(int i=1;i<=n;i++){
        if (!isleaf[i]){
            int c = 0;
            for(auto u : E[i]){
                if (!isleaf[u])c++;
            }
            if (E[i].size() - leafs[i].size() != 0 && c > 2)flag = 1;
        }
    }
    fill(vis, vis+n+1, 0);
    for(int i=1;i<=n;i++){
        if (!isleaf[i] && E[i].size() - leafs[i].size() <= 1){
            dfs_stem(i);
            break;
        }
    }
    vector<int> v;
    for(int i=0;i<(int)stem.size();i++){
        int c = 0;
        int mx = 0;
        int mx2 = 0;
        for(auto x : leafs[stem[i]]){
            if (x > 1)c++;
            if (mx <= x){mx2=mx;mx=x;}
            else if (mx2 < x){mx2 = x;}
        }
        if (i != 0 && i != stem.size() - 1){
            if (c != 0)flag = 1;
            v.push_back(leafs[stem[i]].size());
        }
        else if (i == 0 && i == stem.size() - 1){
            for(int j=0;j<mx;j++)v.push_back(0);
            v.push_back(leafs[stem[i]].size() - !!mx - !!mx2);
            for(int j=0;j<mx2;j++)v.push_back(0);
        }
        else if (i == 0){
            if (c > 1)flag = 1;
            for(int j=0;j<mx;j++)v.push_back(0);
            v.push_back(leafs[stem[i]].size() - !!mx);
        }
        else {
            if (c > 1)flag = 1;
            v.push_back(leafs[stem[i]].size() - !!mx);
            for(int j=0;j<mx;j++)v.push_back(0);
        }
    }

    if (flag){
        printf("-1\n");
        return 0;
    }
    vector<int> ans, ans_r;
    solve(v, ans);
    reverse(v.begin(), v.end());
    solve(v, ans_r);
    if (ans > ans_r)ans = ans_r;
    for(auto x : ans){
        printf("%d ",x);
    }
}


Measured memory_bytes: 15480
N = int(input())
S = input()
s = 0
mi = 0
for i in range(N):
    s += 1 if S[i] == "(" else -1
    mi = min(mi, s)
if s > 0:
    print(-mi * "(" + S + ")" * (s-mi))
else:
    print("(" * max(-s, -mi) + S + ")" * (max(-s, -mi) + s))


Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();

    int lMax = 1;
    int rMin = n;
    for (int i = 0; i < m; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      lMax = Math.max(l, lMax);
      rMin = Math.min(r, rMin);
    }
    if (rMin < lMax) {
      os.println(0);
    } else {
      os.println(rMin - lMax + 1);
    }
  }
}

Measured memory_bytes: 62960
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main()
{
  ll n,k; cin >> n >> k;
  vector<int> a(n),s,ord(n+1, -1); rep(i, n) cin >> a[i];
  int c = 1, l = 0;
  {
    int v = 1;
    while(ord[v] == -1){
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }
  if(k < l) cout << s[k] << endl;
  else{
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ d.cpp
./a.out

サンプルのダウンロードは oj d https://atcoder.jp/contests/abc167/tasks/abc167_d
テストは oj t
*/


Measured memory_bytes: 5884
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  string str;
  cin >> str;

  int cnt = 0;

  REP(i,(int)str.size()-1){

    (str[i] == str[i+1]) ? cnt++ : cnt = 0;

    if(cnt >= 2){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
//Low Elements

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    ll n;cin>>n;
    vector<ll> p(n);
    rep(i,0,n)cin>>p[i];
    ll ans = 1;
    ll c = p[0];
    rep(i,1,n){
        if(p[i]<c)ans++;
        c=min(c,p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
function bomb(y,x){
   var PM=(y%2==1)?0:1;
   var dy=[[-1,-1,0,0,1,1],[-1,-1,0,0,1,1]];
   var dx=[[0,1,-1,1,0,1],[-1,0,-1,1,-1,0]];
   for(var i=0;i<6;i++){
      var Y=y+dy[PM][i];
      var X=x+dx[PM][i];
      if(Y<0 || X<0 || Y>=h+2 || X>=w+2)continue;
      if(yx[Y][X]==1)cnt++;
      if(yx[Y][X]==0){
         yx[Y][X]=2;
         bomb(Y,X);
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var wh=arr.shift().split(" ").map(Number);
var w=wh[0];
var h=wh[1];
var yx=[];
var zero=[];
for(var i=0;i<w+2;i++)zero.push(0);
yx.push(zero.slice());
for(var i=0;i<h;i++)yx.push(("0 "+arr.shift()+" 0").split(" ").map(Number));
yx.push(zero.slice());
var cnt=0;
yx[0][0]=2;
bomb(0,0);
console.log(cnt);

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

int main()
{
	int n,k,i,x;
	cin>>n>>k;
	x=k;
	for(i=1;i<=10000;i++){
	   if(n<x)
	   {
	   	cout<<i;
	   	return 0;
	   }
	   x=x*k;
	}
	   
	
	return 0;
	
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
from collections import deque
s = readline().rstrip().decode('utf-8')
q = int(readline())
flag = 0
lst1 = deque([])
lst2 = deque([])
for i in range(q):
    t = readline().rstrip().decode('utf-8')
    if t[0] == "1":
        #reverse
        flag = 1-flag
    else:
        com,f,c = t.split()
        if f == "1": #先頭にc追加
            if not flag:
                lst1.append(c)
            else: #反転中
                lst2.append(c)
            

        else: #末尾にc追加
            if not flag:
                lst2.append(c)
            else:
                lst1.append(c)

if not flag:
    lst1.reverse()
    s = "".join(lst1) + s + "".join(lst2) 

    
else:
    lst2.reverse()
    s = s[::-1]
    s = "".join(lst2)+ s + "".join(lst1)



print(s)



Measured memory_bytes: 62812
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mon = 1000, sto = 0, tmp;
	cin >> nn;
	vector<int64> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
	}
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		if(aa[ii] < aa[ii + 1])
		{
			tmp = mon / aa[ii];
			sto += tmp;
			mon -= (tmp * aa[ii]);
		}
		else if(aa[ii] > aa[ii + 1])
		{
			mon += aa[ii] * sto;
			sto = 0;
		}
	}
	mon += aa[nn  - 1] * sto;
	cout << mon << endl;
	return 0;
}

Measured memory_bytes: 3624
from collections import deque

INF = float('inf')

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input() for _ in range(H)]

t = [[INF] * W for _ in range(H)]
t[Ch][Cw] = 0
q = deque([(Ch, Cw)])

while q:
    h, w = q.popleft()
    a = t[h][w]
    if h - 1 >= 0 and S[h - 1][w] != '#' and t[h - 1][w] > a:
        q.appendleft((h - 1, w))
        t[h - 1][w] = a
    if h + 1 < H and S[h + 1][w] != '#' and t[h + 1][w] > a:
        q.appendleft((h + 1, w))
        t[h + 1][w] = a
    if w - 1 >= 0 and S[h][w - 1] != '#' and t[h][w - 1] > a:
        q.appendleft((h, w - 1))
        t[h][w - 1] = a
    if w + 1 < W and S[h][w + 1] != '#' and t[h][w + 1] > a:
        q.appendleft((h, w + 1))
        t[h][w + 1] = a

    for i in range(max(0, h - 2), min(H - 1, h + 2) + 1):
        for j in range(max(0, w - 2), min(W - 1, w + 2) + 1):
            if S[i][j] == '#':
                continue
            if t[i][j] <= a + 1:
                continue
            t[i][j] = a + 1
            q.append((i, j))

if t[Dh][Dw] == INF:
    print(-1)
else:
    print(t[Dh][Dw])


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

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0; i<N; i++){
        cin >> V.at(i);
    } 
    for(int i=0; i<N; i++){
        cin >> C.at(i);
    } 
    vector<int> vec;
    int cnt=0;
    for(int i=0; i<N; i++){
        if(V.at(i)>C.at(i)) {
            vec.push_back(V.at(i)-C.at(i));
            cnt++;
        }
    } 
    int SUM=0;
    for(int i=0; i<cnt; i++) SUM+=vec.at(i);

    cout << SUM << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n ;
   cin >> n ;
   int a[n] ;
   for(int i=0;i<n;i++)cin >> a[i] ;
   int count =0 ;
  bool cond = true ;
  while(cond){
   for(int i=0;i<n;i++){
     if(a[i]%2==0){
            a[i]/= 2 ;
     }else{
      cond = false ;
      break;
     }
   }
    if(cond)count++;
  }
  
   cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
mod = 10**9 + 7

ans = 0
two_factor = 1
60.times do |i|
  one = 0
  zero = 0
  a.each do |a_x|
    if a_x[i] == 1
      one += 1
    else
      zero += 1
    end
  end

  add = (one * zero) % mod * two_factor % mod
  ans = (ans + add) % mod
  two_factor = (two_factor * 2) % mod
end

puts ans


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

void Main()
{
	string s;
	cin >> s;
	
	if (s[s.size() - 1] == 's') {
		cout << s + "es";
	}
	else {
		cout << s + "s";
	}
	return;
}

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=998244353;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
pii a[N];
int main(){
#ifdef LOCAL
	freopen("E.in","r",stdin);//freopen("E.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,1,n)scanf("%d%d",&a[i].X,&a[i].Y);
	ll ans=powmod(2,n)-n-n*(n-1)/2-1;
	rep(i,1,n)rep(j,i+1,n){
		int mn=n+1,cnt=2;
		rep(k,1,n)if(i!=k&&j!=k&&(a[j].X-a[i].X)*(a[k].Y-a[i].Y)==(a[j].Y-a[i].Y)*(a[k].X-a[i].X))MIN(mn,k),++cnt;
		if(mn>j)ans-=powmod(2,cnt)-cnt-1-cnt*(cnt-1)/2;
	}
	ans=(ans%mo+mo)%mo;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=22,MOD=1e9+7;
ll dp[NMAX][1<<NMAX];
bool b[NMAX][NMAX];
ll n,i,j;

int main()
{
    cin>>n;
    for(i=1;i<=n;i++) for(j=1;j<=n;j++) cin>>b[i][j];
    dp[0][0]=1;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(b[i][j])
            for(ll k=0;k<(1<<n);k++){
                if(k>>(j-1)&1){
                    dp[i][k]=(dp[i][k]+dp[i-1][k-(1<<(j-1))])%MOD;
                }
            }
        }
    }
    cout<<dp[n][(1<<n)-1];
    return 0;
}

///ABCDEFGHIJKLMNOPQRSTUVWXYZ
///11110111101010000000000000


Measured memory_bytes: 347716
#include <stdio.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <utility>
#include <queue>
#include <climits>
using namespace std;

#define endl '\n'
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define FORE(i, a, b) for(int i=(a); i<=(b); i++)
#define MOD 1000000007ll

typedef pair<int, int> ii;
typedef long long LL;
typedef long double LD;

int n, ma, mb;
int a[100005], b[100005];
int h[100005];
int sure[100005];
 
void solve(){
    if(ma != mb) {
    	cout << 0 << endl;
    	return;	
    }
    memset(h, 0, sizeof(h));
    memset(sure, 0, sizeof(sure));
    
	sure[0] = 1;
    h[0] = a[0];
    int m = h[0];
	FOR(i, 1, n) {
		sure[i] = a[i] > m ? 1 : 0;
    	h[i] = a[i];
    	m = h[i];
    }
    
	if(sure[n-1]) {
    	if(h[n-1] != b[n-1]) {
			cout << 0 << endl;
    		return;
		}
    } else {
    	if(h[n-1] < b[n-1]) {
			cout << 0 << endl;
    		return;
		}
    }
    
    sure[n-1] = 1;
    m = h[n-1] = b[n-1];
    for(int i=n-2; i>=0; i--) {
    	if(b[i] > m) {
    		// make sure
    		if(sure[i]) {
				if(b[i] != h[i]) {
	    			cout << 0 << endl;
	    			return;
	    		}
    		} else {
    			if(h[i] < b[i]) {
	    			cout << 0 << endl;
	    			return;
	    		} else {
	    			sure[i] = 1;
	    			h[i] = b[i];	
	    		}
    		}
    	} else {
    		if(sure[i]) {
    			if(h[i] > b[i]) {
					cout << 0 << endl;
	    			return;
				}
    		} else {
    			h[i] = min(h[i], b[i]);
    		}
    	}
    	m = b[i];
    }
    
    LL res = 1;
    FOR(i, 0, n) {
    	if(sure[i] == 0) {
    		res = (res * h[i]) % MOD;	
    	}
    }
	cout << res << endl;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    std::cin.tie(0);
    while(cin >> n) {
    	ma = mb = -1;
    	FOR(i, 0, n) {
    		cin >> a[i];
    		ma = max(ma, a[i]);
    	}
    	FOR(i, 0, n) {
    		cin >> b[i];
    		mb = max(mb, b[i]);
    	}
		solve();
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> T(n);
  vector<ll> A(n);
  rep(i,n){
    cin >> T[i] >> A[i];
  }
  ll num1 = 1;
  ll num2 = 1;
  rep(i,n){
    ll n1 = num1 / T[i];
    ll n2 = num2 / A[i];
    if(num1 % T[i] != 0) n1++;
    if(num2 % A[i] != 0) n2++;
    ll n = max(n1, n2);
    num1 = T[i] * n; num2 = A[i] * n;
  }
  cout << num1 + num2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

int main(){
    ll N; cin>>N;
    vector<ll> a(N),b(N);
    for(int i=0;i<N;i++) cin>>a.at(i);
    for(int i=0;i<N;i++) cin>>b.at(i);
    
    ll ans=0;
    for(int i=0;i<30;i++){
        ll M=ruijou(2,i);
        vector<ll> c(N);
        for(int j=0;j<N; j++) c.at(j)=b.at(j)%(2*M);
        sort(c.begin(),c.end());
        ll count=0;
        for(int k=0;k<N;k++){
            ll x=a.at(k)%(2*M);
            count+=(upper_bound(c.begin(),c.end(),4*M-x-1)-lower_bound(c.begin(),c.end(),3*M-x));
            count+=(upper_bound(c.begin(),c.end(),2*M-x-1)-lower_bound(c.begin(),c.end(),M-x));
        }
        ans+=M*(count%2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 
	 long A=sc.nextLong();
	 long B=sc.nextLong();
	 long C=sc.nextLong();
	 long D=sc.nextLong();
	 
	 long numC=(A-1)/C;
	 
	 long numC2=B/C;
	 
	 long numD1=(A-1)/D;
	
	 long numD2=B/D;
	 
	
	 long numCD1=(A-1)/lcm(C,D);
	 
	 long numCD2=B/lcm(C,D);
	 if(numCD2<numCD1) {
		 numCD2=numCD1;
	 }
	 
	 
	 
	 long result=(numC2-numC)+(numD2-numD1)-(numCD2-numCD1);
	 
	 //System.out.println(numC+" "+numC2+" "+numD1+" "+numD2+" "+numCD1+" "+numCD2);
	 System.out.println(B-A+1-result); 
	 
	
	 
	 
	 
 }
	


}



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

const int INF = 1e9;
void dijkstra(const int n, vector<vector<int>> &min_path, const vector<vector<pair<int, int>>> &G, const vector<int> &R) {
  for (int i = 0; i < R.size(); i++) {
    int start = R[i];
    vector<int> cost(n + 1, INF);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
    Q.push({0, start});
    cost[start] = 0;
    while (!Q.empty()) {
      int x, c;
      tie(c, x) = Q.top();
      Q.pop();
      if (cost[x] < c) continue;

      for (auto y: G[x]) {
        if (cost[y.first] <= y.second + c) continue;
        cost[y.first] = y.second + c;
        Q.push({y.second + c, y.first});
      }
    }
    for (int j = 0; j < R.size(); j++) {
      min_path[i][j] = cost[R[j]];
    }
  }
}

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> R(r);
  for (int i = 0; i < r; i++) cin >> R[i];
  vector<vector<pair<int, int>>> G(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }

  vector<vector<int>> min_path(r, vector<int>(r));
  dijkstra(n, min_path, G, R);
  vector<vector<int>> dp(1<<r, vector<int>(r, INF));

  for (int i = 0; i < r; i++) dp[0][i] = 0;

  for (int i = 1; i < (1 << r); i++) {
    for (int j = 0; j < r; j++) {
      for (int k = 0; k < r; k++) {
        if ((i & (1 << j)) && (i & (1 << k))) {
          dp[i][k] = min(dp[i][k], dp[i ^ (1 << k)][j] + min_path[j][k]);
        }
      }
    }
  }

  int ans = INF;
  for (int i = 0; i < r; i++) ans = min(ans, dp[(1 << r) - 1][i]);

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

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;
	cin >>s;
	ll ans = 0;
	for(ll i = 1; i < s.size(); i++) {
		if (s[i] != s[i - 1]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t[i];

    ll ans = 0;
    rep(i, N - 1) ans += min(T, t[i + 1] - t[i]);
    ans += T;

    cout << ans << endl;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int MOD=998244353;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,s;
	cin>>n>>s;
	vvi dp(n+1,vi(s+1));
	dp[0][0]=1;
	rep(i,n){
		int a;cin>>a;
		rep(j,s+1){
			(dp[i+1][j]+=dp[i][j]*2)%=MOD;
			if(j+a<=s)(dp[i+1][j+a]+=dp[i][j])%=MOD;
		}
	}
	cout<<dp[n][s]<<endl;
}


Measured memory_bytes: 73676
fun main(args: Array<String>) {
    val (x, k, d) = readLine()!!.split(' ').map { it.toLong() }

    var now = Math.abs(x)
    val first = now/d
    if (first >= k) {
        now -= k * d
    } else {
        now -= first * d
        val zan = k-first
        if (zan%2L == 1L) {
            now -= d
        }
    }
    println(Math.abs(now))
}


Measured memory_bytes: 36456
n=[1,0,0]
while 1:
    try:
        ch=[]
        op1,op2=list(map(str,input().split(",")))
        if op1=="A" or op2=="A":ch.append(0)
        if op1=="B" or op2=="B":ch.append(1)
        if op1=="C" or op2=="C":ch.append(2)
        n[ch[0]],n[ch[1]]=n[ch[1]],n[ch[0]]
    except:break
if n[0]==1:print("A")
if n[1]==1:print("B")
if n[2]==1:print("C")


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

int main() {

    int S;
    cin >> S;

    int h, m, s;
    h = S / 3600;
    m = (S - h*3600) / 60;
    s = S - 3600*h - 60*m;

    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K,T;
    cin>>K>>T;
    vint A(T);rep(i,T)cin>>A[i];


    int ma=max_element(all(A))-A.begin();

    int sum=accumulate(all(A),0ll);
    if(sum-A[ma]+1>=A[ma]){
        cout<<0<<endl;
    }
    else{
        cout<<A[ma]-(sum-A[ma]+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

/*
    G A C G
*/

const string agct = "AGCT";

int N;
vector<map<string, int>> memo;

int dfs(string s, int idx) {
    // cout << "# " << s << ", idx : " << idx << endl;
    if (idx == N) return 1;
    if (memo[idx].count(s)) return memo[idx][s];

    int ret = 0;
    for (auto c : agct) {
        string next = s + c;
        bool ok = true;
        REP(i, 0, 4) {
            string tmp = next;
            if (i > 0) swap(tmp[i], tmp[i - 1]);
            if (tmp.find("AGC") != string::npos) ok = false;
        }
        if (ok) ret = (ret + dfs(s.substr(1) + c, idx + 1)) % MOD;
        // cout << "--> " << next << " : " << ((ok) ? "OK" : "NG") << endl;
    }
    return memo[idx][s] = ret;
}

int main() {
    cin >> N;
    memo.resize(N);
    cout << dfs("TTT", 0) << endl;
    return 0;
}

Measured memory_bytes: 4060
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int > 
#define pii pair< ll, ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz size
const ll inf=1e18+1e17;
const ll mod = 1e9+7;


ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N=4e5+5;
int arr[N];

void solve() {
	int n,k;
	cin>>n>>k;
	for ( int i=0;i<n;i++)
		cin>>arr[i];
	for ( int i=k;i<n;i++){
		if ( arr[i]>arr[i-k])
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}

  
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
//	cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 4432
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

odd = 0
count = 1
a = A[0]
for i in A[1:]:
  if i == a:
    count += 1
  else:
    a = i
    if count % 2 == 1:
      odd += 1
    count = 1
if count % 2 == 1:
      odd += 1
print(odd)

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

int main(){
    int N,L;
    cin >> N >> L;
    vector<string>S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    string ans;
    for(int i = 0; i < N; i++) {
        ans += S[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    println!("{}", n * (n - 1) / 2);
}


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

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> data(n);
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    data.at(a - 1)++;
    data.at(b - 1)++;
  }
  for(int d : data){
    cout << d << endl;
  }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n%2 == 0) {
    n /= 2;
  } else {
    n = n/2 + 1;
  }
  if (n >= m) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    if(n%2 == 0) n--;
    int i = 1, j = (n+1)/2;
    int q = 2;
    while(q--){
        while(i < j){
            cout << i << " " << j << "\n";
            i++;
            j--;
            m--;
            if(m == 0) break;
        }
        if(m == 0) break;
        if(n == 3) break;
        i = ((n+1)/2) + 1;
        j = n;
    }
    return 0;
}

Measured memory_bytes: 3656
k,n=map(int,input().split())
List=list(map(int,input().split()))
P=[]
for i in range(n-1):
  r=List[i+1]-List[i]
  P.append(r)
P.append(k-List[n-1]+(List[0]-0))
print(sum(P)-max(P))

Measured memory_bytes: 26444
N = int(input())
H = list(map(int, input().split()))

DP = [1e10]*(N)
DP[0] = 0
for i in range(N-2):
    DP[i+1] = min(DP[i+1], DP[i]+abs(H[i] - H[i+1]))
    DP[i+2] = min(DP[i+2], DP[i]+abs(H[i] - H[i+2]))
DP[-1] = min(DP[-1], DP[-2]+abs(H[-1] - H[-2]))
print(DP[-1])

Measured memory_bytes: 13908
import java.util.Scanner;

public class Main {

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

		// input
		final int NUM = scan.nextInt();
		int[] timing = new int[NUM + 1];
		for (int i = 1; i <= NUM; i++) {
			timing[scan.nextInt()] = i;
		}

		// answer
		for (int i = 1; i <= NUM; i++) {
			System.out.print(timing[i] + " ");
		}
		System.out.println("");

	}
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i]; //問題1スタート
  rep(i,n-k){ //i+k=n-1
    if(a[i]<a[i+k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4048
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
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         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout); 
    ll n;
    string s;
    sfl(n);
    cin >> s;
    ll mn = INF,cnt=0,cnt1=0,x=0;
    for(ll i=0;i<n;i++){
        if( s[i]=='R' ) cnt++;
        else cnt1++;
    }  
    mn = min(mn,min(cnt,cnt1));
    ll i=0,j=n-1;
    while(i<j){
        if(s[i]=='W' and s[j]=='R'){
            //cout << i <<' '<<j << endl;
            x++;
            j--;
        }
        while(s[j]=='W' and i < j) j--;
        i++;
    }
    mn = min(mn,x);
    pfl(mn);
    return 0;
}

Measured memory_bytes: 3896
// AtCoder ABC107: B - Grid Compression
// 2019.9.11 bal4u

#include <stdio.h>

int H, W;
char a[105][105];
char b[105][105]; int h, w;
int main()
{
	int r, c;
	
	scanf("%d%d", &H, &W);
	h = 0; for (r = 0; r < H; r++) {
		scanf("%s", a[h]);
		for (c = 0; c < W; c++) if (a[h][c] == '#') break;
		if (c < W) h++;
	}

	w = 0; for (c = 0; c < W; c++) {
		for (r = 0; r < h; r++) if (a[r][c] == '#') break;
		if (r < h) {
			for (r = 0; r < h; r++) b[r][w] = a[r][c];
			w++;
		}
	}
	for (r = 0; r < h; r++) puts(b[r]);
	return 0;
}


Measured memory_bytes: 128