akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const string yes = "Yes";
const string no = "No";

int main()
{
  string s;
  cin >> s;
  ll sum = 0;
  for (auto c:s) {
    sum += c-'0';
  }
  if (sum % 9 == 0) {
    cout << yes << endl;
  } else {
    cout << no << endl;
  }

  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, h[MAX_N], dp[MAX_N];
    cin >> n;
    REP(i,n) cin >> h[i];
    fill(dp,dp+n+1,IINF);
    dp[0] = 0;
    REP(i,n-1){
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        if(i<n-2)dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(0, n-2):
    if p[i+1] > p[i] and p[i+1] > p[i+2]:
        continue
    elif p[i+1] < p[i] and p[i+1] < p[i+2]:
        continue
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

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

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String line = reader.readLine();
            String[] values = line.split(" ");
            double x1 = Double.parseDouble(values[0]);
            double y1 = Double.parseDouble(values[1]);
            double x2 = Double.parseDouble(values[2]);
            double y2 = Double.parseDouble(values[3]);
            double x3 = Double.parseDouble(values[4]);
            double y3 = Double.parseDouble(values[5]);
            double x4 = Double.parseDouble(values[6]);
            double y4 = Double.parseDouble(values[7]);
            double det = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
            out.println(det == 0.0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 9796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
	//入力機構
	size_t N;
	std::cin>>N;
	std::vector<std::string> W(N,std::string());
	for(size_t i=0;i<N;i++){
		std::cin>>W[i];
	}

	//処理機構
	//2つのルールを別々に調べる
	bool notSame=true,judgeSequence=true;
	const size_t size=W.size();
	//尻文字と頭文字が一致しているかを判定
	for(size_t i=0;i+1<size;i++){
		if(W[i].back()!=W[i+1].front()){
			judgeSequence=false;
			break;
		}
	}
	//同じ文字列が無いか
	//ソートしてから、隣り合う要素がなければ同じ文字列がないかを判定できる。O(nlogn)にできる。
	//これ以降作業がないため、Wを直接いじってしまう
	std::sort(W.begin(),W.end());
	for(size_t i=0;i+1<size;i++){
		if(W[i]==W[i+1]){
			notSame=false;
			break;
		}
	}

	//出力機構
	std::cout<<((notSame && judgeSequence)?"Yes":"No")<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;
    rep(i, n){
        ll x;
        cin >> x;
        
        a.push_back(make_pair(x, i+1));
    }
    sort(ALL(a));
    
    rep(i, n){
        cout << a[i].second << " ";
    }

    return 0;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    ll a,b,x;
    cin>>a>>b>>x;
    cout<<b/x-a/x+(a%x==0)<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int Mo=998244353;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	if(f) x=-x;
	return x;
}
inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
char s1[200],s2[200];
char s3[401];
signed main()
{
	int a=read(),b=read();
	write(a*b/__gcd(a,b));
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var N, M int

func main() {
	fmt.Scan(&N, &M)
	a, b := make([]int, N), make([]int, N)
	c, d := make([]int, M), make([]int, M)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&c[i], &d[i])
	}

	for i := 0; i < N; i++ {
		var ans int = 999999999999
		var point int

		for j := 0; j < M; j++ {
			if abs(a[i]-c[j])+abs(b[i]-d[j]) < ans {
				ans = abs(a[i]-c[j]) + abs(b[i]-d[j])
				point = j + 1
			}
		}
		fmt.Println(point)
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }
func ceil(x int) int      { return int(math.Ceil(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
N = int(raw_input())
blue = []
for i in range(0, N):
	blue.append(raw_input())
wordlist = []
for i in range(0, N):
	if blue[i] not in wordlist: wordlist.append(blue[i])
M = int(raw_input())
red = []
for i in range(0, M):
	red.append(raw_input())

max = 0
for i in range(0, len(wordlist)):
	sum = 0
	for j in range(0, N):
		if wordlist[i] == blue[j]: sum += 1
	for j in range(0, M):
		if wordlist[i] == red[j]: sum -= 1
	if max < sum: max = sum
print max

Measured memory_bytes: 28524
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ans = n % 2 ? n / 2 + 1 : n / 2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void lcs(string a,string b,int m,int n)
{
	int lcs[m+1][n+1];
	
	for(int i=0;i<m+1;i++)
	{
		for(int j=0;j<n+1;j++)
		{
			if(i==0|| j==0)
			{
				lcs[i][j]=0;
			}
			else if(a[i-1]==b[j-1])
			{
				lcs[i][j]=lcs[i-1][j-1]+1;
			}
			else
			{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	
	int r=lcs[m][n];
	string s="";
	int i=m,j=n;
	
	while(i>0 && j>0)
	{
		if(a[i-1]==b[j-1])
		{
			s+=a[i-1];i--;j--;
		}
		else if(lcs[i-1][j]>lcs[i][j-1])
			i--;
		else
			j--;
	}
	
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	
}
int main()
{
	string a,b;
	cin>>a>>b;
	
	int m=a.size();
	int n=b.size();
	lcs(a,b,m,n);
	
	
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int x;
  int y;
  cin >>x>>y;
  vector<int> vec(7);
  vec.at(0)=1;
  vec.at(1)=3;
  vec.at(2)=5;
  vec.at(3)=7;
  vec.at(4)=8;
  vec.at(5)=10;
  vec.at(6)=12;
  
  vector<int>vect(4);
  vect.at(0)=4;
  vect.at(1)=6;
  vect.at(2)=9;
  vect.at(3)=11;
  
  vector<int> vecto(1);
  vecto.at(0)=2;
  
  int count1=0;
  int count11=0;
  
  int count2=0;
  int count22=0;
  
  int count3=0;
  int count33=0;
  
  rep(i,7) {
if (x==vec.at(i)) {
count1++;
}
    if (y==vec.at(i)) {
count11++;
}
  }
  
  rep(i,4) {
if (x==vect.at(i)) {
count2++;
}
    if (y==vect.at(i)) {
count22++;
}
  }
  rep(i,1) {
if (x==vecto.at(i)) {
count3++;
}
    if (y==vecto.at(i)) {
count33++;
}
  }
    
  
  
  if(((count1==1) &&(count11==1)) || ((count2==1) &&(count22==1)))  {
cout << "Yes" << endl;
  }
  else {
cout << "No" << endl;
  }
}
  
  
  
  
  
  
  
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  s += s;
  vector<vector<int>> next(n, vector<int>(26));
  rep(i, 26) {
    for(int j=n; j<s.size(); j++) {
      if(s[j]-'a' == i) {
        next[n-1][i] = j;
        break;
      }
    }
    for(int j=n-2; j>=0; j--) {
      if(s[j+1]-'a' == i)
       next[j][i] = j+1;
      else
        next[j][i] = next[j+1][i];
    }
  }
  ll ans;
  int now;
  rep(i, n) {
    if(s[i] == t[0]) {
      ans = i+1;
      now = i;
      break;
    }
    if(i == n-1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for(int i=1; i<t.size(); i++) {
    if(!next[now][t[i]-'a']) {
      cout << -1 << endl;
      return 0;
    }
    ans += next[now][t[i]-'a']-now;
    now = next[now][t[i]-'a']%n;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, K;

	cin >> N >> K;

	cout << K * (LL)pow((K - 1),N-1) << endl;

	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"

)
func main(){
	var K,A,B int
	fmt.Scan(&K,&A,&B)

	for i:=A;i<=B;i++{
		if(i%K==0){
			fmt.Println("OK")
			return
		}
	}

	fmt.Println("NG")
}

Measured memory_bytes: 1752
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(){
	int p[5]={0,6000,4000,3000,2000};
	int t,n;
	for(int i=0;i<4;i++){
		scanf("%d %d",&t,&n);
		printf("%d\n",p[t]*n);
	}
}


Measured memory_bytes: 3228
#include <stdio.h>
int main (int argc, char * argv[])
{
    int a;
    int h,m,s,h1,h2,m1;
    scanf("%d",&a);
    h = a/3600;
    h1 = h*3600;
    h2 = a - h1;
    m = h2/60;
    m1 = m*60;
    s = a - (h1+m1);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  
        for (int b = 0; b + a <= N; ++b) {  
            int c = N - a - b;  
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T &a, const T &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T> inline bool chmax(T &a, const T &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    string g;
    while(true) {
        cin >> g;
        if(g == "#") return 0;
        int y, m, d;
        cin >> y >> m >> d;
        if(make_tuple(31, 5, 1) <= make_tuple(y, m, d)) {
            cout << "? " << y - 30 << ' ' << m << ' ' << d << endl;
        } else {
            cout << "HEISEI " << y << ' ' << m << ' ' << d << endl;
        }
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << a-b+1 << endl;

    return 0;
}

Measured memory_bytes: 256
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
dp = [0 for i in range(k+1)]
dp[0]=2
for i in range(1,k+1):
    l=0
    for j in range(n):
        if dp[i-a[j]]==2:
            l=l+1
            break
    if l==1:
        dp[i]=1
    else:
        dp[i]=2
if dp[k]==1:
    print("First")
else:
    print("Second")


Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    int now=0;
    int key=a[0];
    int even=0;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        if(a[i]==key){
            now++;
        }
        else {
            if(now%2==0)even++;
            ans++;
            now=1;
            key=a[i];
        }
    }
    if(now%2==0)even++;
    ans++;
    if(even%2==1)ans--;
    cout <<ans <<endl;
}


Measured memory_bytes: 3752
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    vector<int> abc(3);
    for (int i = 0; i < 3; i++)cin >> abc[i];

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

    int ans = INT_MAX;
    int maxV = abc.back();
    int sum = accumulate(abc.begin(), abc.end(), 0);

    if (((maxV * 3) - sum) % 2 == 0) ans = ((maxV * 3) - sum) / 2;
    if ((((maxV + 1) * 3) - sum) % 2 == 0) ans = min(ans, (((maxV + 1) * 3) - sum) / 2);

    cout << ans << endl;

}


























































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

int main(){
  int N,M;
  cin >> N;
  
  map<string,int> plus;
 // map<string,int> minus;
  
  rep(i,N){
    string s;
    cin >> s;
    plus[s]++;
  }
  
  cin >> M;
  
  rep(i,M){
    string s;
    cin >> s;
    if(plus.count(s))
    plus[s]--;
  }
  
  
  int m=0;
  for (auto p : plus) {
  auto value = p.second;
  m=max(m,value);
  
}

  cout << m << endl;
  
  
}

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};

trait OrdTools: Ord + Clone + Sized {
    fn chmin(&mut self, x: Self) {
        *self = std::cmp::min(self.clone(), x);
    }
    fn chmax(&mut self, x: Self) {
        *self = std::cmp::max(self.clone(), x);
    }
}

impl<T: Ord + Clone + Sized> OrdTools for T {}

fn err() -> ! {
    println!("No");
    std::process::exit(0);
}

trait Itertools2: Iterator {
    fn is_sorted2(self) -> bool
    where
        Self: Sized,
        Self::Item: PartialOrd,
    {
        self.is_sorted_by2(PartialOrd::partial_cmp)
    }

    fn is_sorted_by2<F>(mut self, mut compare: F) -> bool
    where
        Self: Sized,
        F: FnMut(&Self::Item, &Self::Item) -> Option<std::cmp::Ordering>,
    {
        let mut last = match self.next() {
            Some(e) => e,
            None => return true,
        };

        while let Some(curr) = self.next() {
            if let Some(std::cmp::Ordering::Greater) | None = compare(&last, &curr) {
                return false;
            }
            last = curr;
        }

        true
    }
}

impl<I: Iterator> Itertools2 for I {}

fn main() {
    input!(n: usize, p: [Usize1; n]);
    let mut l;
    let mut r = 0;
    let mut max = 0;
    while r < n {
        l = r;
        r = l + 1;
        max.chmax(p[l]);
        while r < n && r - 1 < max {
            max.chmax(p[r]);
            r += 1;
        }
        if l + 1 != r
            && ((r - l) % 2 == 0
                || (l..r).any(|i| (i - l) % 2 == 1 && i != p[i])
                || (l..r).any(|i| (i - l) % 2 == 0 && i == p[i])
                || !(l..r)
                    .filter(|&i| (i - l) % 2 == 0 && i < p[i])
                    .map(|i| p[i])
                    .is_sorted2()
                || !(l..r)
                    .filter(|&i| (i - l) % 2 == 0 && i > p[i])
                    .map(|i| p[i])
                    .is_sorted2())
        {
            err();
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6504
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<climits>

using namespace std;
int main() {
	string s;
	cin>>s;

	int ans=INT_MAX;
	for(int i=0; i<s.size()-2; ++i) {
		string str=s.substr(i, 3);
		stringstream ss;
		int n;
		ss<<str;
		ss>>n;
		ans=min(ans, abs(n-753));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

int n;
int a[100];
bool vis[100];

bool check() {
  int x = *max_element(a, a+n);
  vector<int> v;
  for (int i = (x+1)/2+1; i <= x; i++) {
    v.push_back(i);
    v.push_back(i);
  }
  v.push_back((x+1)/2);
  if (x % 2)
    v.push_back((x+1)/2);

  REP (i, v.size()) {
    bool found = false;
    REP (j, n) {
      if (!vis[j] && a[j] == v[i]) {
        vis[j] = true;
        found = true;
        break;
      }
    }
    if (!found)
      return false;
  }

  REP (i, n) {
    if (vis[i]) continue;
    if (a[i] < (x+1)/2 + 1) return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  REP (i, n) cin >> a[i];
  if (check())
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  
  return 0;
}


Measured memory_bytes: 384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	for (int i = -119; i <= 120; i++)
	{
		for (int j = 1; j <= 120; j++)
		{
			if (abs(pow(i, 5) - pow(i-j, 5)) == X)
			{
				cout << i << " " << i-j << endl;
				return 0;
			}
		}
	}

	
	return 0;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 12345678987654321
using namespace std;

int main()
{
    ll i,j,k,l,m,n,o,p,t,z=0;
  cin>>n;
  ll sum=0;
  while(n--)
  {
      cin>>m;
      sum+=m-1;
  }
  cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,k,a[N],y[N],next[N],p[N],d[N],h[N];
priority_queue<int> q;

int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}

void travel(int x){
	h[x]=1;
	for (int i=1;i<=n;i++)
		if (!h[i]&&gcd(a[x],a[i])>1){
			y[++k]=i;next[k]=p[x];p[x]=k;d[i]++;
			travel(i);
		}
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (!h[i]) travel(i),q.push(i);
	while (!q.empty()){
		int x=q.top();q.pop();
		printf("%d ",a[x]);
		for (int t=p[x];t;t=next[t])
			if (--d[y[t]]==0) q.push(y[t]);
	}
	printf("\n");return 0; 
}

Measured memory_bytes: 10624
my $N = 0;
my $M = 0;

my $input_string = <STDIN>;

($N, $M) = split(/ /, $input_string);

my @input_count = ();

for(my $i = 0; $i < $M; $i++){
	push(@input_count, 0);
}

my @input_city = ();
my $j = 0;

until($input_count[-1] == 1){
	my $row_ab = <STDIN>;

	chomp($row_ab);

	my $a = 0;
	my $b = 0;

	($a, $b) = split(/ /, $row_ab);
	
	push(@input_city, ($a, $b));
	
	$input_count[$j] = 1;
	$j++;
}

my @road_city = ();
for(my $i = 0; $i < $N+1; $i++){
	push(@road_city, 0);
}

foreach(@input_city){
	$road_city[$_]++;
}

shift(@road_city);

foreach(@road_city){
	print "$_\n";
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var (
		a int
		b int
	)
	fmt.Scan(&a, &b)

	var c int
	if b < 10 {
		c = 10*a + b
	} else if b < 100 {
		c = 100*a + b
	} else {
		c = 1000*a + b
	}

	if isSquare(c) {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}

func isSquare(n int) bool {
	tmp := false
	for i := 1; i <= 330; i++ {
		if n == i*i {
			tmp = true
			break
		}
	}
	return tmp
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N;
  ll T;
  cin >> N >> T;
  ll t[N];
  rep(i,N) cin >> t[i];
  ll sum = T;
  for(int i = 1; i < N; ++i){
    ll x = t[i] - t[i-1];
    if(x <= T) sum += x;
    else sum += T;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
from collections import*
n,m,*d=map(int,open(0).read().split())
a=Counter(d[:n])
for b,c in zip(d[n::2],d[n+1::2]):a[c]+=b
s=0
for k, v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v;s+=k*v

Measured memory_bytes: 47572
#include <bits/stdc++.h>
#define FI first
#define SE second

using namespace std;

int b,k,mat[505][505],carry;
vector<pair<pair<int,int>,pair<int,int> > >ans;

int main(){
	scanf("%d%d",&b,&k);
	for(int i =0;i<b;i++){
		for(int j =0;j<k;j++){
			scanf("%d",&mat[i][j]);
			mat[i][j]%=2;
		}
	}
	for(int i=0;i<b;i++){
		if(i&1){
			for(int j =k-1;j>=0;j--){
				if(mat[i][j]==1) carry++;
				carry %= 2;
				
				if(carry){
					if(j==0 && i+1<b){
						ans.push_back({{i,j},{i+1,0}});
					} else if(j-1>=0){
						ans.push_back({{i,j},{i,j-1}});
					}
					
				}
				
			}
		} else {
			for(int j =0;j<k;j++){
				if(mat[i][j]==1) carry++;
				carry %= 2;
				
				if(carry){
					if(j==k-1 && i+1<b){
						ans.push_back({{i,j},{i+1,k-1}});
					} else if(j+1<k){
						ans.push_back({{i,j},{i,j+1}});
					}
					
				}
			}
		}
		
	}
	
	printf("%d\n",ans.size());
	for(int i =0;i<ans.size();i++){
		printf("%d %d %d %d\n",ans[i].FI.FI+1,ans[i].FI.SE+1,ans[i].SE.FI+1,ans[i].SE.SE+1);
	}
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll gcd(ll x, ll y){
  return y ? gcd(y, x%y) : x;
}


vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));//p^num
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll GCD = gcd(A, B);
    auto res = prime_factorize(GCD);


    cout << res.size() + 1 << endl;
}

Measured memory_bytes: 256
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

map<ll,int> prime(ll x){
    map<ll,int> e;
    rep(i,sqrt(x)+1){
        if(i <= 1)continue;
        while(x % i == 0){
            e[i]++;
            x /= i;
        }
    }
    if(x != 1)e[x]++;
    return e;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    rreps(i, x){
        auto mp = prime(i);
        if(i == 1){
            cout << 1 << endl;
            continue;
        }
        ll temp = mp.begin()->second;
        if(temp == 1)continue;
        bool ok = true;
        for(auto &it : mp){
            ok &= temp == it.second;
        }
        debug(i, temp, ok);
        if(ok){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n;
    cin >> n;
    VLL a(n);
    REP(i, 0, n)
    cin >> a[i];
    VLL ru(n + 1);
    REP(i, 0, n)
    ru[i + 1] = ru[i] + a[i];
    LL ans = -1;
    REP(i, 1, n)
    {
        LL diff = abs(ru[i] - (ru[n] - ru[i]));
        if (ans < 0)
            ans = diff;
        else
            ans = min(ans, diff);
    }
    cout << ans << endl;
}

int main()
{
    solve();

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    if(n%1000 == 0)
    {
        cout << 0 << endl;
    } else
    {
        cout << 1000 - n%1000 << endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> V(N,0);
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        V[a]++;
    }
    int ans=1;
    if(N%2){
        if(V[0]!=1){
            ans=0;
        }
        for(int i=2;i<N;i+=2){
            if(V[i]==2){
                ans*=2;
                ans%=1000000007;
            }else{
                ans=0;
            }
        }
    }else{
        for(int i=1;i<N;i+=2){
            if(V[i]==2){
                ans*=2;
                ans%=1000000007;
            }else{
                ans=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,a,b; cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}


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



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	string str;
	cin >> str;

	int ans = 0;
	if (str == "SUN") ans = 7;
	if (str == "MON") ans = 6;
	if (str == "TUE") ans = 5;
	if (str == "WED") ans = 4;
	if (str == "THU") ans = 3;
	if (str == "FRI") ans = 2;
	if (str == "SAT") ans = 1;

	cout << ans;
	
}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int pasta,juice,i,n;
	scanf("%d",&pasta);
	for(i=0; i<2; i++){
		scanf("%d",&n);
		if(n<pasta){
			pasta = n;
		}
	}
	scanf("%d",&juice);
	scanf("%d",&n);
	if(n<juice){
		juice = n;
	}
	printf("%d\n",pasta+juice-50);
	return 0;
}

Measured memory_bytes: 592