akhauriyash/Code-Regression huggingface dataset:
import queue

N,M = map(int, input().split())
V   = []

for _ in range(N):
    V.append(set())

for _ in range(M):
    a,b = map(int, input().split())
    V[a-1].add(b-1)
    V[b-1].add(a-1)

q = queue.Queue()

q.put(0)
visit = [False]*N
visit[0] = True
ans_list = [0]*N
while not (q.empty()):
    node = q.get()
    for next_node in V[node]:
        if visit[next_node]:
            continue
        visit[next_node] = True
        ans_list[next_node] = node
        q.put(next_node)

if False in visit:
    print("No")
else:
    print("Yes")
    for i in range(1, len(ans_list), 1):
        print(ans_list[i]+1)

Measured memory_bytes: 63752
#include <iostream>

using namespace std;

int main(void)
{
    int X, Y, sum=0;

    cin >> X >> Y;

    if(X<=3){
        sum += (4-X) * 100000;
    }
    if(Y<=3){
        sum += (4-Y) * 100000;
    }

    if(X==1 && Y==1){
        sum += 400000;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#abc146_b
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())
#tmp = input().split()
#d,c = list(map(lambda a: int(a), tmp))

s=input()
ans=""

for i in range(len(s)):
	tmp=ord(s[i])
	tmp+=n
	if(tmp>90):
		tmp-=26
	ans+=chr(tmp)

print(ans)

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

int main() {
  string a, b;
  cin >> a;
  cin >> b;
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define WHITE 0
#define BLACK 1
#define inf 2001

int main(){
  int n, mincost, sum=0;
  int A[101][101]={}, color[101], d[101], pi[101];
  int i, j, u, v;

  scanf("%d", &n);
  if(n < 0 || 100 < n)
    exit(1);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
      if(A[i][j] != -1 && (A[i][j] < 0 || 2000 < A[i][j]))
	exit(2);
    }
  }

  for(i = 0; i < n; i++){
    d[i] = inf;
    pi[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    mincost = inf;
    for(i = 0; i < n; i++){
      if((color[i] != BLACK) && (d[i] < mincost)){
	  mincost = d[i];
	  u = i;
      }
    }
    if(mincost == inf)
      break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if((color[v] != BLACK) && (A[u][v] != -1) && (A[u][v] < d[v])){
	pi[v] = u;
	d[v] = A[u][v];
      }
    }
  }

  for(i = 0; i < n; i++)
    sum += d[i];
  
  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;


int main() {
	string s;
	LL k;
	cin >> s >> k;
	if(k <= 100) {
		int il = 0;
		for(int i = 0 ; i < k ; ++i) {
			if(s[i] != '1')
				break;
			il++;
		}
		if(il == k) {
			cout << "1\n";
			return 0;
		}
	}
	int in = 0;
	while(s[in] == '1') {
		in++;
	}
	cout << s[in] << "\n";
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

template<typename T>
struct BIT{
    private:
        using Func = function<T(T, T)>;

        int n;
        vector<T> node;

        T init_v;
        Func func;

    public:

        BIT(vector<T> a, Func _func, T _init_v) {
            n = a.size() + 1;
            init_v = _init_v;
            func = _func;

            node.resize(n, init_v);
            for(int i=1; i<n; i++) if((i+(i&-i)) < n) node[i+(i&-i)] = func(node[i+(i&-i)], node[i]);
        }

        void add(int pos, T v) {
            while(pos < size()){
                node[pos] = func(node[pos], v);
                pos += pos & -pos;
            }
        }

        T sum(int pos){
            T res = init_v;
            while(pos > 0){
                res = func(res, node[pos]);
                pos = pos & (pos-1);
            }
            return res;
        }

        int size(){
            return n;
        }
};

int f(int a, int b){
    return a+b;
}

bool comp(pair<int,int> a, pair<int,int> b){
    return a.second < b.second;
}

int main(void){
    int n; cin >> n;
    vector<pair<int, int>> a(n); REP(i,n){cin >> a[i].first; a[i].second = i;}

    SORT(a);
    int m = -1, pre = -1;
    REP(i,n){
        if(a[i].first != pre){
            m++;
            pre = a[i].first;
        }
        a[i].first = m;
    }

    sort(a.begin(), a.end(), comp);

    BIT<int> bit(VI(n,0), f, 0);

    ll ans = 0;
    REP(i,n){
        ans += i-bit.sum(a[i].first);
        bit.add(a[i].first+1, 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5936
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll t ;

    if(c<=a+b)t=b+c;
    else t=a+2*b+1;
    cout << t << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  ll N;cin>>N;
  vector<ll> a(3*N);
  REP(i,0,3*N)cin>>a[i];

  ll ans=-2e18;
  priority_queue<ll,vector<ll>,greater<ll>> pq;
  ll tot=0;
  vector<ll> prefix(3*N);
  REP(i,0,N){
    tot+=a[i];
    pq.push(a[i]);
    prefix[i]=tot;
  }

  REP(i,N,2*N){
    tot+=a[i];
    pq.push(a[i]);
    tot-=pq.top();
    pq.pop();
    prefix[i]=tot;
  }

  while(pq.size())pq.pop();
  tot=0;

  vector<ll> suffix(3*N);
  for(int i=3*N-1;2*N<=i;i--){
    tot-=a[i];
    pq.push(-a[i]);
    suffix[i]=tot;
  }

  for(int i=2*N-1;N<=i;i--){
    tot-=a[i];
    pq.push(-a[i]);
    tot-=pq.top();
    pq.pop();
    suffix[i]=tot;
  }
  REP(i,N-1,2*N){
    ans=max(ans,prefix[i]+suffix[i+1]);
  }
  print(ans);

}

Measured memory_bytes: 8180
#include<stdio.h>
 
int main() {
    int i,j,n;
    int array[200000];
    int array2[200000];
    scanf("%d",&n);
    array[0] = 0;
    array2[0] = 0;
    for(i = 1;i < n;i++) {
        scanf("%d",&array[i]); //添字＝社員番号、中身＝上司の社員番号
        array2[i] = 0;
    }
    for(i = 1;i < n;i++) {
        array2[array[i]-1]++;
    }
    for(i = 0;i < n;i++) {
        printf("%d\n",array2[i]);
    }

    return 0;
}

Measured memory_bytes: 3288
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        C = int((x - 500 * i - 100 * j) / 50)
        if C >= 0 and C <= c:
            cnt += 1
            
print(cnt)

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

class Node{
private:
  int data;
  Node* next;
  Node* prev;
public:
  Node(int x){
    data = x;
  }
  void setData(int x){
    data = x;
  }
  void setNext(Node* n){
    next = n;
  }
  void setPrev(Node* n){
    prev = n;
  }
  Node* getNext(){
    return next;
  }
  Node* getPrev(){
    return prev;
  }
  int getData(){
    return data;
  }
};

class List{
private:
  Node* head;
  Node* tail;
public:
  List(){
    head = new Node(0);
    tail = new Node(0);
    head->setNext(tail);
    tail->setPrev(head);
  }
  Node* Insert(int x){
    Node* p = new Node(x);
    head->getNext()->setPrev(p);
    p->setNext(head->getNext());
    head->setNext(p);
    p->setPrev(head);
    return p;
  }
  Node* getFirst(){
    return head->getNext();
  }
  Node* getLast(){
    return tail->getPrev();
  }
  bool isFirst(Node* node){
    if(node==head){
      return true;
    }else{
      return false;
    }
  }
  bool isLast(Node* node){
    if(node==tail){
      return true;
    }else{
      return false;
    }
  }
  Node* Delete(int x){
    Node* node=head;
    while (node!=tail){
      if (node->getData()==x){
        break;
      }
      node=node->getNext();
    }

    Node* p=head;
    if(node!=tail){
      Node* p=head;
      while (p->getNext()!=node){
        p=p->getNext();
      }
      node->getNext()->setPrev(p);
      p->setNext(node->getNext());
      delete node;
    }
    return p;
  }
  Node* DeleteFirst(){
    Node* tmp=head->getNext();
    Node* p=tmp->getNext();

    head->setNext(p);
    p->setPrev(head);
    delete tmp;
    return p;
  }
  Node* DeleteLast(){
    Node* tmp=tail->getPrev();
    Node* p=tmp->getPrev();

    tail->setPrev(p);
    p->setNext(tail);
    delete tmp;
    return p;
  }
  Node* search(int x){
    Node* p=head;
    while (p!=tail){
      if (p->getData()==x){
        return p;
      }
      p=p->getNext();
    }
    return NULL;
  }
  ~List(){
    Node* p=head;
    while (p!=tail){
      Node* tmp=p;
      p=p->getNext();
      delete tmp;
    }
    delete p;
  }
};

int main(){
  List list;
  int count=0;
  int n;
  cin>>n;

  string c;
  int x;

  for(int i=0; i<n; i++){
    cin >> c;
    if(c=="insert"){
      cin >> x;
      list.Insert(x);
      count++;
    }else if(c=="delete"){
      cin >> x;
      list.Delete(x);
      count--;
    }else if(c=="deleteFirst"){
      list.DeleteFirst();
      count--;
    }else if(c=="deleteLast"){
      list.DeleteLast();
      count--;
    }
  }

  Node* p=list.getFirst();
  while(!list.isLast(p)){
    if(list.isLast(p->getNext())){
      cout << p->getData() << "\n";
      p=p->getNext();
    }else{
      cout << p->getData() << " ";
      p=p->getNext();
    }
  }

  return 0;
}


Measured memory_bytes: 34384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
    double[][] dp;
    double[][] g;
    int N,M;
    public void solve() {
        while (true) {
            N = nextInt();
            M = nextInt();
            if(N + M == 0)break;
            g = new double[N][N];
            dp = new double[M + 1][N];
            for(int i = 0;i < N;i++){
                for(int j = 0;j < N;j++){
                    g[i][j] = nextDouble();
                }
            }
            for(int i = 0;i < N;i++){
                dp[0][i] = 1.0;
            }
            for(int i = 0;i < M;i++){
                for(int j = 0;j < N;j++){
                    for(int k = 0;k < N;k++){
                        dp[i + 1][k] = Math.max(dp[i + 1][k],dp[i][j] * g[j][k]);
                    }
                }
            }
            double ans = 0;
            for(int i = 0;i < N;i++){
                ans = Math.max(dp[M - 1][i],ans);
            }
            out.println(String.format("%.02f", ans));
        }

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main () {
  int N;
  cin >> N;
  int a[N*3];
  
  for (int i=0;i<N*3;++i) {
    cin >> a[i];
  }
  sort(a, a + (N*3), greater<>());
  long sum = 0;
  for (int i=0;i<N;++i) {
    sum += a[2 * i + 1];
  }
  cout << sum << endl;
}


Measured memory_bytes: 1408
from collections import deque
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

DD = [-1, 1]
while 1:
    W, H = map(int, input().split())
    if W == H == 0:
        break
    tx, ty = map(int, input().split())
    kx, ky = map(int, input().split())
    D = [list(map(int, input().split())) for i in range(H)]
    que = deque()
    push = que.append
    pop = que.popleft
    key = (tx-1, ty-1, kx-1, ky-1)
    push(key)
    dist = {key: 0, (kx-1, ky-1, tx-1, ty-1): 0}
    while que:
        x0, y0, x1, y1 = key = pop()
        d = dist[key]
        if x0 == x1 and y0 == y1:
            print(d)
            break
        if d == 99:
            continue
        for dx in DD:
            nx0 = x0 + dx
            if not 0 <= nx0 < W or D[y0][nx0]:
                nx0 = x0
            nx1 = x1 - dx
            if not 0 <= nx1 < W or D[y1][nx1]:
                nx1 = x1
            key = (nx0, y0, nx1, y1)
            if key not in dist:
                dist[key] = d + 1
                push(key)
                key = (nx1, y1, nx0, y0)
                dist[key] = d + 1
        for dy in DD:
            ny0 = y0 + dy
            if not 0 <= ny0 < H or D[ny0][x0]:
                ny0 = y0
            ny1 = y1 - dy
            if not 0 <= ny1 < H or D[ny1][x1]:
                ny1 = y1
            key = (x0, ny0, x1, ny1)
            if key not in dist:
                dist[key] = d + 1
                push(key)
                key = (x1, ny1, x0, ny0)
                dist[key] = d + 1
    else:
        print("NA")


Measured memory_bytes: 69472
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m, s;
	cin>>n>>m>>s;
	vector<P> g[51];
	int a[101]; ll b[101];
	for(int i=0; i<m; i++){
		int u, v; cin>>u>>v>>a[i]>>b[i];
		u--; v--;
		g[u].push_back({v, i});
		g[v].push_back({u, i});
	}
	int c[55]; ll d[55];
	for(int i=0; i<n; i++) cin>>c[i]>>d[i];
	ll dp[51][2525];
	const int mx=2500;
	s=min(s, mx);
	const ll INF=1e18;
	for(int i=0; i<n; i++){
		for(int j=0; j<=mx; j++){
			dp[i][j]=INF;
		}
	}
	using Pl=pair<ll, P>;
	priority_queue<Pl, vector<Pl>, greater<Pl>> que;
	dp[0][s]=0;
	que.push({0, {0, s}});
	while(!que.empty()){
		auto p=que.top(); que.pop();
		int x=p.second.first, y=p.second.second;
		if(p.first>dp[x][y]) continue;
		int y1=min(mx, y+c[x]);
		if(dp[x][y1]>dp[x][y]+d[x]){
			dp[x][y1]=dp[x][y]+d[x];
			que.push({dp[x][y1], {x, y1}});
		}
		for(auto q:g[x]){
			int x1=q.first, k=q.second;
			if(y<a[k]) continue;
			if(dp[x1][y-a[k]]>dp[x][y]+b[k]){
				dp[x1][y-a[k]]=dp[x][y]+b[k];
				que.push({dp[x1][y-a[k]], {x1, y-a[k]}});
			}
		}
	}
	for(int i=1; i<n; i++){
		ll ans=INF;
		for(int j=0; j<=mx; j++){
			ans=min(ans, dp[i][j]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 6268
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1e9;
const LL INFL = 1e18;
const int MOD = 1000000007;


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

  int ans = 0;
  int gs = 0;

  string s;
  cin >> s;

  rep(i, s.length()) {
    if (s[i] == 'g') {
      if (0 < gs) {
        ++ans;
        --gs;
      } else {
        ++gs;
      }
    } else {
      if (0 < gs) {
        --gs;
      } else {
        --ans;
        ++gs;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3720
N,K = map(int,input().split())
m = 10**9 + 7
ans = 0
cnt_arr = [0]*(K+1)
for i in range(K,0,-1):
  cnt = pow(int(K//i), N, mod=m)
  j = 2
  while i*j<=K:
    cnt -= cnt_arr[i*j]
    j+=1
  cnt_arr[i]=cnt
  ans += i*cnt

print(int(ans%m))

Measured memory_bytes: 11112
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int n,a[MAX_N], dp[MAX_N];
int main(void)
{

	ios::sync_with_stdio(false);
	cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i < n; i++)
	{
		if (a[i]<=a[i-1])
		{
			dp[i] = dp[i - 1] + 1;
		}
	}
	cout << *max_element(dp, dp + n) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string S,T; cin>>S>>T;
	// ote(S);//
	// ote(T);//
	int N = S.size();
	bool ans = true;
	rp(i,0,N){
		ans = true;
		int s = i;
		rp(t,0,N){
			// printf("%d %d %c %c\n",s,t,S[s],T[t]);//
			if(S[s] != T[t]){
				ans = false;
				break;
			}
			s = (s+1)%N;
		}
		if(ans) break;
	}
	ote(ans?"Yes":"No");
}


Measured memory_bytes: 256
import sys

def warshall_floyd(d):
    n = len(d)
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[j][k] = min(d[j][k], d[j][i] + d[i][k])
    return d


def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    C = [[int(c) for c in input().split()] for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]

    d = warshall_floyd(C)

    ans = 0
    for a in A:
        for i in a:
            if i == -1:
                continue
            ans += d[i][1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import sys

N, M, X, Y = map(int, input().split())
X_lis = list(input().split())
X_lis = [int(X_lis[i]) for i in range(N)]
Y_lis = list(input().split())
Y_lis = [int(Y_lis[i]) for i in range(M)]

for Z in range(X+1, Y+1):
    if Z > max(X_lis) and Z <= min(Y_lis):
        print('No War')
        sys.exit()
    
print('War')


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

using namespace std;
using ll = long long;
#define int ll

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

vector<string> v;
int N;

void init()
{
	cin >> N;
	v.resize(N);
	rep(i, N) cin >> v[i];
}

void solve()
{
	auto t = v;
	UNIQUE(t);
	if ((int) t.size() != N) {
		PRINT(0);
		return;
	}
	rep(i, N-1) {
		if (v[i][v[i].length()-1] != v[i+1][0]) {
			PRINT(0);
			return;
		}
	}
	PRINT(1);
}



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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

struct Line {
	double a, b, c;
};

struct BIT {
	int N;
	vector<ll> bit;
	BIT(int n) : N(n), bit(N + 1){}
	void add(int a, ll w) {
		for(int x = a; x < N; x |= x + 1) {
			bit[x] += w;
		}
	}
	ll sum(int a) {
		ll ret = 0;
		for(int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
			ret += bit[x];
		}
		return ret;
	}
};

ll getTransNum(vector<int> &r) {
	BIT bit(r.size());
	ll ret = 0;
	for(int i = 0; i < r.size(); i++) {
		ret += i - bit.sum(r[i]);
		bit.add(r[i], 1);
	}
	return ret;
}

bool ok(vector<Line> &L, double c, bool vertical) {
	vector<pair<double, int>> L_c;
	if (vertical) {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// By=C-Ax
			// y=(C-Ax)/B
			double y = (L[i].c - L[i].a * c) / L[i].b;
			L_c.push_back(mp(y, i));
		}
	} else {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// Ax=C-By
			// x=(C-By)/A
			double x = (L[i].c - L[i].b * c) / L[i].a;
			L_c.push_back(mp(x, i));
		}
	}

	sort(L_c.begin(), L_c.end());
	vector<int> r;
	for (int i = 0; i < L_c.size(); i++) {
		r.push_back(L_c[i].second);
	}

	ll n = getTransNum(r);
	ll minn = L.size() * (L.size() - 1) / 2;
	if (minn % 2 == 0) {
		minn = minn / 2;
	} else {
		minn = minn / 2 + 1;
	}
	return n >= minn;
}

int main() {
	int N;
	cin >> N;
	vector<Line> L;
	for (int i = 0; i < N; i++) {
		double a, b, c;
		cin >> a >> b >> c;
		L.push_back((Line){a, b, c});
	}
	vector<Line> L_x = L;
	vector<Line> L_y = L;
	sort(L_x.begin(), L_x.end(), [](Line &lhs, Line &rhs){return lhs.a / lhs.b < rhs.a / rhs.b;});
	sort(L_y.begin(), L_y.end(), [](Line &lhs, Line &rhs){return lhs.b / lhs.a < rhs.b / rhs.a;});

	double ans_x, ans_y;
	double a = -1e30;
	double b = 1e30;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		if (ok(L_x, c, true)) {
			b = c;
		} else {
			a = c;
		}
	}
	ans_x = b;
	
	a = -1e30, b = 1e30;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		if (ok(L_y, c, false)) {
			b = c;
		} else {
			a = c;
		}
	}
	ans_y = b;

	printf("%.15f %.15f\n", ans_x, ans_y);
	return 0;
}



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

bool isPrime(int);

int main(){
  //いもす法でまず累積和を計算しておく
  int n=50000;
  int imos[n+1];
  for(int i=0; i<n+1; i++) imos[i]=0;

  for(int i=1; i<=n; i++){  //1番目から50000番目までの奇数で確認
    if(isPrime(2*i-1) && isPrime(i)) {
      imos[i]++;
    }
  }

  for(int i=1; i<=n; i++) imos[i] += imos[i-1]; //累積和をとる

  int q; cin >> q;
  int l[q], r[q];
  for(int i=0; i<q; i++) cin >> l[i] >> r[i];
  for(int i=0; i<q; i++) cout << imos[(r[i]+1)/2]-imos[(l[i]+1)/2-1] << endl;


  return 0;

}

bool isPrime(int n){
  if(n==1) return false;
  bool isPrime=true;
  for(int i=2; i<n; i++) {
    if(n%i==0){
      isPrime=false;
      break;
    }
  }
  return isPrime;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  int cnt = 0;
  rep(i, n) cnt += a[i] % 2;
  cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;


  
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> dp(N + 1, INF);
    // dp[i]:=[0,i)までで最小コスト
    dp[0] = dp[1] = 0;
    for(int i = 1; i < N; i++) {
        if(i + 1 <= N)
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i - 1]));
        if(i + 2 <= N)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i + 1] - A[i - 1]));
    }
    cout << dp[N] << endl;
    return 0;
}

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

int main()
{
    ll n, q;
    string s;
    cin >> n >> s >> q;
    for (ll i = 0; i < q; i++)
    {
        ll k;
        ll d, m, dm, dmc;
        d = m = dm = dmc = 0;
        scanf("%d", &k);
        for (ll i = 0; i < n; i++)
        {
            if (i - k >= 0)
            {
                if (s[i - k] == 'D')
                {
                    d--;
                    dm -= m;
                }
                if (s[i - k] == 'M')
                    m--;
            }
            if (s[i] == 'D')
                d++;
            if (s[i] == 'M')
            {
                m++;
                dm += d;
            }
            if (s[i] == 'C')
                dmc += dm;
        }
        cout << dmc << endl;
    }
}

Measured memory_bytes: 1412
//don't go gentle into
// the goodnight.

#include<bits/stdc++.h>
using namespace std;

#define int       long long
#define ll        long long
#define fr        first
#define sec       second
#define pi        3.141592653589793
#define M         1000000007
#define mod       998244353
#define maxint    2147483647
#define minint    -2147483648
#define maxll     9223372036854775807
#define minll     -9223372036854775808
#define meme0(a)  memset(a,0,sizeof(a));
#define meme1(a)  memset(a,-1,sizeof(a));
#define i_m_speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open      freopen("input.txt","r",stdin);
#define close     freopen("output.txt","w",stdout);
#define v_int     vector<int >
#define v_ll      vector<long long >
#define pb        push_back
#define mk        make_pair
//upper_bound(begin(),end(),key)
//lower_bound(begin(),.end(),key);

ll expo(ll x , ll n , ll m){
    if(n==0)
        return 1;
    else if(n%2==0)
        return expo((x*x)%m , n/2 , m);
    else
        return (x*expo((x*x)%m,(n-1)/2,m))%m;

}
string toBinary(ll n)
{
    std::string r;
    while(n!=0){
        r=(n%2==0 ?"0":"1")+r;
        n/=2;
    }
    return r;
}


void solve(){
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >>a >> b;
    string u;
    cin >> u;
    if(u==s)
         cout << a-1 << " " << b << endl;
     else if(u==t)
            cout << a << " "  << b-1  << endl;
    else cout << a<< " " << b << endl;

    return;
}
int32_t main(){
    i_m_speed
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	if (S.size() % 2 == 1) cout << "No" << endl;
	else {
		for (int i = 0; i < S.size(); i += 2) {
			string T;
			T += S[i];
			T += S[i + 1];
			if (T != "hi") {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int x , y;

int main()
{
    _FastIO;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
static const int MOD = 1e9 + 7;

int dp0[2005][2005];
int dp1[2005][2005];

int main() {
    
    int n, m;
    cin >> n >> m;
    vector<int> s(n+1), t(m+1);
    for (int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &t[i]);
    }
    dp0[0][0] = 1
        ;
    for (int i = 0; i < n+1; i ++) {
        for (int j = 0; j < m+1; j ++) {
            dp0[i+1][j] += dp0[i][j];
            dp0[i+1][j] %= MOD;
            dp1[i][j] += dp0[i][j];
            dp1[i][j] %= MOD;
            dp1[i][j+1] += dp1[i][j];
            dp1[i][j+1] %= MOD;
            if (s[i] == t[j]) {
                dp0[i+1][j+1] += dp1[i][j];
            }
        }
    }

    int ans = dp1[n][m];
    cout << ans << '\n';



}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n;
    cin >> n;
    vector<pii> v;
    rep(i, n)
    {
        ll x; cin >> x; v.pb({x, i+1});
    }
    sort(all(v));
    for(auto x: v) cout << x.sd << " ";
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 2544
import math
import collections
import itertools
import heapq

def main():
    N = int(input())
    A = list(map(int, input().split()))

    revs_A = sorted(A, reverse=True)
    double_A = sorted(list(map(lambda x: 2*x, A)))
    cum_double_A = list(itertools.accumulate(double_A))[::-1]
    res = 1
    for i, a in enumerate(cum_double_A[1:]):
        if a >= revs_A[i]:
            res += 1
        else:
            break
    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 105760
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
rslt = 0
def score(chr):
    if chr == 'r':
        return p
    elif chr == 's':
        return r
    else:
        return s
stack = ''
for i in range(n):
    if i < k:
        rslt += score(t[i])
        stack += t[i]
    else:
        if t[i] != stack[i-k]:
            rslt += score(t[i])
            stack += t[i]
        else:
            stack += 'a'
print(rslt)  

Measured memory_bytes: 3444
function main(input){
    const int = parseInt;
    const lines = input.split("\n");
    const length = int(lines[0]);
    let nums = lines[1].split(" ").map(item=>int(item));
    let sortingIndex =0;
    let swapCount=0;
    let put = "";

    for(let i=sortingIndex;i<length-1;i++){
        let minIndex = sortingIndex;
        let swapped = false;

        for(let j=sortingIndex;j<length;j++){
            if(nums[j]<nums[minIndex]){
                minIndex = j;
                swapped = true;
            }
            
        }
        if(swapped){
            let temp = nums[i];
            nums[i]=nums[minIndex];
            nums[minIndex]=temp;
            swapCount++;
        }
        sortingIndex++;
    }
    
    
    for(let i=0;i<length;i++){
        put += nums[i] + " ";
    }
    
    console.log(put.trim());
    console.log(swapCount);
    
    
}





main(require("fs").readFileSync("/dev/stdin",'utf-8'));


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

int main() {
    int h, w;

    cin >> h >> w;

    string s = "";

    for (int i = 0; i < h + 2; ++i) {
        for (int j = 0; j < w + 2; ++j) {

            if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
                s += "#";
            } else {
                char a;

                cin >> a;

                s += a;
            }
        }

        s += "\n";
    }

    cout << s;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
 

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll s;
  ll a;
  cin >> s;
  map<ll,ll> b;
  rep(i,s){
    cin >> a;
    b[a]=i;
  }
  if(b.size()==s) pri("YES");
  else pri("NO");
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <numeric>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
  if(a%b==0) return b;
  else return gcd(b, a%b);
}
ll lcn(ll a, ll b){
  return a*b/gcd(a, b);
}
int main(){
  ll a, b, c, d, n1, n2;
  cin >> a >> b >> c >> d;
  n1=b-(b/c+b/d-b/lcn(c, d));
  n2=a-1-((a-1)/c+(a-1)/d-(a-1)/lcn(c, d));
  cout << n1-n2;
  return 0;
}

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

using namespace std;

int main() {
	int n; scanf("%d",&n);
	while (n--) {
		int a; scanf("%d",&a);
		if (a%2==0) {
			if (a%3!=0 && a%5!=0) {
				printf("DENIED");
				return 0;
			}
		}
	}
	printf("APPROVED");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double ret = 0.0;
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			double amount = in.nextDouble();
			boolean btc = in.next().equals("BTC");
			ret += (btc) ? amount * 380000 : amount;
		}
		
		System.out.println(ret);
	}
	
}


Measured memory_bytes: 22612
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b, c; cin >> a >> b >> c;
  if ((a < c && c < b && a < b) || ((a > c && c > b && a > b))) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())

#約数
def divisor(n):
    a = []
    root_n = int(n**0.5)
    for i in range(root_n):
        if n % (i+1) == 0:
            a.append(i+1)
            if (i+1) != n // (i+1):
                a.append(n//(i+1))
    a.sort()
    return a

yaku = divisor(n)
ima = n + 2
for i in yaku:
    othe = n // i
    ima = min(ima,i + othe)
print(ima - 2)

Measured memory_bytes: 3264
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, macOS, linux)
 * Author: ashiknur
 * Time: 2020-02-27 23:40:08
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int count=0,sum=0,flag=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
       if( s[i]=='h')
       {
           count++;
       }
       else if(s[i]=='i')
       {
           sum++;
       }
    }
   for(int i=0;i<s.size()-1;i++)
   {
       if(s[i]=='h' && s[i+1]=='i')
       {
           flag++;
       }
   }
   if(flag==(count+sum+1)/2 && count+sum==s.size())
   {
       cout<<"Yes"<<endl;
       return 0;
   }
   cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
llint a[100005], b[100005];
vector<llint> vec;

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		a[i] *= 2, b[i] *= -2;
	}
	
	llint sum = 0;
	for(int i = 0; i < n; i++){
		sum += (a[i]+b[i])/2;
		vec.push_back(a[i] - (a[i]+b[i])/2);
	}
	sort(vec.rbegin(), vec.rend());
	
	for(int i = 0; i < vec.size(); i++){
		if(i%2) sum -= vec[i];
		else sum += vec[i];
	}
	cout << sum/2 << endl;
	
	return 0;
}

