akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=9000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a,b;cin>>a>>b;
    ll h[n];rep(i,0,n)cin>>h[i];
    ll u=10000000000,d=0;
    while(u-d>1){
        ll mid=(u+d)/2;
        ll sum=0;
        rep(i,0,n){
            ll y=h[i]-mid*b;
            if(y<=0)continue;
            sum+=(y+a-b-1)/(a-b);
        }
        if(sum<=mid)u=mid;
        else d=mid;
    }
    cout<<u<<endl;
}




Measured memory_bytes: 1024
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]:
   if A[i][2]>A[i+1][2]:return 0
 return 1
n=int(input())
f=lambda x,i:(x[0],int(x[1]),i)
A=[f(sys.stdin.readline().split(),i)for i in range(n)]
k(A,0,n-1)
print(['Not s','S'][s(A)]+'table')
for e in A:print(*e[:2])


Measured memory_bytes: 20432
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return input().rstrip().split()
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10



#solve
def solve():
    def f0(x):
        for td_ in td:
            if td_[0] == s[x]:
                if td_[1] == "L":
                    x -= 1
                else:
                    x += 1
            if x < 0:
                return True
            if x >= n:
                return False
        return False
    def f1(x):
        for td_ in td:
            if td_[0] == s[x]:
                if td_[1] == "L":
                    x -= 1
                else:
                    x += 1
            if x >= n:
                return True
            if x < 0:
                return False
        return False

    n, q = LI()
    s = S()
    td = LSR(q)
    ok = -1
    ng = n
    ans = n
    while ng - ok > 1:
        mid = (ng - ok) // 2 + ok
        if f0(mid):
            ok = mid
        else:
            ng = mid
    ans -= ok  + 1
    ok = n
    ng = -1
    while ok - ng > 1:
        mid = (ok - ng) // 2 + ng
        if f1(mid):
            ok = mid
        else:
            ng = mid
    ans -= n - ok
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef long double ld;

const int rmax = 20;

