akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,A=0,B=0;
  cin >> N;
  
  vector<int> a(N);
  for(int i=0;i<N;i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  for(int i=0;i<N;i++){
    if(i%2!=0)A+=a.at(i);
    else B+=a.at(i);
  }
    
  cout << max(A,B)-min(A,B) << endl;
  
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// typedef __int128 int128_t;
// typedef unsigned __int128 uint128_t;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<char, int> pci;
typedef tuple<int, int, int> ti3;
typedef tuple<ll, ll, ll> tl3;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define ff          first
#define ss          second

#define pb(x)       push_back(x)
#define ppb()       pop_back()
#define pf(x)       push_front(x)
#define ppf()       pop_front()
#define mp(x,y)     make_pair(x, y)
#define all(v)     begin(v),end(v)
#define gcd(x, y)   __gcd(x, y)

// pbds and ordered set
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T, class cmp = less<T> >
// using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

// for fast I/O
#define endl '\n'
#define FASTIO() ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

const int N = 2e5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const ll INF = INT_MAX-1;

int main() {
  FASTIO();

  string s;
  cin >> s;

  for (int i = 0, n = s.size(); i < n; i++) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }

  cout << s << endl;
  
  return 0;
}



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

using namespace std;

int main() {
  int n;
  cin>>n;
  string c;
  cin>>c;
  int w=0;
  int r=0;
  for(int i=0;i<n;i++){
    if(c.at(i)=='W'){
      w++;
    }
    else{
      r++;
    }
  }
  if(w==0||r==0){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  for(int i=0;i<r;i++){
    if(c.at(i)=='W'){
      ans++;
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[x].parent = y;
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 61648
#include <iostream>

using namespace std;

int main()
{
    int b, r, g, c, s, t;

    while (cin >> b >> r >> g >> c >> s >> t) {
        if (b + r + g + c + s + t == 0)
            break;

        cout << 100 + 2 * c + 7 * g + 95 * b + 63 * r + 3 * s - 3 * t << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    string s; cin >> s;
    ll length = s.length();
    reverse(s.begin(), s.end());
    ll tcnt = 0;
    rep(i, s.length()){
        if(s[i] == 'S') {
            if(tcnt > 0){
                length -= 2;
                tcnt--;
            }
        }else{
            tcnt++;
        }
    }
    cout << length << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main(void){
    int N,i,j,p=0,w=0,g=0,y=0,cou=0;
    char S[1000];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%c",&S[i]);
    }
    for(i=0;i<N;i++){
    if(S[i]=='Y'){
        cou++;
    }
    }
    if(cou!=0){
        printf("Four");
        
    }else{
        printf("Three");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
}; //comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

int main() {
    // A 対 Bの値、A,B両方0の場合、Aが0の場合
    int N;
    cin >> N;
    mint ans = 1;
    int Azero = 0, Bzero = 0;
    int zerozero = 0;
    map<pair<ll, ll>, int> mp;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        if (A == 0 && B == 0) {
            zerozero++;
        } else if (A == 0) {
            Azero += 1;
        } else if (B == 0) {
            Bzero += 1;
        } else {
            ll g = gcd(A, B);
            if (A < 0) {
                A = -A; B = -B;
            }
            A /= g; B /= g;
            mp[make_pair(A, B)]++;
        }
    }
    set<pair<ll, ll>> used;
    ans *= mint(2).pow(Azero) + mint(2).pow(Bzero) - 1;
    for (auto p : mp) {
        auto pl = p.first;
        int x = p.second;
        ll y = pl.first, z = pl.second;
        swap(y, z);
        z *= -1;
        if (y < 0) {
            y *= -1; z *= -1;
        }
        if (used.count(pl)) continue;
        mint mul = mint(2).pow(x) + mint(2).pow(mp[make_pair(y, z)]) - 1;
        used.insert(make_pair(y, z));
        ans *= mul;
    }
    ans += zerozero;
    ans -= 1;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 40856
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    int n;
    cin >> n;
    vector<int> idx;
    for(int i = 0; i < n; i++) {
        int d[2];
        cin >> d[0] >> d[1];
        if(d[0] == d[1]) {
            idx.push_back(i);
        }
    }
    for(int i = 2; i < idx.size(); i++) {
        if(idx[i - 2] + 1 == idx[i - 1] && idx[i - 1] + 1 == idx[i]) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
using namespace __gnu_pbds;
 
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long
#define ull unsigned long long
 
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
 
const int  M    =  1000000007;
const int  maxn =  1001   ;
const long long   inf  =  1e18     ;
const long double eps = 1.084202e-19;
 
 
 
void solve(){
    string s ; 
    int n ; 
    cin >> n ;
    cout<< (n/500)*(1000) + (((n%500)/5)*5);
}
 
int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int te;
      te = 1;
      while(te--){
          solve();
          cout<<"\n";
      }
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n;
cin>>s;
int i=0;
int cnt=0;
while(i<n-2)
{
if(s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C')
{
cnt++;
i=i+3;
}
else
i++;
}
cout<<cnt<<endl;
return 0;
}




Measured memory_bytes: 256
from collections import deque
import math
import bisect
n, d, a = map(int, input().split())
data = []
x_point = []
for i in range(n):
    x,h = map(int, input().split())
    data.append([x,h])
    x_point.append(x)
data.sort()
x_point.sort()
imos = [0] * (n+2)
ans = 0
for i in range(1,n+1):
    x, h = data[i-1]
    imos[i] += imos[i-1]
    index = bisect.bisect_right(x_point, x + 2*d)
    h -= imos[i]
    count = max(math.ceil(h/a), 0)
    ans += count
    imos[i] += count*a
    if index + 1 <= n:
        imos[index+1] -=count*a
print(ans)



Measured memory_bytes: 110216
object Main extends App {
  val x =  scala.io.StdIn.readInt()

  if (x <= 599) {
    println(8)
  } else if (x <= 799) {
    println(7)
  } else if (x <= 999) {
    println(6)
  } else if (x <= 1199) {
    println(5)
  } else if (x <= 1399) {
    println(4)
  } else if (x <= 1599) {
    println(3)
  } else if (x <= 1799) {
    println(2)
  } else {
    println(1)
  }
}


Measured memory_bytes: 54668
#include<bits/stdc++.h>
using namespace std;
#define maxn 800010
#define ll long long
const double pi=acos(-1);
typedef complex<double> cp;
int n,rev[maxn];
cp omega[maxn],iomega[maxn];
void init(int n)
{
        for(int i=0;i<n;i++)
        {
                omega[i]=cp(cos(2*pi/n*i),sin(2*pi/n*i));
                iomega[i]=conj(omega[i]);
        }
        int k=log2(n);
        for(int i=0;i<n;i++)
        {
                int t=0;
                for(int j=0;j<k;j++)if(i&(1<<j))t|=(1<<(k-j-1));
                rev[i]=t;
        }
}
void transform(vector<cp>& a,cp* omega,int n)
{
        for(int i=0;i<n;i++)if(i<rev[i])swap(a[i],a[rev[i]]);
        for(int len=2;len<=n;len<<=1)
        {
                int mid=len>>1;
                for(int j=0;j<n;j+=len)for(int i=0;i<mid;i++)
                {
                        cp t=omega[n/len*i]*a[j+mid+i];
                        a[j+mid+i]=a[j+i]-t;
                        a[j+i]+=t;
                }
        }
}
void fft(vector<cp>& a,int n)
{
        transform(a,omega,n);
}
void ifft(vector<cp>& a,int n)
{
        transform(a,iomega,n);
        for(int i=0;i<n;i++)a[i]/=n;
}
vector<ll> mul(vector<ll> a,vector<ll> b)
{
        int n=1;
        int n1=(int)a.size(),n2=(int)b.size();
        while(n<n1+n2)n<<=1;
        vector<cp> tmp_a(n),tmp_b(n);
        for(int i=0;i<n1;i++)tmp_a[i]=cp(a[i],0);
        for(int i=0;i<n2;i++)tmp_b[i]=cp(b[i],0);
        init(n);
        fft(tmp_a,n),fft(tmp_b,n);
        for(int i=0;i<n;i++)tmp_a[i]*=tmp_b[i];
        ifft(tmp_a,n);
        vector<ll> ans(n);
        for(int i=0;i<n;i++)ans[i]=round(tmp_a[i].real());
        while((int)ans.size()>1 && ans.back()==0)ans.pop_back();
        return ans;
}
vector<ll> a,b;
vector<ll> s;
vector<int> ans;
char c[maxn];
int main()
{
        bool flag=0;
        scanf("%s",c);
        int n=strlen(c);
        if(c[0]=='-')flag^=1;
        for(int i=0;i<n;i++)
        {
                if(c[i]!='-')a.push_back(c[i]-'0');
        }
        reverse(a.begin(),a.end());
        scanf("%s",c);
        if(c[0]=='-')flag^=1;
        n=strlen(c);
        for(int i=0;i<n;i++)
        {
                if(c[i]!='-')b.push_back(c[i]-'0');
        }
        reverse(b.begin(),b.end());
        s=mul(a,b);
        n=(int)s.size();
        int cur=0;
        for(int i=0;i<n;i++)
        {
                cur=cur/10+s[i];
                ans.push_back(cur%10);
        }
        cur/=10;
        if(cur)ans.push_back(cur);
        reverse(ans.begin(),ans.end());
        if(!flag || ((int)ans.size()==1 && ans[0]==0))
        {
                for(int i=0;i<(int)ans.size();i++)printf("%d",ans[i]);puts("");
        }
        else
        {
                putchar('-');
                for(int i=0;i<(int)ans.size();i++)printf("%d",ans[i]);puts("");
        }
        return 0;
}


Measured memory_bytes: 57432
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

for i in range(21):
    k = i*(a-1) + 1
    if k >= b:
        print(i)
        exit()


Measured memory_bytes: 38256
import sys
readline = sys.stdin.buffer.readline

if __name__ == "__main__":
    sx,sy,tx,ty = map(int,readline().split())
    ans = ""
    #tx,tyは必ず右上にあることが言える
    ans += "U"*(ty-sy)
    ans += "R"*(tx-sx)
    ans += "D"*(ty-sy)
    ans += "L"*(tx-sx)
    ans += "L"
    ans += "U"*(ty-sy+1)
    ans += "R"*(tx-sx+1)
    ans += "D"
    ans += "R"
    ans += "D"*(ty-sy+1)
    ans += "L"*(tx-sx+1)
    ans += "U"
    print(ans)

Measured memory_bytes: 38384
// ** Sumonta Saha Mridul **
// SWE - SUST


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

#define ll long long
#define pb push_back
#define endl '\n'
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)


int main()
{
    fast;

   int n , t  , s;

   cin>> n >>t >>s;

 double p;
 p=(double)n / s;


 if(t>=p) cout<<"Yes" ;
 else cout<<"No";

}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

char lastChar(char* T) {
	int i = 0;

	while (true) {
		if (T[i + 1] == '\0') {
			return T[i];
		}
		i++;
	}
}

int main() {
	char A[11], B[11], C[11]; cin >> A >> B >> C;
	char a, b, c;

	a = lastChar(A);
	b = lastChar(B);

	cout << ((a == B[0] && b == C[0]) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
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<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int n;
int f[100][14];
int p[100][15];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    REP(i,n) REP(j,10) cin>>f[i][j];
    REP(i,n) REP(j,11) cin>>p[i][j];
    int res = -(1<<30);
    for(int b=1;b<(1<<10);b++){
        int cc=0;
        for(int i=0;i<n;i++){
            int c=0;
            for(int j=0;j<10;j++) if((b & 1<<j) && f[i][j]) c++;
            cc+=p[i][c];
        }
        if(res<cc) res=cc;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll t[100010];
ll x[100010];
ll y[100010];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
        cin >> t[i] >> x[i] >> y[i];
    }

    bool b=true;

    ll dis = abs(x[0]) + abs(y[0]);
    if(dis>t[0] || dis%2!=(t[0])%2){
        b=false;
    }

    for(ll i=1; i<n ; i++){
        ll dis = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        if(dis>t[i]-t[i-1] || dis%2!=(t[i]-t[i-1])%2){
            b=false;
        }
    }

    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    if(a == b){
        //bが割り切れるなら1割り切れないなら0
        if(b % x == 0){
            cout << 1 << endl;
            return 0;
        }else if(b % x > 0){
            cout << 0 << endl;
            return 0;
        }
        
        return 0;
    }
    
    if(a <= 0){
        cout << b / x + 1 << endl;
    }else{
        a--;
        cout << (b / x) - (a / x) << endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  int i;
  int b[5];
  
  for(i=0;i<5;i++)
  {
    scanf("%d",&b[i]);
  }
  
  for(i=0;i<5;i++)
  {
    if(b[i]!=i+1)
    {
      printf("%d",i+1);
      return 0;
    }
  }
}

Measured memory_bytes: 2084
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

a, b, c, d = list(map(int, input().split()))
if (a <= 0 and b >= 0) or (c<=0 and d>=0):
    zero = True
else:
    zero = False

if zero:
    print(max(a*c, a*d, b*c, b*d, 0))
else:
    print(max(a * c, a * d, b * c, b * d))



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

#define rep(i,n) for(int i = 0;i < n; i++)

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    }else{
        cout << b - a << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+5],q;
	memset(a,0,sizeof(a));
	while(cin>>q)
	{
		if(getchar()=='\n')
		{
			a[q]++;
			break;
		}
		
		a[q]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 4412
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	const int maxn=100050;
	int n,m;	
	bool bl[maxn];
	int h[maxn];
	int ans;
	int main() {
		IOS
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>h[i];
		for(int i=1;i<=m;i++){
			int a,b;
			cin>>a>>b;
			if(h[a]==h[b]){
				bl[a]=bl[b]=1;
			}
			else if(h[a]>h[b]){
				bl[b]=1;
			}
			else
				bl[a]=1;
		}		
		for(int i=1;i<=n;i++)
			if(bl[i]==0)
				ans++;
		cout<<ans<<endl;
	}

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

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

typedef int64_t ll;
typedef long double ld;

const ll INF = 1e18;
const ld EPS = 1e-8;

typedef ll Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst) : src(src), dst(dst), weight(1) {}
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main(){
  int N;
  cin >> N;
  Graph g(N);
  REP(i, N - 1) {
    int a, b, c;
    cin >> a >> b >> c; --a; --b;
    g[a].push_back(Edge(a, b, c));
    g[b].push_back(Edge(b, a, c));
  }
  int Q, K;
  cin >> Q >> K; --K;

  vector<ll> dist(N, INF);
  dist[K] = 0;
  queue<Edge> que;
  que.push(Edge(-1, K));
  while(!que.empty()) {
    Edge e = que.front(); que.pop();
    if(e.src != -1 && dist[e.dst] != INF) continue;
    if (e.src != -1) dist[e.dst] = min(dist[e.dst], dist[e.src] + e.weight);
    for(Edge f : g[e.dst]) {
      if(dist[f.dst] != INF) continue;
      que.push(f);
    }
  }

  REP(i, Q) {
    int x, y;
    cin >> x >> y; --x; --y;
    cout << (dist[x] + dist[y]) << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

ll maxx(ll x,ll y,ll z,ll w){
  return max(x,max(y,max(z,w)));
}
ll minn(ll x,ll y,ll z,ll w){
  return min(x,min(y,min(z,w)));
}
int main() {
  ll N; cin>>N;
  ll ans=10000000000000;
  vector<ll> A(N);
  vector<ll> s(N+1,0);
  rep(i,N){
    cin>>A[i];
    s[i+1]=s[i]+A[i];
  }
  ll i=2;//真ん中の分割
  ll l=1;//l:1~i-1
  ll r=3;//r:i+1~N-1
  ll P,Q,R,S;
  while(i<=N-2){
    while(1){//lを決定する
      if(l<i-1 && abs(s[l]-(s[i]-s[l]))>abs((s[l+1])-(s[i]-s[l+1]))){
        l++;
        continue;
      }
      break;
    }
    while(1){//rを決定する
      if(r<N-1 && abs((s[r]-s[i])-(s[N]-s[r]))>abs((s[r+1]-s[i])-(s[N]-s[r+1]))){
        r++;
        continue;
      }
      break;
    }
    P=s[l];
    Q=s[i]-s[l];
    R=s[r]-s[i];
    S=s[N]-s[r];
    ans=min(ans,maxx(P,Q,R,S)-minn(P,Q,R,S));

    i++;
    if(i==r) r++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    input(a,n);
    input(b,m);
    lint ans=0;
    sort(all(a));
    rep(i,b.size()){
        if(binary_search(all(a),b[i]))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,i;
for(i = 0; i < 20000; i++){
    cin >> x >> y;
    if( x == 0 && y == 0) break;
    if( x >= y ){
        cout << y << " " << x << endl;
    }else{
        cout << x << " " << y << endl;
    };
};
return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;
    ll N;
    ll A[100010],B[100010],C[100010];
    ll ans;
    int ok=0,ng=100001,mid;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    REP(i,N)cin>>B[i];
    REP(i,N)cin>>C[i];
    sort(A,A+N);sort(C,C+N);
    REP(i,N){
        bool x=false,y=false;
        if(!(A[0]<B[i]))x=true;
        if(!(B[i]<C[N-1]))y=true;
        DEB(B[i])TF(x)TF(y)END
        ll res=1;
        if(x||y){
            ans+=0;
            continue;
        }
        ok=0,ng=N;
        while(abs(ok-ng)>1){
            mid=(ok+ng)/2;
            DEB(mid)END
            if(A[mid]<B[i])ok=mid;
            else ng=mid;
        }
        res*=ok+1;DEB(ok)DEB(ng)
        ok=N-1,ng=-1;DEB(res)END
        while(abs(ok-ng)>1){
            mid=(ok+ng)/2;
            DEB(mid)END
            if(B[i]<C[mid])ok=mid;
            else ng=mid;
        }
        res*=N-(ok);
        ans+=res;
        DEB(ok)DEB(ng)END
        DEB(ans)DEB(res)END
    }
    cout<<ans<<endl;

    return 0;
}
/*6
2 3 6 14 53 159
58 9 79 323 84 6
2 50 79 288 383 2643
5*4
3*5*/


Measured memory_bytes: 2560
sx, sy, tx, ty = map(int, input().split())

ans = (abs(tx - sx)  * 'R') + (abs(ty - sy) * 'U')
ans += ((abs(tx - sx) * 'L') + (abs(ty - sy) * 'D'))
ans += 'L' + ((abs(ty - sy) + 1) * 'U') + ((abs(tx - sx) + 1) * 'R') + 'D'
ans += 'R' + ((abs(ty - sy) + 1) * 'D') + ((abs(tx - sx) + 1) * 'L') + 'U'
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = pow(n, 3);
	cout << ans << endl;
	return 0;
}

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

ll dfs(ll d, ll t,int first){
  if(t==0) return (d==0);
  ll res=0;
  // v:dの下一桁の絶対値
  int v=(d%10+10)%10;
  // 10-v-first:vに固定した場合の，二つの辺数の決め方
  // 正の場合
  res+=(10-v-first)*dfs((d-t*v)/10,t/100,0);
  // 負の場合
  if(t) res+=(v-first)*dfs((d+(10-v)*t)/10,t/100,0);
  return res;
}

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

  ll D; cin>>D;
  if(D%9){
    cout<<0<<endl;
    return 0;
  }
  D/=9;
  int ans=0;
  ll p10=1;
  for(int i=1;i<=18;i++){
    p10*=10;
    ans+=(i%2?10:1)*dfs(D,p10/10/9,1);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int xmin,xmax,ymin,ymax;
  xmin = ymin = 0;
  xmax = w;
  ymax = h;
  for(int i=0; i<n; i++){
    int x, y, a;
    cin >> x >> y >> a;
    if(a==1) xmin = max(xmin,x);
    else if(a==2) xmax = min(xmax, x);
    else if(a==3) ymin = max(ymin,y);
    else ymax = min(ymax,y);
  }
  cout << max(0,xmax-xmin)*max(0,ymax-ymin) << endl;
}

Measured memory_bytes: 640
import math

def chmin(a, b):
    if a > b:
        a = b
        return a
    else:
        return a

n = int(input())

dp = [10**5] * (n + 1)
dp[0] = 0

p = int(math.log(n, 6))
q = int(math.log(n, 9))

for i in range(1, n + 1):
    dp[i] = chmin(dp[i], dp[i - 1] + 1)
    for j in range(1, p + 2):
        if i - 6 ** j >= 0:
            dp[i] = chmin(dp[i], dp[i - 6 ** j] + 1)
        else:
            break
    for k in range(1, q + 2):
        if i - 9 ** k >= 0:
            dp[i] = chmin(dp[i], dp[i - 9 ** k] + 1)
        else:
            break

print(dp[n])

Measured memory_bytes: 3828
// A - Getting Difference

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll get_gcd(ll x, ll y) {
	if (y > 0) return get_gcd(y, x % y);
	else return x;
}

int A[100000];

int main() {
	int N, K;
	cin >> N >> K;

	int max_A = 0;
	for (int i=0; i<N; i++) {
		cin >> A[i];
		max_A = max(max_A, A[i]);
	}

	int gcd = A[0];
	for (int i=0; i<N; i++) {
		gcd = get_gcd(gcd, A[i]);
	}

	string ans;
	if (K <= max_A && K % gcd == 0) ans = "POSSIBLE";
	else ans = "IMPOSSIBLE";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3936
# -*- coding: utf-8 -*-

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve
ans = set()
for i in range(N):
    if A[i] in ans:
        ans.remove(A[i])
    else:
        ans.add(A[i])

# output
print(len(ans))


Measured memory_bytes: 13204
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>

using namespace std;
const int MAX_N = 200;
int N;
int A[MAX_N];

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

    cin >> N;

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

    int ans = 0;
    bool alleven = true;
    while (alleven) {
        for (int i = 0; i < N; i++) {
            if (A[i] & 1) {
                alleven = false;
                break;
            }
            A[i] = A[i] >> 1;
        }
        if (alleven)
            ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    
    int hour = (int) a / 3600;
    int min = (a - hour * 3600) / 60;
    int sec = a - 3600 * hour - 60 * min;
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}


Measured memory_bytes: 3088
from sys import stdin
n,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
def knapsack(n,w,li):
    #li[i][0]が重さ,li[i][1]が価値
    dp = [[0 for i in range(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - li[i][1] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-li[i][1]]+li[i][0])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return max(dp[-1])
print(knapsack(n,w,li))


Measured memory_bytes: 25952
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int i=0,c=0;
    while(i<s.length()){
        if(s[i]!=t[i])
         c++;
        i++;
    }
    cout<<c<<endl;
}


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

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


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	LL x;
	cin >> n >> x;
	vector<LL> as(n);
	for(int i = 0; i < n; ++i){ cin >> as[i]; }
	LL ans = 0;
	LL prv = 0;
	for(int i = 0; i < n; ++i){
		if(prv + as[i] > x){
			ans += prv + as[i] - x;
			prv = x - prv;
		}
		else{
			prv = as[i];
		}
	}
	cout << ans << endl;
}



}
int main() try{
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
uint d[100000];

bool gint(const uint& l, const uint& r) { return l > r; }
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0;
	cin >> n;
 
	for (unsigned int i = 0; i < n; i++) {
		uint a, b;
		cin >> a >> b;
		d[i] = a + b;
		t -= b;
	}
 
	sort(d, d+n, gint);
 
	for (unsigned int i = 0; i < n; i+=2) {
        t += (ll)(d[i]);
	}
 
    cout << t << endl;
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;

    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef long long ll;

int main(){
    int x, y;
    cin >> x >> y;
    int g1[]={1,3,5,7,8,10,12}, g2[]={4,6,9,11}, g3[]={2};
    int X=0, Y=0;
    
    for(int i=0; i<7; i++){
        if(g1[i]==x){
            X=1;
        }
        if(g1[i]==y){
            Y=1;
        }
    }
    for(int i=0; i<4; i++){
        if(g2[i]==x){
            X=2;
        }
        if(g2[i]==y){
            Y=2;
        }
    }
    if(x==2) X=3; if(y==2) Y=3;
    
    cout << ((X==Y)?"Yes":"No") << endl;
}


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

int main()
{
	int32_t K, S;
	cin >> K >> S;

	int32_t sum = 0;
	for (int32_t x = 0; x <= K; x++) {
		for (int32_t y = 0; y <= K; y++) {
			int32_t z = S - x - y;
			if (z >= 0 && z <= K) {
				sum++;
			}
		}
	}

	cout << sum  << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define nax 1000005
#define mod 1000000007
#define ll long long int
using namespace std;
int main(){
	int n=0;
	cin >> n;
	vector<string> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	int c=0,a=0,b=0,ba=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<v[i].length()-1;j++){
			if(v[i][j]=='A' && v[i][j+1]=='B'){
				c++;
			}
		}
		if(v[i][0]=='B' && v[i][v[i].length()-1]=='A'){
			ba++;
		}
		else if(v[i][v[i].length()-1]=='A'){
			a++;
		}
		else if(v[i][0]=='B'){
			b++;
		}
	}
	if(a==b && ba>0 && a+b<ba){
		ba--;
	}
	c+=min(a+ba,b+ba);
	cout << c;
	return 0;	
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

const int MAX_N=100005;
int n;
int a[MAX_N];

int main()
{
	while(cin>>n){
		for(int i=1;i<=n;++i)
			cin>>a[i];
		sort(a+1,a+n+1);
		int t=(n+1)/2;
		LL ans=a[t]-a[t+1];
		if(n%2)    ans=max(a[t]*3-a[t+1],a[t]+a[t-1]);
		for(int i=1;i<=t;++i)
			ans-=a[i]*2;
		for(int i=t+1;i<=n;++i)
			ans+=a[i]*2;
		cout<<ans<<endl;
	}
	
	return 0;
}

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

int main() {
  double A,B;
  cin >> A >> B;
  for(int i=1; i<=1100; i += 1){
    int X = i*8/100;
    int Y = i*10/100;
    if(X == A && Y == B){
      cout << i << endl;
      return 0;
    }
  }
cout << -1 << endl;
}


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

using namespace std;

typedef long long int lli;

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

    int n, cont = 0;
    cin >> n;
    vector<int> a(n+1), ans(n+1);
    for (int i=0; i<n; i++) {
        cin >> a[i+1];
        if (i+1 > n/2) {
            ans[i+1] = a[i+1];
            if (a[i+1]) cont++;
        }
    }

    for (int i=n/2; i>0; i--) {
        int sum = 0;
        for (int j=2; i*j<=n; j++) {
            sum += ans[i*j];
        }
        if  ((sum%2 && a[i]) || (!(sum%2) && !a[i])) {
            ans[i] = 0;
        }
        else {
            ans[i] = 1;
            cont++;
        }
    }

    cout << cont << endl;
    for (int i=0; i<n; i++) {
        if (ans[i+1]) cout << i+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl


signed main(){
    
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int Ans=0;
    REP(i,N+1){
        REP(j,N+1){
            int Y=N-R*i-G*j;
            if(Y%B==0 && Y>=0){
                Ans++;
                //cout << i << " " <<j << " " << Y/B << endl;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long num, sum = 0;
  scanf("%lld", &num);
  for(long long i=1; i<num; i++){
    sum += i;
  }
  if(num==1){
    printf("0");
  }else{
    printf("%lld\n", sum);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int k,arr[11];
vector<int>v;
int main(){
    cin>>s>>k;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        arr[x]++;
    }
    for(int i=0;i<=9;i++){
        if(arr[i]==0){
            v.push_back(i);
        }
    }
    int id = -1;
    for(int i=0;i<s.size();i++){
        int num = s[i]-'0';
        if(arr[num]){
            id = i;
            break;
        }
    }
    if(id==-1)goto end;
    int j;
    for(j=0;j<v.size();j++){
        if(v[j] > s[id]-'0'){
            s[id] = v[j]+'0';
            break;
        }
    }
    if(j == v.size()){
        if(v[0]==0)
            s[0] = v[1]+'0';
        else
            s[0] = v[0]+'0';
        for(int i=1;i<s.size();i++)
            s[i] = v[0]+'0';
        s += v[0]+'0';
        goto end;
    }
    for(int i=id+1;i<s.size();i++){
        s[i] = v[0]+'0';
    }
    end:;cout<<s<<endl;
}

/*
200 8
2 3 4 5 6 7 8 9

*/


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;



int main(){
	string s;
	while (cin>>s) {
		int jo = 0, io = 0;
		for (int i = 0; i < s.size() - 2; i++) {
			if (s[i] == 'J'&&s[i + 1] == 'O'&&s[i + 2] == 'I') jo++;
			if (s[i] == 'I'&&s[i + 1] == 'O'&&s[i + 2] == 'I') io++;
		}
		cout << jo << endl;
		cout << io << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ii pair<int,int>
#define iii pair<int,ii>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define nu 100000
#define mod 1000000007
#define inf pow(10,8)
#define h pow(10,-8)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
	fastio;

	int n, t, x, y;
	cin >> n;
	vector<iii> v(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> t >> x >> y;
		v[i].fi = t;
		v[i].se.fi = x;
		v[i].se.se = y;
	}

	t = 0, x = 0, y = 0;

	for (int i = 0; i < n; ++i)
	{
		int d = abs(v[i].se.fi-x) + abs(v[i].se.se-y), T = v[i].fi-t;
		if ((d>T) || ((T-d)%2==1))
		{
			cout << "No";
			return 0;
		}

		t = v[i].fi, x = v[i].se.fi, y = v[i].se.se;
	}

	cout << "Yes";
}

Measured memory_bytes: 1408
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class topological_sort {
private:
	int V;
	vector<vector<int>> edges;
	vector<int> in;
public:
	topological_sort(int n) :V(n), edges(n), in(n) {}
	topological_sort(vector<vector<int>> &edges) :V(edges.size()), in(edges.size()) { this->edges = edges; }

	void add_edge(int from, int to) { edges[from].emplace_back(to); }

	vector<int> build() {

		for (int i = 0; i < V; i++) for (const auto &e : edges[i]) in[e]++;

		vector<int> used(V), res;
		res.reserve(V);
		queue<int> que;

		for (int i = 0; i < V; i++) {
			if (in[i] == 0 && !used[i]) {
				used[i] = 1;
				que.emplace(i);
			}
		}

		while (!que.empty()) {
			int now = que.front();
			DMP(now, in);
			que.pop();
			res.emplace_back(now);
			for (const auto &e : edges[now]) {
				in[e]--;
				if (in[e] == 0) {
					if (used[e]) return vector<int>(); // unable to sort
					used[e] = used[now] + 1;
					que.emplace(e);
				}
			}
		}
		cout << *max_element(used.begin(), used.end()) - 1 << "\n";
		return res;
	}

};

int main() {

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

	int N, M;
	cin >> N >> M;

	topological_sort ts(N);
	for (int i = 0; i < M; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		ts.add_edge(s, t);
	}

	auto ord = ts.build();

	return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>

int main(){
   long long int a,b,x,i=0;

  scanf("%lld",&a);
  scanf("%lld",&b);
  scanf("%lld",&x);

  if(a != 0)

    {
    i= b/x - (a-1)/x;
    }

    else
    {
    i= b/x+1;
    }
   printf("%lld\n",i);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a[10],b=0,c=130,i;
	for(i=0;i<6;i++){
		scanf("%d",&a[i]);
		if(i<5){
			b=max(b,a[i]);
			c=min(c,a[i]);
		}
	}
	if(b-c<=a[5]){
		printf("Yay!");
	}else{
		printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128