Measured memory_bytes: 2936
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S, T;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> S >> T;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  if (S == T.substr(0, T.size() - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 998244353
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,S; cin>>N>>S;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vii dp(N+1,vi(S+1));
  int ans=0;
  rep(i,0,N){
    dp[i][0]=i+1;
    REP(j,0,S) dp[i+1][j]=dp[i][j];
    if(A[i]<=S){
      ans+=dp[i][S-A[i]]*(N-i)%MOD;
      ans%=MOD;
      REP(j,A[i],S){
        dp[i+1][j]+=dp[i][j-A[i]];
        dp[i+1][j]%=MOD;
      }
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>n>>k;
p=n/k;
a=n-p*k;
p++;
b=abs(n-p*k);
p++;
c=abs(n-p*k);
ans=min({a,b,c});
cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long A,B,K;
  scanf("%ld%ld%ld",&A,&B,&K);
  if(K > A){
    K = K-A;
    A = 0;
    if(K < B){
      B = B-K;
      printf("%ld %ld",A,B);
      return 0;
    }
    else{
      B = 0;
      printf("%ld %ld",A,B);
      return 0;
    }
  }
  else if(K == A){
    A = 0;
    K = 0;
    printf("%ld %ld",A,B);
  }
  else{
    A = A-K;
    K = 0;
    printf("%ld %ld",A,B);
  }
}

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];

    //足りるか
    auto A=a;auto B=b;
    sort(ALL(A));sort(ALL(B));
    bool f=true;
    rep(i,n){
        if(A[i]>B[i]) f=false;
    }
    if(!f){
        cout<<"No"<<endl;
        return 0;
    }

    //ガバイやつがある時点でそれはn-2回で足りる
    auto ga=a;auto gb=b;
    sort(ALL(ga));sort(ALL(gb));
    vector<pair<ll,ll>> v;
    rep(i,n){
        v.push_back(make_pair(b[i],a[i]));
    }
    sort(ALL(v));
    rep(i,n){
        a[i]=v[i].second;
        b[i]=v[i].first;
    }
    //よく考えるとここ要らない．下の条件だけでこれも判定できてる
    // //aに同じのあればガバイ
    // rep(i,n-1){
    //     if(a[i]==a[i+1]){
    //         cout<<"Yes"<<endl;
    //         return 0;
    //     }
    // }
    //左右入れ替えてもクリアできるのがあればガバイ
    rep(i,n-1){
        ll a1=ga[i],a2=ga[i+1],b1=gb[i],b2=gb[i+1];
        if(a1<=b2&&a2<=b1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    //もうガバいのない．aにダブリもないからmap使って考えられる
    map<ll,int> mp;
    rep(i,n){
        mp[ga[i]]=i;
    }
    vector<bool> checked(n,false);
    int begin=mp[a[0]];
    int idx=mp[a[0]];
    checked[0]=true;
    while(idx!=0){
        checked[idx]=true;
        idx=mp[a[idx]];
    }
    int cnt=0;
    rep(i,n){
        if(checked[i]) cnt++;
    }
    // debug(checked);
    if(cnt==n){
        cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 12784