int main()
{

    //ifstream cin("input.txt");

    int n;
    cin >> n;

    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }

    int l;
    cin >> l;

    vector<vector<int> > shifts(n, vector<int>(rmax));
    for (int i = 0; i < n; ++i) {
        int pos = lower_bound(all(x), x[i] + l) - x.begin();
        if (pos == n || x[pos] > x[i] + l) {
            --pos;
        }
        shifts[i][0] = pos;
    }

    for (int r = 1; r < rmax; ++r) {
        for (int i = 0; i < n; ++i) {
            int t = shifts[i][r - 1];
            shifts[i][r] = shifts[t][r - 1];
        }
    }

    int q;
    cin >> q;

    while (q--) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) {
            swap(a, b);
        }
        int ans = 0;
        for (int r = rmax - 1; r >= 0; --r) {
            if (shifts[a][r] < b) {
                ans += (1 << r);
                a = shifts[a][r];
            }
        }
        ++ans;
        cout << ans << "\n";
    }

}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a[200010],t;
int main(){
	LL i,k;
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0,t=0;i<n;i++){
		if(a[i]>t){
			cout<<-1<<endl;
			return 0;
		}
		t=a[i]+1;
	}
	a[n]=-1;
	for(i=n-1,k=0;i>=0;i--){
		if(a[i]==a[i+1]-1)continue;
		else k+=a[i];
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;

vector<int> edge[5001];
int h[5001];
int hb[5001];
int n;
int m;

int main()
{
    cin >> n >> m;

    for(int i = 0;i < m;i++)
    {
        int s;int t;
        cin >> s >> t;

        edge[s].push_back(t);
        h[t]++;
        hb[t]++;
    }

    stack<int> st;
    queue<int> bs;
    vector<int> anss;
    vector<int> ansq;

    for(int i = 1;i <= n;i++)
    {
        if(h[i] == 0)
        {
            st.push(i);
            bs.push(i);
        }
    }

    while(!st.empty())
    {
        int v = st.top();
        st.pop();
        anss.push_back(v);
        for(int to : edge[v])
        {
            h[to]--;
            if(h[to] == 0)
            {
                st.push(to);
            }
        }
    }
    while(!bs.empty())
    {
        int v = bs.front();
        bs.pop();
        ansq.push_back(v);
        edge[v].reserve(edge[v].size());
        for(int to : edge[v])
        {
            hb[to]--;
            if(hb[to] == 0)
            {
                bs.push(to);
            }
        }
    }
    bool same = true;
    for(int i = 0;i < anss.size();i++)
    {
        cout << anss[i] << endl;
        if(anss[i] != ansq[i])
        {
            same = false;
        }
    }

    if(same) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
int main(){
int a,b,c,d,f,g;
int card[4][13]={0};
char z;
scanf("%d",&a);
for(b=0;b<a;b++){
scanf("%s %d",&z,&c);
if(z=='S')
card[0][c-1]=1;
if(z=='H')
card[1][c-1]=1;
if(z=='C')
card[2][c-1]=1;
if(z=='D')
card[3][c-1]=1;
}

for(d=0;d<13;d++){
if(card[0][d]==0)
printf("S %d\n",d+1);
}
for(d=0;d<13;d++){
if(card[1][d]==0)
printf("H %d\n",d+1);
}
for(d=0;d<13;d++){
if(card[2][d]==0)
printf("C %d\n",d+1);
}
for(d=0;d<13;d++){
if(card[3][d]==0)
printf("D %d\n",d+1);
}


return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, X = get_ints
XX = get_ints

XX.sort!

sa = ([X] + XX).each_cons(2).map { |a, b| (a - b).abs }

ans = sa[0]
sa.each do |x|
  ans = ans.gcd(x)
end

puts ans


Measured memory_bytes: 23876
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    double a, b, x;
    in >> a, b, x;
    x /= a;

    double pi = std::acos(-1);
    if (x < a * b / 2.) {
        out << atan(b * b / (2 * x)) * 180 / pi;
    } else {
        out << atan(2 * (a * b - x) / (a * a)) * 180 / pi;
    }

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n;
    cin >> n;
    vt<vt<pii>> adj(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].emplace_back(v, i);
        adj[v].emplace_back(u, i);
    }

    vt<int> colors(n);
    function<void(int, int, int)> dfs = [&](int u, int p, int c) {
        int numC = 1;
        for (pii &v : adj[u]) {
            if (v.fi == p) continue;

            if (numC == c) numC++;
            colors[v.se] = numC;
            dfs(v.fi, u, numC);
            numC++;
        }
    };
    dfs(0, -1, -1);

    int mxEdges = 1;
    for (int i = 0; i < n; i++) {
        mxEdges = max(mxEdges, sz(adj[i]));
    }
    cout << mxEdges << '\n';

    for (int i = 1; i < n; i++) {
        cout << colors[i] << '\n';
    }
}


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

int main(){
  int n,i,c;

  cin>>n;

  vector<int> x(n);

  for(i=0;i<n;i++)
  cin>>x.at(i);

  c=0;
  i=0;

  while(i<n){
    if(x.at(i)%2==0){
      x.at(i)/=2;
      i++;
    }
    else{
      cout<<c<<endl;
      break;
    }
    if(i==n-1){
      i=0;
      c++;
    }
  }

}


Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    A, B, C, K = map(int, input().split())

    if abs(K) > 10 ** 18:
        print("Unfair")
        return

    if K % 2 == 0:
        print(A - B)
    else:
        print(B - A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5568
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 long long H;
  cin >> H;
  
  // 2-> 1,1, -> x 3
  // 4-> 2,2 -> 1,1,1,1 -> x 7
  // 5-> 2,2 -> 1,1,1,1 -> x 7
  // 8-> 4,4 -> 2,2,2,2 -> 1,1,1,1,1,1,1,1 15
  
  // 2^(n)-1
  
  int tmp = log2(H); //切り捨て
  
  cout << (long long)pow(2,tmp+1) -1LL << endl;
  
  
  
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
    }
    int ans=0;
    for(int i=0; i<N; i++){
        if(p[i]==i){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
 
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  map<string, int> ma;
  string s;
  while (cin >> s) {
    ma[s]++;
  }
  string ans1, ans2;
  int maxx = 0;
  each(m, ma) if (maxx < m.second) {
    maxx = (int) m.second;
    ans1 = m.first;
  }
  maxx = 0;
  each(m, ma) if (maxx < (int) m.first.size()) {
    maxx = (int) m.first.size();
    ans2 = m.first;
  }
  cout << ans1 << " " << ans2 << '\n';
}



Measured memory_bytes: 3092
N,M = map(int,input().split())
A = [0]*(N+1)
ac = 0
pe = 0
for i in range(M):
    p,S = input().split()
    if A[int(p)] == -1:
        continue
    if S == "AC":
        ac += 1
        pe += A[int(p)]
        A[int(p)] = -1
    else:
        A[int(p)] += 1
print(ac,pe)

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
//const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,m;
int S,T; 
vector<int> v[maxN];
ll dis[maxN][4];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		v[x].push_back(y);
	}
	scanf("%d%d",&S,&T);
	for(int i=1;i<=n;i++)
		for(int j=0;j<3;j++)
			dis[i][j] = INF;
	dis[S][0] = 0;
	queue<pii> Q;
	Q.push(pii(S,0));
	while(!Q.empty())
	{
		pii u = Q.front();
		Q.pop();
		int x = u.first;
		int i = u.second;
		for(auto y : v[x])
		{
			int j = (i+1)%3;
			if(dis[y][j] > dis[x][i] + 1)
			{
				dis[y][j] = dis[x][i] + 1;
				Q.push(pii(y,j));
			}
		}
	}
	if(dis[T][0] == INF)
		puts("-1");
	else
		cout<<dis[T][0]/3<<endl;
	return 0;
}


