akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){
 int n;
  cin >>n;
 int a[n];
 for(int i=0;i<n;i++) cin >> a[i];
  
  int res=0;
  int crt=0;
  while(res<n&&crt!=1){
   int ptr=a[crt];
   res++;
    crt=ptr-1;
  }

  if(res==n) cout << -1 << endl;
  else cout << res << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i,n)std::cin >> a[i];
  int c=1;
  rep(i,n){
    if(a[i]==c){
      c++;
    }
  }
  if(c==1)std::cout << -1 << std::endl;
  else  std::cout << n-c+1 << std::endl;
}

Measured memory_bytes: 1152
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (x, y) = scan!(i64, i64);
    println!("{}", if (x - y).abs() <= 1 { "Brown" } else { "Alice" })
}


Measured memory_bytes: 4352
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "vowel"; }
  string_type do_falsename() const { return "consonant"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int N;
ll d, x[128000], y[128000];
int deg[128000];
int visited[128000];

using Graph = vector<vector<int>>;

ll dist(int i, int j) {
  return max(abs(x[i] - x[j]), abs(y[i] - y[j]));
}

void make_graph(Graph &g) {
  vector<tuple<ll,ll,int>> vs;
  REP(i,N) vs.emplace_back(x[i], y[i], i);
  sort(ALL(vs));
  REP(i,N) {
    auto lp = lower_bound(ALL(vs), make_tuple(x[i] + d, y[i] - d, 0));
    auto rp = lower_bound(ALL(vs), make_tuple(x[i] + d, y[i] + d, 0));
    if (lp == end(vs)) continue;
    if (rp == begin(vs)) continue;
    --rp;
    int l = get<2>(*lp);
    int r = get<2>(*rp);
    if (x[l] != x[i] + d || dist(i, l) != d) continue;
    if (x[r] != x[i] + d || dist(i, r) != d) continue;
    deg[i] += rp - lp + 1;
    g[i].push_back(l);
    g[i].push_back(r);
    g[l].push_back(i);
    g[r].push_back(i);
    if (i == N - 1) continue;
    if (x[i] != x[i+1] || dist(i + 1, r) != d) continue;
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
}

void dfs(const Graph &g, int v) {
  if (visited[v]) return;
  visited[v] = true;
  for (int i: g[v]) {
    dfs(g, i);
  }
}

void solve() {
  int a, b;
  cin >> N >> a >> b;
  --a; --b;
  REP(i,N) {
    int xx, yy;
    cin >> xx >> yy;
    x[i] = xx + yy;
    y[i] = xx - yy;
  }
  d = dist(a, b);
  Graph g(N);
  REP(i,4) {
    make_graph(g);
    REP(j,N) tie(x[j], y[j]) = make_pair(y[j], -x[j]);
  }
  dfs(g, a);
  ll res = 0;
  REP(i,N) {
    if (visited[i]) res += deg[i];
  }
  cout << res / 2 << endl;
  return;
}


Measured memory_bytes: 23236
N = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

ls = num_divisors_table(N)
ans = 0
for i in range(1, N+1):
    ans += i * ls[i]
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    double s = 1.0*w*h/2;
    bool cond1 = w%2==0&&x==w/2;
    bool cond2 = h%2==0&&y==h/2;
    if(cond1 && cond2){
        cout<<std::setprecision(10)<<s<<" "<<1<<endl;
    }else{
        cout<<std::setprecision(10)<<s<<" "<<0<<endl;
    }
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int n,m,to=0,ans;
	int t[101],p,x;
	cin>>n;
	for(int i=0;i<n;i++){
		 cin>>t[i];
		to+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		ans=to;
		cin>>p>>x;
		ans-=(t[p-1]-x);
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
#define ll long long


ll A, B, Q;
ll s[100002], t[100002], x[100002];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> A >> B >> Q;
    s[0] = -1e18;
    for (int i = 1; i <= A; ++i) {
        cin >> s[i];
    }
    s[A+1] = 1e18;
    t[0] = -1e18;
    for (int i = 1; i <= B; ++i) {
        cin >> t[i];
    }
    t[B+1] = 1e18;
    
    ll s_l, s_r, t_l, t_r, x_i;
    for (int i = 0; i < Q; ++i) {
        cin >> x_i;
        
        ll* b;
        ll* d;
        b = upper_bound(s, s + A + 2, x_i) - 1;
        ll S[2], T[2];
        S[0] = *b;
        S[1] = *(b + 1);
        d = upper_bound(t, t + B + 2, x_i) - 1;
        T[0] = *d;
        T[1] = *(d + 1);
        ll res = 1e18;
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                ll d1 = abs(S[j] - x_i) + abs(T[k] - S[j]);
                ll d2 = abs(T[k] - x_i) + abs(S[j] - T[k]);
                res = min({res, d1, d2});
            }
        }
                
        cout << res << endl;
    }

    return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <stack>
using namespace std;
static const int MAX = 100;
static const int NIL = -1;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int M[MAX][MAX], n, tt = 0;
int d[MAX], f[MAX], color[MAX];
stack<int> S;

int next(int v)
{
    for (int i = 0; i != n; ++i)
    {
        if (M[v][i] != 0)
        {
            if (color[i] == WHITE)
            {
                return i;
            }
        }
    }
    return NIL;
}

void dfs(int u)
{
    int v;
    S.push(u);
    color[u] = GRAY;
    d[u] = ++tt;
    while (S.size())
    {
        u = S.top();
        v = next(u);
        if (v != NIL)
        {
            S.push(v);
            color[v] = GRAY;
            d[v] = ++tt;
        }
        else
        {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }     
    }
}

int main()
{
    int id, m, v;
    cin >> n;
    for (int i = 0; i != MAX; ++i)
    {
        d[i] = 0;
        f[i] = 0;
        color[i] = WHITE;
        for (int j = 0; j != MAX; ++j)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        cin >> id >> m;
        for (int j = 0; j != m; ++j)
        {
            cin >> v;
            M[id-1][v-1] = 1;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        if (color[i] == WHITE) dfs(i);
    }

    for (int i = 0; i != n; ++i)
    {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
x,y = input().split()
a = ['1','3','5','7','8','10','12']
b = ['4','6','9','11']

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x == '2' and y == '2':
    print('Yes')
else:
    print('No')

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;

    int n = (100 * r) + (10 * g) + b;
    cout << (n % 4 == 0 ? "YES" : "NO") << endl;

    return 0;
}


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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  
  if (A > B) {
    cout << "Alice" << endl;
  } else if (A < B) {
    cout << "Bob" << endl;
  } else { 
    cout << "Draw" << endl;
  }
  
  
}

Measured memory_bytes: 256
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5

test_case 1,6 == 50 delivery point
		 2,3,4,5,7 == 80 delivery point
				8,9 == 90 delivery point
				10 > 100 delivery point
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long dp[302][302][302] = {};//day,undetermined,determined
int main() {
	long long n, m;
	cin >> n >> m;
	dp[0][1][1] = 1;
	for (long long i = 0; i < m; ++i) {
		for (long long q = 1; q <= n; ++q) {
			for (long long j = 1; j <= n; ++j) {
				dp[i + 1][q + 1][j] += dp[i][q][j] * (n - q);
				dp[i + 1][q + 1][j] %= MAX_MOD;
				dp[i + 1][q][j] += dp[i][q][j] * (q - j);
				dp[i + 1][q][j] %= MAX_MOD;
				dp[i + 1][q][q] += dp[i][q][j] * j;
				dp[i + 1][q][q] %= MAX_MOD;
			}
		}
	}
	cout << dp[m][n][n] << endl;
}

Measured memory_bytes: 214528
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			double r = double.Parse(Console.ReadLine());
			//var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			double area = Math.PI * r * r;
			double length = 2.0 * Math.PI * r;
			Console.WriteLine($"{area:f5} {length:f5}");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 17944
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define endl "\n"
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e6+4;
 
ll fac[N],infac[N];

ll me(ll a,ll b)
{
    ll res=1;
 
    while(b)
    {
        if(b&1)
        res=(res*a)%mod;
 
        b>>=1;
 
        a=(a*a)%mod;
    }
 
    return res;
}
 
ll mi(ll a)
{
    return me(a,mod-2);
}
 
void factorial()
{
   fac[0]=1;
 
   for(ll i=1;i<N;i++)
   fac[i]=(i*fac[i-1])%mod;
 
   infac[N-1]=mi(fac[N-1]);
 
   for(ll i=N-1;i>=1;i--)
   infac[i-1]=(i*infac[i])%mod;
}
 
ll ncr(ll n,ll r)
{
    if(n<r)
    return 0;
 
    ll val=fac[n];
 
    val=(val*infac[r])%mod;
 
    val=(val*infac[n-r])%mod;
 
    return val;
}
 
int main()
{	
	factorial();

	int k; scn(k);

	string s; cin>>s; int n=(int)s.size();

	ll ans=0;

	rep(x,0,k+1)
	{
		ll here = (me(26,x)*me(25,k-x))%mod;

		here = (here*ncr(k-x+n-1,n-1))%mod;

		//cout<<here<<endl;

		ans=(ans+here)%mod;
	}

	lpri(ans);

	return 0;
}                   

Measured memory_bytes: 36660
#include <stdio.h>

int main() {
	int a, b, c, max = 0;

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

	if (a >= max) max = a;
	if (b >= max) max = b;
	if (c >= max) max = c;

	printf("%d\n", a + b + c - max);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s(n+1);
  rep(i, n) s[i+1] = s[i]+a[i];
  ll ans = 1e18;
  int l = 0, r = 2;
  for (int i = 2; i < n-1; i++) {
    while (abs(s[i]-2*s[l+1]) < abs(s[i]-2*s[l]))
      l++;
    while (abs(s[n]-2*s[r+1]+s[i]) < abs(s[n]-2*s[r]+s[i]))
      r++;
    ll l1 = s[l], l2 = s[i]-s[l];
    ll r1 = s[r]-s[i], r2 = s[n]-s[r];
    ll mn = min({l1, l2, r1, r2});
    ll mx = max({l1, l2, r1, r2});
    chmin(ans, mx-mn);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    char b;
    cin >> b;
    if (b=='A'){
        cout << 'T' << endl;
    }
    else if (b=='T'){
        cout << 'A' << endl;
    }
    else if (b=='G'){
        cout << 'C' << endl;
    }
    else if(b=='C'){
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;


int main(){
    //bool ans=false;
    int a,b,s=6;

    cin>>a>>b;
    cout<<s-a-b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll a, b;
  cin >> a >> b;

  if(a>0){
    cout << "Positive\n";
    return 0;
  }
  if(a<0 && b>0){
    cout << "Zero\n";
    return 0;
  }
  if((b-a)%2==0){
    cout << "Negative\n";
    return 0;
  }

  cout << "Positive\n";
  return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


// ABC116 C - Grand Garden
int main(){
  int n ;
  cin >> n;
  vector<int> h(n,0);
  rep(i, n) cin >> h[i];

  vector<int> cur(n,0);

  const auto findStartIndex = [&h,&cur,&n]() -> int {
    rep(i,n){
      if (h[i]>cur[i]) {
        return i;
      }
    }
    return -1;
  };

  int ans = 0;
  for (int i = findStartIndex(); i != -1; i = findStartIndex()) {
    ++ans;
    int baseH = cur[i];
    for (int j = i; j < n; ++j) {
      if (cur[j] == baseH && h[j] > baseH) {
        cur[j]++;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
n, m = map(int,input().split())
k = []
s = []

for i in range(m):
    temp = list(map(int, input().split()))
    temp_k = temp[0]
    temp_s = temp[1:]
    k.append(temp_k)
    s.append(temp_s)

p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    on = bin(i)[2:].rjust(n,"0")
    cond = 0
    for j in range(m):
        cnt = sum(list(map(int,[on[k] for k in range(n) if k+1 in s[j]])))
        
        if cnt % 2 == p[j]:
            cond += 1

    if cond == m:
        ans += 1

print(ans)

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

struct st {
	int a, b, c;
};
int main() {
	int n, m, a;
	while (cin >> n >> m >> a, n) {
		vector<st>v;
		rep(i, m) {
			int h, p, q; cin >> h >> p >> q;
			v.push_back({ h,p,q });
		}
		sort(v.begin(), v.end(), [](st a, st b) {return a.a > b.a; });
		int pos = a;
		for (st i : v) {
			if (i.b == pos)pos = i.c;
			else if (i.c == pos)pos = i.b;
		}
		cout << pos << endl;
	}
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

vector<ll> a; 

int main() {
  int N, M;
  ll cnt=0, tmp, b, c;
  cin >> N >> M;
  
  rep(i, N){
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());

  vector<pair<ll, ll> > pairs(M);
  rep(i, M){
    cin >> pairs[i].second >> pairs[i].first;
  }
  sort(pairs.begin(), pairs.end());

  int j = a.size()-1;
  int k = pairs.size()-1;
  ll sum = 0;
  while(cnt != N){
    cnt++;
    if(a[j] > pairs[k].first){
      sum += a[j];
      j--;
    } else {
      sum += pairs[k].first;
      pairs[k].second--;
      if(pairs[k].second == 0) k--;
    }
  }

 
  cout << sum << endl;

}


Measured memory_bytes: 2676
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;
    int start = max(a, c);
    int end = min(b, d);
    if(end <= start)
        ans = 0;
    else if(end > start)
        ans = end-start;
    cout << ans << endl;
    return 0;
}

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

class Dice {
public:
    int face[6];

    Dice(int face1, int face2, int face3, int face4, int  face5, int face6) {
        face[0] = face1;
        face[1] = face2;
        face[2] = face3;
        face[3] = face4;
        face[4] = face5;
        face[5] = face6;
    }

    int top() {
        return face[0];
    }
    int front() {
        return face[1];
    }
    int right() {
        return face[2];
    }

    void move(char c) {
        if (c == 'N') {
            moveFace(1, 2, 6, 5);
        } else if (c == 'S') {
            moveFace(1, 5, 6, 2);
        } else if (c == 'W') {
            moveFace(1, 3, 6, 4);
        } else if (c == 'E') {
            moveFace(1, 4, 6, 3);
        }
    }

    void moveFace(int i1, int i2, int i3, int i4) {
        int tmp = face[i1 - 1];
        face[i1 - 1] = face[i2 - 1];
        face[i2 - 1] = face[i3 - 1];
        face[i3 - 1] = face[i4 - 1];
        face[i4 - 1] = tmp;
    }

    int getRight(int top2, int front2) {
        for (int i = 0; i < 4; i++) {
            move('N');
            for (int j = 0; j < 4; j++) {
                move('W');
                for (int k = 0; k < 4; k++) {
                    move('N');
                    if (top() == top2 && front() == front2) {
                        return right();
                    }
                }
            }
        }

        return 0;
    }
};

int main() {
    int face1, face2, face3, face4, face5, face6;
    cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;
    Dice d(face1, face2, face3, face4, face5, face6);
    int count;
    cin >> count;

    for (int i = 0; i < count; i++) {
        int top, front;
        cin >> top >> front;

        cout << d.getRight(top, front) << endl;
    }
}

Measured memory_bytes: 1160
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 2020, mod = 1000000007;
int a[maxn];

int main() {
	int n = input(), k = input();
	for(int i = 1; i <= n; i ++)
		a[i] = input();

	lolong ans = 0;
	for(int i = 1; i <= n; i ++) {
		int tot = 0, s = 0;
		for(int j = i + 1; j <= n; j ++)
			if(a[j] < a[i])
				tot ++;
		for(int j = 1; j <= n; j ++)
			if(a[j] < a[i])
				s ++;
		ans += 1ll * tot * k % mod + (1ll * k * (k - 1) >> 1) % mod * s % mod;
	}

	printf("%lld\n", ans % mod);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;

char arr[N][N];
char arr1[N][N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);

    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);


    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }

            }
            if(cnt==(m*m))
            {
                printf("Yes\n");
                return 0;
            }

        }
    }
    printf("No\n");

}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a); i < (b); ++i)

int main()
{
    ll N, M;
    cin >> N >> M;
    if(M < 2*N) { //cが足りないとき
        cout << M/2 << endl;
        return 0;
    }

    cout << N + (M - 2*N)/4 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, K := ReadInt(), ReadInt()
	p := ReadInts(N)
	sort.Ints(p)
	ans := 0
	for i := 0; i < K; i++ {
		ans += p[i]
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a;
    rep(i,5){
        cin>>a;
        if(a==0)cout<<i+1<<endl;
    }
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
char c;
int main()
{
  cin >> c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" << "\n";
  }
  else{
    cout << "consonant" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
//解説AC
#include <iostream>
using namespace std;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  if (w / 2 < a || h / 2 < b) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x = 0, y = 0;
      if (i < b) {
        y = 1;
      }
      if (j < a) {
        x = 1;
      }
      cout << (x ^ y);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
S = input()

alphabets=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for alphabet in alphabets:
    flag = 1
    for character in S:
        if character == alphabet:
            flag = 0
    if alphabet == "z" and flag == 0:
        print("None")
    elif flag == 1:
        print(alphabet)
        break


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
    ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll a,v,b,w,t;
    bool flag=false;
    cin >> a >> v >> b >> w >> t;
    if (a<b){
        for (ll i=0;i<t;i++){
            a+=v;
            b+=w;
            if (a>=b){
                flag=true;
            }
        }
    }else{
        for (ll i=0;i<t;i++){
            a-=v;
            b-=w;
            if (a<=b){
                flag=true;
            }
        }
    }
    if (flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
int main(){
    int n,x,count;
    
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0 && x==0) break;
        
        count=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(x==i+j+k) count++;
                    }
            }
        }
        
    printf("%d\n",count);    
    }
    return 0;
}


Measured memory_bytes: 2104
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=100005;

int n,a[N];
int cnt[N];

int main(){
  int ans=0,tot=0;
  scanf("%d",&n);
  for (int i=1;i<=n;i++)
    scanf("%d",a+i),cnt[a[i]]++;
  for (int i=1;i<=100000;i++)
    if (cnt[i]){
      ans++;
      if (cnt[i]>3)
	cnt[i]=cnt[i]&1?1:2;
      if (cnt[i]==2)
	tot++;
    }
  if (tot&1)
    printf("%d\n",ans-1);
  else
    printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 896
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



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

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

	int n, m;
	cin >> n >> m;
	if (n != 1 && m != 1) {
		cout << (n - 2)*(m - 2);
	}
	ei(n==1&&m==1) {
		cout << 1;
	}ei((n == 1 && m == 2) || (n == 2 && m == 1)) {
		cout << 2;
	}
	else {
		if (n == 1) {
			cout << m - 2;
		}
		else {
			cout << n - 2;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int cnt=0,k,n;
	cin>>n>>k;
	vector<int> x;
	for(int i=0;i!=n;++i){
		int temp;
		cin>>temp;
		x.push_back(temp);
	}
	int ans=0;
	while(cnt<n){
		if(ans==0)
			cnt+=k;
		else
			cnt+=k-1;
		++ans;
	}
	cout<<ans;
}




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

using namespace std;

#define ff first
#define ss second
#define mp make_pair
#define sz size()
#define pb push_back

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

int main() {

  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int R[n];
  for(int i=0;i<n;i++){
    cin>>R[i];
  }
  int count=0,copy;
  for (int i=0;i<n;i++){
    int minA=i;
    for(int j=i;j<n;j++){
      if(R[j]<R[minA]){
        minA=j;
      }
    }
    if(i!=minA){
      copy=R[i];
      R[i]=R[minA];
      R[minA]=copy;
      count++;
    }
  }
  for(int i=0;i<n;i++){
    if(i==n-1){
        cout<<R[i]<<endl<<count<<endl;
    }else{
        cout<<R[i]<<" ";
    }
  }
  return 0;
}



Measured memory_bytes: 3088
// バケット法
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};
    for (int i = 0; i < N; ++i){
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; ++i){
        if (num[i]){
            ++res;
        }
    }
    cout<< res << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
res=[0]*4
for i in range(n):
  s=input()
  if s=='AC':
    res[0]+=1
  elif s=='WA':
    res[1]+=1
  elif s=='TLE':
    res[2]+=1
  elif s=='RE':
    res[3]+=1
print(f'AC x {str(res[0])}')
print(f'WA x {str(res[1])}')
print(f'TLE x {str(res[2])}')
print(f'RE x {str(res[3])}')

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

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

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

int main() {
    string S;
    cin >> S;

    bool ok = false;
    for (int i=0; i<S.size(); i++) {
        for (int j=0; j<S.size()-i; j++) {
            if (S.substr(0, i) + S.substr(i+j) == "keyence") ok = true;
        }
    }

    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = 50;
        long k = long.Parse(Console.ReadLine());
        var plus = k / n;
        var rem = k % n;
        var a = Enumerable.Repeat(n - 1 + plus, n).ToArray();
        for (int t = 0; t < rem; t++)
        {
            var min = a.Min();
            var minIndex = Array.IndexOf(a, min);
            a[minIndex] += n;
            for (int i = 0; i < n; i++)
            {
                if (i != minIndex)
                {
                    a[i]--;
                }
            }
        }
        Console.WriteLine(n);
        Console.WriteLine(String.Join(" ", a));
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<math.h>

typedef struct{
	double x;
	double y;
}Point;

void koch(int n,Point a,Point b){
	if(n!=0){
		Point s,t,u;
		double th=M_PI*60.0/180.0;
		
		s.x=(2.0*a.x+1.0*b.x)/3.0;
		s.y=(2.0*a.y+1.0*b.y)/3.0;
		t.x=(1.0*a.x+2.0*b.x)/3.0;
		t.y=(1.0*a.y+2.0*b.y)/3.0;
		u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
		u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
		
		koch(n-1,a,s);
		printf("%.8f %.8f\n",s.x,s.y);
		koch(n-1,s,u);
		printf("%.8f %.8f\n",u.x,u.y);
		koch(n-1,u,t);
		printf("%.8f %.8f\n",t.x,t.y);
		koch(n-1,t,b);
	}
}

int main(void){
	Point a,b;
	int n;
	
	scanf("%d",&n);
	
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	
	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(){

    long long  m;
    long long k,n;
    m=0;
    n=0;
    scanf("%lld",&k);
    if(k%2==0||k%5==0){
        n=-1;
        printf("%lld",n);
        return 0;
    }
    else
    {
    while(1){
        m=(m*10+7)%k;
        n+=1;
        if(m %k  ==0){

            printf("%lld",n);
            return 0;
        }
    }
    }
    /*return EXIT_SUCCESS;*/
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  a.insert(a.begin(), 0);
  rep(i, n) a[i+1] += a[i];

  ll ans = INF64;
  for(int i = 1; i < n; ++i) chmin(ans, abs(a[n]-2*a[i]));
  cout << ans << endl;
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3,y3,x4,y4;
    x4=x1-(y2-y1);
    y4=y1+(x2-x1);
    x3=x1+(x2-x1)+(x4-x1);
    y3=y1+(y2-y1)+(y4-y1);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    
}


Measured memory_bytes: 3624
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int a, b, t;
  std::cin >> a >> b >> t;
  int ans = t / a * b;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a-1)%2==0)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 判定条件を解説どおりに実装
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long d = scanner.nextLong();
			System.out.println(IntStream.range(0, n).filter(i -> {
				long x = scanner.nextLong(), y = scanner.nextLong();
				return (x * x + y * y) <= d * d;
			}).count());
		}
	}
}


Measured memory_bytes: 59968
#include <stdio.h>
#define N 2000
int solve(int,int);
int A[N];
int num;

int main(){
  int m,i,que,j;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&que);
    for(j=0;j<que;j++){
      scanf("%d",&m);
      if(solve(0,m)==1)printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0) return 1;
  if(i >= num) return 0;
   res = solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}



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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
 //   freopen("input.txt","r",stdin);
    FastIO;

    int n,m;

    while(cin>>n>>m){
        int a[m] , b[m] , unlocks[m];
        for(int i=0; i<m; i++){
            cin>>a[i]>>b[i];
            unlocks[i] = 0;
            for(int j=0; j<b[i]; j++){
                int x;
                cin>>x;
                unlocks[i] |= 1<<(x-1);
            }
        }
        int M = 1<<n;
        lli dp[M];
        dp[0] = 0;
        for(int i=1; i<M; i++) dp[i] = 1e18;
        for(int mask=0; mask<M; mask++){

            for(int i=0; i<m; i++){

                dp[mask|unlocks[i]] = min(dp[mask]+a[i] , dp[mask|unlocks[i]]);
            }
        }
        if(dp[M-1] == 1e18) dp[M-1] = -1;
        cout<<dp[M-1]<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256