Measured memory_bytes: 8956
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(int num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(int i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

const int lim = 100000;

signed main(){
  int q; cin>>q;
  int l[q], r[q];
  rep(i,q) cin>>l[i]>>r[i];
  bool check[lim+1];
  check[0] = false;
  reps(i,lim){
    if(IsPrime(i)) check[i] = true;
    else check[i] = false;
  }
  int nums[lim+1]; CLR(nums);
  reps(i,lim){
    nums[i] = nums[i-1];
    if(!i%2) continue;
    if(check[i]&&check[(i+1)/2]) nums[i]++;
  }
  rep(i,8) cerr << i SP ':' SP check[i] SP nums[i] SP IsPrime(i) << endl;
  cerr << endl;
  rep(i,q){
    cout << nums[r[i]]-nums[l[i]-1] << endl;
  }



  return 0;
}


Measured memory_bytes: 1920
while True:
    inps = input().split()
    if len(inps) < 3:
        print("Illegal input.")
        break
    else:
        a = int(inps[0])
        b = int(inps[2])
        if inps[1] == "+":
            print(a + b)
        elif inps[1] == "-":
            print(a - b)
        elif inps[1] == "*":
            print(a * b)
        elif inps[1] == "/":
            print(a // b)
        elif inps[1] == "?":
            break
        else:
            print("Illegal input.")
            break

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

int main(){
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel"<<endl;
  }
  else {
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	reverse(t.begin(),t.end());
	if(s==t)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	int A[110];
	bool ans = true;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
			ans = false;
		}
	}

	printf(ans ? "APPROVED" : "DENIED");

	return 0;
}


Measured memory_bytes: 3724
N,M = map(int,input().split())

t = [-1]*N
for _ in range(M):
    s,c = map(int,input().split())
    s -= 1
    if t[s] == -1 or t[s] == c:
        t[s] = c
    else:
        print('-1')
        exit()
if N != 1:
    if t[0]==0:
        print('-1')
        exit()
    if t[0]==-1:
        t[0]=1
    for i in range(1,N):
        if t[i]==-1:
            t[i]=0
else:
    if t[0]==-1:
        t[0]=0
    
print(''.join(map(str,t)))
   



Measured memory_bytes: 9224
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll bit[60] = {0};
    inp(n);
    inpv(a, n);
    ll ans = 0;
    ll cnt = 0;
    for(int i=n-1; i>=0; i--){
        ll x[60] = {0};
        cnt++;
        for(ll j=0; j<60; j++){
            if((1ll<<j)&a[i]){
                x[j] = 1;;
            }
        }
        for(ll j=0; j<60; j++){
            if(x[j]!=0&&i!=n-1){
                ans += xmod((1ll<<j), MOD)*xmod((cnt-1-bit[j]), MOD);
                ans%=MOD;
            }
            else if(x[j]==0&&i!=n-1){
                ans += xmod((1ll<<j), MOD)*xmod((bit[j]), MOD);
                ans%=MOD;
            }
            bit[j]+=x[j];
        }
    }
    out(ans);
}

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

int main() {
	int n;
	cin >> n;

	int ans = 0;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}

	for (int i = 0; i < n; i++) {
		if (a[a[i]] == i) ans++;
	}

	cout << ans / 2 << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 5001;

void solve() {
	int a, b;
	cin >> a >> b;
	char one = (char)(a + '0');
	char two = (char)(b + '0');
	string res1;
	for (int i = 0; i < a; i++) res1.pb(two);
	string res2;
	for (int i = 0; i < b; i++) res2.pb(one);
	cout << min(res1, res2);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        w: usize,
        h: usize,
        n: usize,
        xxyyss: [(usize, usize, usize); n]
    };
    // (x+0.5, y+0.5) の部分が塗られるかどうかを数える
    let mut area = vec![vec![true; w]; h];
    for (x, y, s) in xxyyss {
        match s {
            1 => {
                for y in 0..h {
                    for xi in 0..x {
                        area[y][xi] = false;
                    }
                }
            }
            2 => {
                for y in 0..h {
                    for xi in x..w {
                        area[y][xi] = false;
                    }
                }
            }
            3 => {
                for x in 0..w {
                    for yi in 0..y {
                        area[yi][x] = false;
                    }
                }
            }
            4 => {
                for x in 0..w {
                    for yi in y..h {
                        area[yi][x] = false;
                    }
                }
            }
            _ => unreachable!(),
        };
    }
    let count = area.iter().fold(0, |acc, row| {
        acc + row.iter().fold(0, |accc, &point| accc + (point as i32))
    });
    println!("{}", count);
}


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

#define fio                          \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;

ll mod(ll a, ll m)
{
   if (a == 0)
      return 0;
   else
      return (a % m + m) % m;
}
int mod(string num, int a)
{

   int res = 0;

   for (int i = 0; i < num.length(); i++)
      res = (res * 10 + (int)num[i] - '0') % a;

   return res;
}

ll d, x, y;
void extendedEuclid(int A, int B)
{
   if (B == 0)
   {
      d = A;
      x = 1;
      y = 0;
   }
   else
   {
      extendedEuclid(B, A % B);
      int temp = x;
      x = y;
      y = temp - (A / B) * y;
   }
}

ll modInverse(int A, int M)
{
   extendedEuclid(A, M);
   return (x % M + M) % M;
}
ll poow(ll a, ll b, ll m)
{

   if (b % 2 == 0)
      return (((ll)pow(a, b / 2) % m) * ((ll)pow(a, b / 2) % m)) % m;
   else
      return (((ll)pow(a, (b - 1) / 2) % m) * ((ll)pow(a, (b + 1) / 2) % m)) % m;
}

bool subsum(ll ar[], ll s, ll n)
{
   if (n == 0 && s != 0)
      return false;
   else if (s <= 0)
      return true;

   else if (ar[n - 1] > s)
      return subsum(ar, s, n - 1);
   else
      return (subsum(ar, s - ar[n - 1], n - 1) || subsum(ar, s, n - 1));
}
int binarySearch(int arr[], int l, int r, int x)
{
   if (r >= l)
   {
      int mid = l + (r - l) / 2;

      if (arr[mid] == x)
         return mid;

      if (arr[mid] > x)
         return binarySearch(arr, l, mid - 1, x);

      return binarySearch(arr, mid + 1, r, x);
   }

   return -1;
}

int main()
{
   fio;
   ll t, a, n, q, k, i, m, c, u, f, j, p, r, x, y, s, b, d;
   //   p= 1000000;
   // bool a[p];

   //       for (i = 2; i <= p; i += 1)
   //          a[i] = true;
   //       a[0] = false;
   //       a[1] = false;
   //       for (i = 2; i * i <= p; i += 1)
   //       {
   //          if (a[i] == true)
   //             for (j = i * i; j <= p; j += i)
   //                a[j] = false;
   //       }
   //  cin >> t;
   t = 1;
   while (t--)
   {
     cin>>n>>k;
     cout<<n*k;
   }

   return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
int main(void)
{
char c;
scanf("%c", &c);
  if(c == 'a' || c == 'e' || c == 'i' ||
  c == 'o' || c == 'u'){
    printf("vowel\n");
  } else {
    printf("consonant\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100

char room[MAX_W][MAX_H];
int W,H;

const int direc[4][2] = {
	{0, -1},
	{1, 0},
	{0, 1},
	{-1, 0},
};

void dfs(const int& row, const int& col, const char c);

int main() {
	while(cin>>H>>W, W > 0) {
		int step = 0;
		int col, row;
		for (row = 0; row < H; ++row) {
			for (col = 0; col < W; ++col) {
				cin >> room[row][col];
			}
		}
		for (row = 0; row < H; ++ row) {
			for(col = 0; col < W; ++ col) {
				if(room[row][col] != '!') {
					dfs(row, col, room[row][col]);
					++ step;
				}
			}
		}
		cout<<step<<endl;
	}
	return 0;
}

void dfs(const int& row, const int& col, const char c) {
	room[row][col] = '!';
	for(int d = 0; d < 4; ++ d) {
		int curRow = row + direc[d][1];
		int curCol = col + direc[d][0];
		if(curRow >= 0 && curRow < H && curCol >= 0 && curCol < W && room[curRow][curCol] == c) {
			dfs(curRow, curCol, c);
		}
	}
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    ll N;
    cin >> N;
    for(int i = 1;i <= 3500;i++){
        for(int j = 1;j <= 3500;j++){
            ll a = i * j * N;
            ll b = (4 * i * j) - N * (i + j);
            if(b == 0 || a % b || a/b < 0)continue;
            cout << i << " " << j << " " << a/b << endl;
            return 0;
            
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

typedef vector<Int> vec;
typedef vector<vec> mat;
Int M;
mat mult(const mat &A,const mat &B){
  assert(A[0].size() == B.size());
  Int n = A.size(),m = B.size(),l = B[0].size();
  mat C(A.size(),vec(l,0));

  for(Int i=0;i<n;i++)
    for(Int j=0;j<l;j++)
      for(Int k=0;k<m;k++) {
        C[i][j] += (A[i][k]*B[k][j]);
        C[i][j] %= M;
      }

  return C;
}

mat pow(mat x, Int y){
  Int N = x.size();
  mat res(N, vec(N, 0));
  for(Int i=0;i<N;i++) res[i][i] = 1;
  while(y){
    if(y&1) res = mult(res, x);
    x = mult(x, x);
    y /= 2;
  }
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    Int N, A, B, C, T;
    cin>>N>>M>>A>>B>>C>>T;
    if(N == 0) break;

    vector<Int> S_0(N);
    cin>>S_0;

    mat X(N, vec(N));
    Int ABC[] = {A, B, C};

    for(Int i=0;i<N;i++){
      for(Int j=-1;j<=1;j++)
        if(0 <= i + j && i + j < N) X[i][i + j] = ABC[j+1];
    }

    X = pow(X, T);
    mat Y(N, vec(1));
    for(Int i=0;i<N;i++) Y[i][0] = S_0[i];

    mat ans = mult(X, Y);
    for(Int i=0;i<N;i++){
      if(i) cout<<" ";
      cout<<ans[i][0];
    }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        ll n,sum=0;
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            if(i%5!=0&&i%3!=0)sum+=i;
        }
        cout<<sum;
        return 0;
    }

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int main()
{
    int n; cin>>n;
    int cnt = 1, cur = 7 % n;
    while (cnt < 2e6 && cur) {
        cnt++;
        cur = (cur*10 % n+7) % n;
    }
    if (cnt == 2e6) puts("-1");
    else printf("%d\n", cnt);
    return 0;
}

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

int main()
{
    int a, b, c, d, e, f, g, ans;

    cin >> a >> b >> c;

    g = a + b + c;
    d = max(a, max(b, c));
    e = min(a, min(b, c));
    f = g - d - e;
    ans = (d * 10) + (e + f);

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;

    vector<long long> a(3*n);
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int idx = 3 * n - 1;
    vector<vector<long long>> vc(n, vector<long long>(3));
    for(int i = 0; i < 3*n; i++){
        if(i >= idx-1) break;
        vc[i][0] = a[i];
        vc[i][1] = a[idx-1];
        vc[i][2] = a[idx];
        idx -= 2;
    }

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

Measured memory_bytes: 8064
#include<iostream>
#include<set>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	set<int> cpp;
	int m, n, i, o;
	cin >> n;
	r(i, n)
	{
		cin >> o;
		cpp.insert(o);
	}

	cin >> m;
	r(i, m)
	{
		cin >> o;
		cpp.insert(o);
	}

	set<int>::iterator iter = cpp.begin();
	for (; iter != cpp.end(); iter++)
		cout << *iter << endl;

	return 0;
}


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

# input
a, b, c = map(int, input().split())

# solve
if a == b and b == c:
    ans = 1
elif a == b and b != c:
    ans = 2
elif a == c and b != c:
    ans = 2
elif b == c and c != a:
    ans = 2
else:
    ans = 3

# output
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
int n,dp[2003][2003],a[6003],ans,tg,MX[2003],cur;
int A[100004],B[100004],C[100004],t;
void init(){t=0;}
void add(int x,int y,int z){A[t]=x,B[t]=y,C[t++]=z;}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)cin>>a[i]; 
	memset(dp,-1,sizeof(dp));
	memset(MX,-1,sizeof(MX));
	dp[a[1]][a[2]]=dp[a[2]][a[1]]=MX[a[1]]=MX[a[2]]=cur=0;
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){tg++;continue;}
		init();
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		if(a[i+1]>a[i+2])swap(a[i+1],a[i+2]);
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		for(int j=1;j<=n;j++){
		if(a[i]==a[i+1])if(dp[j][a[i]]>=0)add(j,a[i+2],dp[j][a[i]]+1);
		if(a[i+1]==a[i+2])if(dp[j][a[i+1]]>=0)add(j,a[i],dp[j][a[i+1]]+1);
		}
		if(dp[a[i]][a[i]]>=0)add(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
		if(dp[a[i+1]][a[i+1]]>=0)add(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);
		if(dp[a[i+2]][a[i+2]]>=0)add(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
		add(a[i],a[i+1],cur),add(a[i+1],a[i+2],cur),add(a[i],a[i+2],cur);
		for(int j=i;j<i+3;j++)for(int k=1;k<=n;k++)if(MX[k]>=0)add(a[j],k,MX[k]);
		for(int j=0;j<t;j++)if(dp[A[j]][B[j]]<C[j])
			dp[A[j]][B[j]]=dp[B[j]][A[j]]=C[j],MX[A[j]]=max(MX[A[j]],C[j]),MX[B[j]]=max(MX[B[j]],C[j]),cur=max(cur,C[j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)if(dp[i][j]>=0)ans=max(ans,dp[i][j]);
		if(dp[i][i]>=0)if(i==a[3*n])ans=max(ans,dp[i][i]+1);
	}
	printf("%d",ans+tg);
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=INF+7,a[100000000],b,c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
           sum+=a[i];
       }
       rep(i,n-1){
           cmp+=a[i];
           sum-=a[i];
           if(i==0){
               ans=Abs(cmp,sum);
           }
          else{
            ans=min(ans,Abs(cmp,sum));
          }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
	int a, aa, b, bb, c, cc, x, xx, count = 0;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &x);


	for (aa = 0; aa <= a; aa++) {
		for (bb = 0; bb <= b; bb++) {
			for (cc = 0; cc <= c; cc++) {
				xx = aa * 500 + bb * 100 + cc * 50;
				if (xx == x) count++;
			}
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc136/tasks/abc136_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << (C > (A - B) ? C - (A - B) : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], cnt[maxn], c[24][maxn];
int n, l, q;
int main(){
	//a[0]=0;
	while(~scanf("%d", &n)){
		for(int i=1; i<=n; i++) scanf("%d", &a[i]);
		scanf("%d", &l);
		for(int i=1; i<n; i++){
			int tmp=cnt[i-1];
			while(tmp<=n && a[tmp]-a[i]<=l) tmp++;
			cnt[i]=tmp-1;
			c[0][i]=tmp-1;
		}
		c[0][n]=n;
		for(int i=1; i<=20; i++){
			for(int j=1; j<=n; j++){
				c[i][j]=c[i-1][c[i-1][j]];
			}
		}
		scanf("%d", &q);
		while(q--){
			int a, b, ans=0;
			scanf("%d%d", &a, &b);
			if(a>b) swap(a, b);
			while(a<b){
				int tmp=0;
				for(tmp=0; tmp<=20; tmp++)
					if(c[tmp][a]>=b)
						break;
				if(tmp) tmp--;
				a=c[tmp][a];
				ans+=1<<tmp;
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 9856
# coding: utf-8
import numpy as np
H, W = map(int, input().split())
S = []
cnt = 0
for i in range(H):
    s = input()
    cnt += s.count("#")
    S.append(s[:])
t_cnt = 0
T = [[False] * W] * H
T = np.array(T)
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            if 0 < i < H-1:
                if 0 < j < W-1:
                    T[i-1][j] = True
                    T[i+1][j] = True
                    T[i][j-1] = True
                    T[i][j+1] = True
                elif j == 0:
                    T[i-1][j] = True
                    T[i+1][j] = True
                    T[i][j+1] = True
                else:
                    T[i-1][j] = True
                    T[i+1][j] = True
                    T[i][j-1] = True
            elif i == 0:
                if 0 < j < W-1:
                    T[i][j-1] = True
                    T[i][j+1] = True
                    T[i+1][j] = True
                elif j == 0:
                    T[i][j+1] = True
                    T[i+1][j] = True
                else:
                    T[i+1][j] = True
                    T[i][j-1] = True
            else:
                if 0 < j < W-1:
                    T[i][j-1] = True
                    T[i][j+1] = True
                    T[i-1][j] = True
                elif j == 0:
                    T[i][j+1] = True
                    T[i-1][j] = True
                else:
                    T[i-1][j] = True
                    T[i][j-1] = True
for i in range(H):
    for j in range(W):
        if T[i][j] and S[i][j] == "#":
            t_cnt += 1
print("Yes" if cnt == t_cnt else "No")


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

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

const MOD: i64 = 1e+9 as i64 + 7;

fn calc(
    first: usize,
    l: usize,
    r: usize,
    seq1: &Vec<usize>,
    seq2: &Vec<usize>,
    memo: &mut Vec<Vec<Vec<i64>>>,
) -> i64 {
    let n = seq1.len();
    let m = seq2.len();
    if l == n || m == r {
        return first as i64;
    }
    if memo[first][l][r] != -1 {
        return memo[first][l][r];
    }
    let mut ret = 0;
    if seq1[l] == seq2[r] {
        ret = (ret + calc(1, l + 1, r + 1, seq1, seq2, memo)) % MOD;
    }
    if first == 1 {
        ret = (ret + calc(1, l + 1, r, seq1, seq2, memo)) % MOD;
    }
    ret = (ret + calc(0, l, r + 1, seq1, seq2, memo)) % MOD;
    memo[first][l][r] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut seq1 = vec![0; n];
    let mut seq2 = vec![0; m];
    for i in 0..n {
        seq1[i] = read::<usize>();
    }
    for i in 0..m {
        seq2[i] = read::<usize>();
    }
    let mut memo = vec![vec![vec![-1; m]; n]; 2];
    let ans = calc(1, 0, 0, &seq1, &seq2, &mut memo);
    println!("{}", ans);
}


Measured memory_bytes: 86524
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        x: [usize; 5],
    }
    println!("{}", x.iter().position(|&xi| xi == 0).unwrap() + 1);
}


Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        a.at(i)=l+i;
        b.at(i)=abs(a.at(i));
    }
    sort(b.begin(),b.end());
    int che = b.at(0);
    int chea =0;
    int ans =0;
    for(int i=0;i<n;i++){
        if(a.at(i)==che||a.at(i)==-1*che){
            if(chea ==0){
            chea++;
            a.at(i)=0;
        }
        }
         ans+=a.at(i);
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    double score = 0.0, t;
    ll p;
    REP(i,1,N+1) {
        p = i;
        t = 1.0;
        while(p < K) {
            p *= 2;
            t *= 0.5;
        }
        score += t;
    }
    cout << setprecision(12) << score / N << endl;


    return 0;
}

/*



*/

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

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

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    int N, a;
    cin >> N;

    int ans = 0;
    REP(i, N){
        cin >> a;
        if (i % 2 == 1) continue;
        if (a % 2 == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588