akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const double PI=3.14159265359;
const int N_MAX=1000000;
//modの掛け算
ll mul(ll x, ll y){
	return (x%mod)*(y%mod)%mod;
}

int main(){
	ll n, k, k2;
	cin>>n>>k;
	ll bit[100000];
	ll bit2[200000];
	REP(i,n){
		cin>>bit[i];
	}
	REP(i,n*2){
		if(i<n){
			bit2[i]=bit[i];
		}else {
			bit2[i]=bit[i-n];
		}
	}
	ll cnt1=0, cnt2=0;
	FOR(i,0,n){
		FOR(j,i+1,n){
			if(bit[i]>bit[j])cnt1++;
			else if(bit[i]<bit[j])cnt2++;
		}
	}

	if(k%2==0)k2 = (k/2 * (k-1))%mod;
	else k2 = ((k-1)/2 * k)%mod;
	ll ans = ((mul(cnt1,k))%mod + (mul(k2,cnt1))%mod)%mod;
	ll ans2 = mul(k2,cnt2)%mod;

	cout<<(ans+ans2)%mod<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;

  if(N%2 == 0){ //偶数の時
  	if((N/2)+1>K){
  		cout<<"YES"<<endl;
  	}
  	else cout<<"NO"<<endl;
  }

  else{  //奇数の時
  	if((N/2)+1>=K){
  		cout<<"YES"<<endl;
  	}
  	else cout<<"NO"<<endl;
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <set>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B, C;
set<int> T;

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

  cin >> A >> B>> C;
  T.insert(A);
  T.insert(B);
  T.insert(C);
  string ans = T.size() == 2?"Yes":"No";
  cout << ans<< "\n";
  return 0;
}

Measured memory_bytes: 256
def dfs(s, mx):#sに対して、sと同じかsの一つ辞書順で後の文字列を追加する関数
    if len(s) == n:
        print(s)
        return
    for c in range(ord("a"), mx + 1):#
        dfs(s + chr(c), mx + 1 if c == mx else mx)#再帰的に一つ追加する

n = int(input())
dfs("", ord("a"))

Measured memory_bytes: 56920
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=m;++i){
		for(int j=0;j<=n;++j){
			if(n*i+m*j-2*i*j==k){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}
	cout<<"No"<<endl;
}

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


Measured memory_bytes: 256
# abc070d: Transit Tree Path

n = int(input())

T = [[] for _ in range(n)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    v1,v2 = v1-1,v2-1
    T[v1].append([v1,v2,d])
    T[v2].append([v2,v1,d])

q,k = map(int, input().split())

visit = [False]*(n)
depth = [0]*(n)
stack = [[-1,k-1,0]]
while stack:
    p,c,d = stack.pop()
    if visit[c]: continue
    visit[c] = True
    depth[c] = d
    if p>=0: depth[c] += depth[p]
    for pp,cc,dd in T[c]:
        if not visit[cc]: stack.append([pp,cc,dd])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1-1]+depth[v2-1])

Measured memory_bytes: 52924
# 基本的に問題はここで解く。

num = gets.chomp
num_sum = num.split("").map{|x| x.to_i}
num = num.to_i

sum = 0

(num_sum.length).times do |i|
    sum += num_sum[i]
end

if (num % sum) == 0
    puts "Yes"
else
    puts "No"
end



Measured memory_bytes: 2044
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
 
 
n = int(input())
 
p = primes(55555)
ans = [v for v in p if v % 5 == 1]
print(*ans[:n])

Measured memory_bytes: 9752
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
#define int ll
const int MOD = 1000000007;

int bit[200005]; int N;

void upd(int x, int v) { x++; while(x <= N) { bit[x] += v; x += (-x&(x)); } }
int get(int x) { x++; int ans = 0; while(x) { ans += bit[x]; x -= (-x&(x)); } return ans; }

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	int dia, A; cin >> N >> dia >> A;
	vector<pii> v;
	rep(i, N) {
		int loc, ne; cin >> loc >> ne;
		ne = (ne + A - 1) / A;
		v.pb({loc, ne});
	}
	sort(all(v));
	int ans = 0;
	rep(i, N) {
		if(get(i) >= v[i].se) continue;
		// bin search for last index <= than v[i].fi+2*dia
		int targ = v[i].fi+2*dia;
		int lef = i, rig = N-1, ban = i;
		while(lef <= rig) {
			int mid = (lef+rig)/2;
			if(v[mid].fi > targ) rig = mid-1;
			else { lef = mid+1; ban = mid; }
		}
		int dt = v[i].se-get(i);
		ans += dt;
		upd(i, dt); upd(ban+1, -dt);
	}
	cout << ans << endl;	
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int a, d, n;
  vector<int> f(1000000 + 1, 0);
  for(int i = 2; i <= sqrt(1000000); i++){
    if(f[i] == 0){
      for(int j = 2 * i; j <= 1000000; j+=i){
        f[j] = 1;
      }
    }
  }
  while(cin >> a >> d >> n, a||d||n){
    int cnt = 0, ans;
    for(int i = a;; i+=d){
      if(i != 1 && f[i] == 0)cnt++;
      if(cnt == n){
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 6532
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    int64_t a, b;
    cin >> a >> b;
    auto c = a -  2 * b;
    if (c <= 0) c= 0;
    cout << c << endl;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K;
    R(N,K);
    if(K%2){
        LL v=N/K;
        W(v*v*v);
    }
    else{
        LL v=N/K;
        LL an=v*v*v;
        v=0;
        FOR(i,1,N){
            if(i%K==K/2)v++;
        }
        an+=v*v*v;
        W(an);
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b; cin >> a >> b;

	if (a == b) {
		cout << 1 << endl;
		return 0;
	}
	else {
		if (a > b) swap(a, b);
		if ((a + b) % 2 == 0) {
			cout << (a + b) / 2;
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	return 0;
}
/*

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int k, n, c, sum = 0;
  cin >> n >> k;
  c = n - k;
  vi v(n);
  rep(i, n) {
    cin >> v[i];
    sum += v[i];
  }
  sort(v.begin(), v.end());
  rep(i, c) sum -= v[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 210

ll dp[SIZE][SIZE][1<<10]; //現, 上, 履歴

int main(){
  int N, K, M;
  bool t[2][SIZE];

  cin >> N >> K >> M;

  dp[0][0][0] = 1;

  int mask = (1 << K) - 1;

  for (int i=0; i<=N*2; i++) {
    for (int u=0; u<=i && u<=N; u++) {
      for (int r=0; r<(1<<K); r++) {
        if (!dp[i][u][r]) continue;

        int d = i - u;

        t[0][d] = false;
        t[1][u] = false;
        if (u > 0) t[0][u-1] = false;
        if (d > 0) t[1][d-1] = false;

        int tmpU = u, tmpD = d;

        for (int j=0; j<K && j<i; j++) {
          if (r & (1<<j)) {
            tmpU--;
            t[0][tmpU] = true;
          } else {
            tmpD--;
            t[1][tmpD] = true;
          }
        }

        //上
        if (u < N && (u == 0 || t[0][u-1])) {
          dp[i+1][u+1][((r << 1)&mask) + 1] += dp[i][u][r];
          dp[i+1][u+1][((r << 1)&mask) + 1] %= M;
        }

        //下
        if (d < N && d < u && t[0][d] && (d == 0 || t[1][d-1])) {
          dp[i+1][u][((r << 1)&mask) + 0] += dp[i][u][r];
          dp[i+1][u][((r << 1)&mask) + 0] %= M;
        }
      }
    }
  }

  ll ans = 0;

  for (int i=0; i<(1<<K); i++) {
    ans += dp[N*2][N][i];
  }

  cout << ans % M << endl;

  return 0;
}



Measured memory_bytes: 30892
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#define fr(a) freopen(a,"r",stdin)
#define fw(a) freopen(a,"w",stdout)
#define reset(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define ins insert
#define mp make_pair
#define fi first
#define se second
#define bug(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double lf;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
map<ll,ll> numprime;
ll n,t,Ti=1;
vll prime;
bool mark[1001]={0};
int main(){
    for(int i=2;i<=1000;i++){
        if(!mark[i]){
            prime.pb(i);
            for(int j=i*i;j<=1000;j+=i) mark[j]=1;
        }
    }
    cin>>n;
    for(ll i=2;i<=n;i++){
        t=i;
        for(int j=0;j<prime.size()&&prime[j]<=t;j++){
            while(t%prime[j]==0){
                t/=prime[j];
                numprime[prime[j]]++;
            }
        }
    }
    map<ll,ll>::iterator itr;
    for(itr=numprime.begin();itr!=numprime.end();itr++){
        Ti*=(itr->second+1)%1000000007;
        Ti%=1000000007;
    }
    cout<<Ti<<endl;
    return 0;
}





Measured memory_bytes: 256
using System;

namespace ITP1_5_C
{
    class Program
    {
        static void Main()
        {
            for (; ; )
            {
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);
                int W = int.Parse(str[1]);

                if (H == 0 && W == 0) break;

                    for (int i = 0; i < H; i++)
                    {
                        for (int j = 0; j < W; j++)
                        {
                            if((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) Console.Write("#");

                            else Console.Write(".");
                        }

                        Console.WriteLine();
                    }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8920
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N, K;
	cin >> N >> K;
	int ans = 0;

	rep(i, N) {
		int h;
		cin >> h;
		if (h >= K) {
			ans++;
		}
	}
	
	cout << ans << endl;

}


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

int main(){
	int num;
	int height[10];
	for(int i=0;i<=9;i++)
		cin>>height[i];

	for(int i=0;i<=9;i++){
		for(int j=i+1;j<=9;j++){
			if(height[i]<=height[j]){
				num=height[i];
				height[i]=height[j];
				height[j]=num;
			}
		}
	}
	for(int i=0;i<=2;i++)
		cout<<height[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

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

	if(a+b==c){
		printf("Yes\n");
	}else if(b+c==a){
		printf("Yes\n");
	}else if(c+a==b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N;
ll s[200001],ans = 0;

void solve(){
	
	sort(s,s + N + 1);
	int i = 0;
	while(i <= N){
		int j = i + 1;
		while(j <= N && s[j] == s[j - 1]) ++j;
		ans += (ll)(j - i) * (j - i - 1) / 2;
		i = j;
	}
	cout<<ans<<endl;
	
	return;
}

void input(){
	
	cin>>N;
	s[0] = 0;
	rep(i,N){
		int a; cin>>a;
		s[i + 1] = s[i] + a;
	}
	
	return;
}

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





Measured memory_bytes: 1792
import Control.Applicative ((<$>))
import Data.List (sort, group)

solve :: [[Int]] -> Int
solve [] = 0
solve (xs:xxs)
  | length xs > head xs = length xs - head xs + solve xxs
  | length xs < head xs = length xs + solve xxs
  | length xs == head xs = solve xxs

main = do
  n <- read <$> getLine :: IO Int
  a <- words <$> getLine :: IO [String]
  putStrLn . show . solve . group . sort $ fmap (read :: String -> Int) a


Measured memory_bytes: 39804
#include<stdio.h>
#include<string.h>
#include<math.h>

//dp[i] = min cost incurred going from stone i to stone n
int dp[100005], h[100005], n;

int min(int x, int y)
{
    return((x < y) ? x : y);
}

int solve(int i)
{
    if(dp[i] != -1)
        return(dp[i]);
    if(i == n)
        return(dp[i] = 0);
    if(i == n-1)
        return(dp[i] = abs(h[n-1] - h[n-2]));
    return(dp[i] = min(abs(h[i]-h[i-1]) + solve(i+1), abs(h[i+1]-h[i-1]) + solve(i+2)));
}

int main()
{
    scanf("%d", &n);
    memset(dp,-1,(n+2)*sizeof(int));
    for(int i=0;i<n;i++)
    {
        scanf("%d", &h[i]);
    }
    int min = solve(1);
    printf("%d\n", min);
    return(0);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n, p[8], q[8];
bool dff() {
	for (int i = 0; i < n; ++i)
		if (p[i] != q[i]) return true;
	return false;
}
bool sml() {
	for (int i = 0; i < n; ++i) {
		if (p[i] < q[i]) return true;
		if (p[i] > q[i]) return false;
	}
	return true;
}
int main() {
	cin >> n; for (int i = 0; i < n; ++i) cin >> p[i];
	for (int i = 0; i < n; ++i) cin >> q[i];
	if (!dff()) { cout << 0 << endl; return 0; }
	if (!sml()) {
		for (int i = 0; i < n; ++i) swap(p[i], q[i]);
	}
	int k = 0;
	while (dff()) {
		++k;
		next_permutation(p, p + n);
	}
	cout << k << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        
        while(true){
            
            String str=sc.next();
            
            if(str.equals("-")) break;
        
            int m=sc.nextInt();
        
            for(int i=0;i<m;i++){
            int a=sc.nextInt();
            String str1=str.substring(0,a);
            String str2=str.substring(a);
            str=str2+str1;

            }
            System.out.println(str);
            
        }
        
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  if(s[1]=='R')cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<climits>
#define ll long long 
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    pair<ll,ll> arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i].first>>arr[i].second;
    }
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<=w;i++)
    {
        dp[0][i]=0;
    }
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(arr[i-1].first<=j)
            {
                dp[i][j]=max(dp[i-1][j],arr[i-1].second+dp[i-1][j-arr[i-1].first]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 82460
class Multiset:
    def __init__(self, N):
        self.N = N
        self.tree = [0] * (N + 1)
        self.bisect_K = [1 << k for k in reversed(range(N.bit_length()))]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.N:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        if w <= 0:
            return 0
        bit, N = self.tree, self.N
        i = 0
        for k in self.bisect_K:
            ni = i + k
            if ni <= N and bit[ni] < w:
                w -= bit[ni]
                i = ni
        return i + 1

    def insert(self, x):
        self.add(x, 1)

    def erase(self, x):
        self.add(x, -1)

    def lower_bound(self, x):
        return self.bisect(self.sum(x))

    def size(self):
        return self.sum(self.N)


def main():

    # https://atcoder.jp/contests/abc134/tasks/abc134_e

    N, *A = map(int, open(0).read().split())

    memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
    M = len(memo)

    ms = Multiset(M)
    for b in (memo[a] for a in A):
        i = ms.lower_bound(b - 1)
        if i != 0:
            ms.erase(i)
        ms.insert(b)

    print(ms.size())


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    double ave=(double)sum/n;
    int ans=-1;
    int m=-1;
    for(int i=0;i<n;i++){
        if(abs(m-ave)>abs(a[i]-ave)){
            m=a[i];
            ans=i;
        }
    }
    cout << ans << endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(int N,vi& a) {
    // cerr << a << endl;
    if (a[0] != 0) return -1;
    ll ans = 0;
    // a[0] = 0
    for (int i=0,last=0; i<N; ++i) {
        // fprintf(stderr, "i=%d, last=%d; a[%d]=%d, ans=%lld\n", i,last, i,a[i], ans);
        if (a[i] == 0) {
            // last = a[i];
            // continue;
        }
        else if (a[i] == last+1) {
            // ++last;
            // last = a[i];
            ++ans; // this
        }
        else if (a[i] > last+1) {
            return -1;
        }
        else if (a[i] <= last) {
            // 1...(this-1)
            // last = a[i];
            ans += a[i];
        }
        last = a[i];
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vi a(N);
    rep(i,N) cin >> a[i];
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 1024
#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;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 
 
const ll N = 5005;
const ll mod = 998244353;
const long long int inf = 1e9;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main(){
    ll n,k,s;
    cin>>n>>k>>s;
    ll a[n];
    rep(i,k) a[i] = s;
    if(s==inf){
        for(ll i = k;i<n;i++) a[i] = 1;
    }
    else for(ll i = k;i<n;i++) a[i] = inf;
    rep(i,n) cout<<a[i]<<" ";
    cout<<endl;


}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 2048
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int num=int.Parse(Console.ReadLine());
    string S=Console.ReadLine();
      string sl1=S.Substring(0,1);
      int ans=num;
      for(int i=1;i<S.Length;i++){
        if(S.Substring(i,1)==S.Substring(i-1,1)){
         ans-=1;
        }
      }
    Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,k;
	sd(n);sd(k);
	ll ans=n/k;
	ans*=ans;
	ans*=int(n/k);
	if(k%2==0){
		int x=k/2;
		int temp=n/x;
		temp++;
		temp/=2;
		ll ans2=temp;
		ans2*=temp;
		ans2*=temp;
		ans+=ans2;
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 256
s=input()
s_2=[1 if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T" else 0 for i in range(len(s))]
s_3=0
for j in range(len(s)):
    s_3+=s_2[j]*(10**j)
s_3=str(s_3)
ans=0
for k in range(len(s)+1):
    if "1"*k in s_3:
        ans=k
print(ans)

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int xdiff = tx - sx;
	int ydiff = ty - sy;
	rep(i, ydiff) cout << 'U';
	rep(i, xdiff) cout << 'R';
	rep(i, ydiff) cout << 'D';
	rep(i, xdiff) cout << 'L';
	cout << 'L';
	rep(i, ydiff+1) cout << 'U';
	rep(i, xdiff+1) cout << 'R';
	cout << 'D';
	cout << 'R';
	rep(i, ydiff+1) cout << 'D';
	rep(i, xdiff+1) cout << 'L';
	cout << 'U';
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define swap(a,b) a^=b^=a^=b 
#define inf 1000000007

int main(void) {
	// your code goes here
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=(b-a)*(b-a+1)/2-b;
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define LOG1(x1,x2) cout << x1 << ": " << x2 << endl;
#define LOG2(x1,x2,y1,y2) cout << x1 << ": " << x2 << " , " << y1 << ": " << y2 << endl;
#define LOG3(x1,x2,y1,y2,z1,z2) cout << x1 << ": " << x2 << " , " << y1 << ": " << y2 << " , " << z1 << ": " << z2 << endl;
typedef long long ll;
typedef double db;
const int N = 2*1e5+100;
const int M = 1e5+100;
const db EPS = 1e-9;
using namespace std;

ll n,k,a[N],vis[N],cnt,pos;
//vis[i]: 位置i第一次出现在队首的位置
pair<ll,ll> mp[N]; //记录每一个pos的下一个pos, 以及中间跨越的步数
vector<ll> v[N],ans;

int main()
{
	scanf("%lld%lld",&n,&k);
	memset(vis,-1,sizeof vis);
	rep(i,0,n-1){
		scanf("%lld",&a[i]);
		v[a[i]].push_back(i);
	}
	rep(i,1,((int)2*1e5)){
		if(!v[i].size()) continue;
		int len = v[i].size();
		rep(j,0,len-1){
			if(j != len-1){
				mp[v[i][j]].first = (v[i][j+1]+1)%n;
				mp[v[i][j]].second = v[i][j+1]+1-v[i][j];
			}
			else{
				mp[v[i][j]].first = (v[i][0]+1)%n;
				mp[v[i][j]].second = n-v[i][j]+v[i][0]+1;	
			}
		}
	}
	cnt = 0; pos = 0;
	ll total = n*k-1ll;
	while(cnt+mp[pos].second <= total){
		// LOG1("cnt",cnt);
		if(vis[pos] != -1){
			ll K = cnt-vis[pos];
			ll hp = (n*k-vis[pos])%K;
			if(hp == 1ll){
				printf("\n");
				return 0;
			}
			if(hp == 0) hp = K-1ll;
			else hp--;
			total = vis[pos]+hp;
			cnt = vis[pos];
			// LOG1("vis[pos]",vis[pos])
			// LOG3("K",K,"hp",hp,"total",total);
			break;
		}
		else vis[pos] = cnt;
		cnt += mp[pos].second;
		pos = mp[pos].first;
	}
	// LOG1("total",total);
	if(total == cnt+mp[pos].second-1ll){
		printf("\n");
		return 0;
	}
	while(cnt <= total){
		while(cnt+mp[pos].second <= total){
			cnt += mp[pos].second;
			pos = mp[pos].first;
		}
		if(cnt+mp[pos].second-1ll == total) break;
		else{
			ans.push_back(a[pos]);
			pos = (pos+1ll)%n;
			cnt++;
		}
	}
	int len = ans.size();
	// LOG1("len",len);
	if(len == 0) printf("\n");
	else{
		rep(i,0,len-1){
			printf("%lld",ans[i]);
			if(i != len-1) printf(" ");
			else printf("\n");
		}
	}
	return 0;
}

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

int main(){

	int A, B, K;
	cin >> A >> B >> K;
	for(int i = A; i <= min(B, A + K-1); i++)
	{
		cout << i << endl;
	}
	for(int i = max(A+K, B - K+1); i <= B; i++)
	{
		cout << i << endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
var n,k,w = new Array(100000);


function judge(p){
    i = 0;
    for(var j = 0;j < k;j++){
        var sum = 0;
        while(i < n && sum + w[i] <= p)
            sum += w[i++];
    }
    if(i == n)
        return true;
    else
        return false
}


function Main(input){
    input = input.split("\n");

    input[0] = input[0].split(" ");
    n = parseInt(input[0][0],10);
    k = parseInt(input[0][1],10);
    for(var i = 1;i <= n;i++){
        w[i - 1] = parseInt(input[i],10);
    }
    var max = 0;
    for(var i = 0;i < n;i++){
        if(max < w[i])
            max = w[i];
    }

    var left = 0;right = Math.floor(n / k) + 1;
    right *= max;

    while(right - left > 1){
        var mid = Math.floor((right + left) / 2);
        if(judge(mid))right = mid;
        else left = mid;
    }
    console.log(right);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 25416
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        else:
            nmap[v1] += 1
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 20492
#include<iostream>
using namespace std;
int main ()
{
int s[31]={};
for(int i=0;i<28;i++)
{
int h;
cin>>h;
s[h]=1;
}
for(int i=1;i<31;i++)
{
if(s[i]==0)cout<<i<<endl;
}
return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	while (1) {
		int n, x;
		cin >> n >> x;

		if (!n && !x) return 0;

		int cnt = 0;
		for (int i = n; i > 0; --i) {
			for (int j = i - 1; j > 0; --j) {
				for (int k = j - 1; k > 0; --k) {
					if (i + j + k == x) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3096
#include <stdio.h>

int main()
{
   int N;
   
   scanf("%d",&N);

   int a[N];

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

   for(int i = 0;i<N;i++)
   {
       for(int j = N-1;j>0;j--)
       {
           if(a[j-1]>a[j])
           {
               int x = a[j];
               a[j] = a[j-1];
               a[j-1] = x;
           }
       }
   }

   printf("%d",a[N-1]-a[0]);

   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int c[]={1,5,10,50,100,500},i,s,sum;
	sum=0;
	for(i=0;i<6;i++){
		scanf("%d",&s);
		sum+=s*c[i];
	}
	if(sum<1000) printf("0\n");
	else printf("1\n");
	return 0;
}

Measured memory_bytes: 2608
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 10000000000

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	long long int N,M;
	cin>>N>>M;
	if(N>=2 && M>=2)
		cout<<(N-2)*(M-2)<<endl;
	else if(N==1 && M==1)
		cout<<1<<endl;
	else
		cout<<max(N,M)-2<<endl;
	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin>>n;
	vll nums(n);
	for(auto &it: nums) cin>>it;
	
	ll dp[n+1][2];
	
	dp[0][0] = 0;
	dp[0][1] = -INFLL;
	
	for(int i=1; i<=n; i++) {
		dp[i][0] = max(dp[i-1][0] + nums[i-1], dp[i-1][1] - nums[i-1]);
		dp[i][1] = max(dp[i-1][0] - nums[i-1], dp[i-1][1] + nums[i-1]);
	}
	
	cout<<dp[n][0]<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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

long long int a[3][100001];

int main() {
	int n = 0;
	cin >> n;
	vector<int> w(200);
	for (int i = 0; i < n; i++) {
		cin >> w.at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += w.at(i);
	}
	vector<int> z(n);
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		tmp += w.at(i);
		z.at(i) = abs(sum - 2 * tmp);
	}
	sort(z.begin(), z.end());
	cout << z.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;



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

	cout << (n-1) * (m-1) << endl;

	return 0;
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}
	sort(begin(a), end(a));

	ll mi = INT64_MAX;
	for (ll i = 0; i < n - 1; i++) {
		ll g = gcd(a[i], a[i + 1]);
		mi = min(mi, g);
	}

	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
#define x first
#define y second
int main(){
	int table[] = {1000,500,100};
	int n;
	while(cin >> n , n){
		set< set<P> > ret;
		vector< vector<P> > d(n,vector<P>(n));
		rep(i,n){
			rep(j,n){
				cin >> d[i][j].x >> d[i][j].y;
			}
		}
		rep(i,n)rep(j,n){
		
			P add = make_pair(i,j);
			
			set<P> lp;
			
			while(lp.find(add) == lp.end() ){
				lp.insert(add);
				add = d[add.y][add.x];
			}
			if(add == make_pair(i,j) )ret.insert(lp);
			
		}
		cout << ret.size() << endl;
		
	}
}

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

import sys
import os
import math
import itertools

d = {}
d['A'] = 0
d['B'] = 0
d['AB'] = 0
d['O'] = 0

s = input().strip()

apple_key = 'a)@#%^(@#)$&@'
peach_key = 'p#*$^(#$&#)(*'

s = s.replace('apple', apple_key)
s = s.replace('peach', peach_key)

s = s.replace(apple_key, 'peach')
s = s.replace(peach_key, 'apple')

print(s)

Measured memory_bytes: 7420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  if(n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  vector<int> d(n);
  for(int i = 0; i < n; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  int ans = d[n/2] - d[(n/2) - 1];
  cout << ans << endl;

}

Measured memory_bytes: 640
S, T=input(), input()
src, trg = {}, {}
for i in range(len(S)):
    s, t = S[i], T[i]
    if (s in src and src[s] != t) or (t in trg and trg[t] != s):
        print("No")
        exit()
    src[s] = t
    trg[t] = s
print("Yes")

Measured memory_bytes: 41932
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    int k;
    cin>>k;
    cin>>s;
    int len=s.length();
    if(len<=k)
        cout<<s<<endl;
    else
    {
        for(int j=0;j<k;j++)
            cout<<s[j];
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3624
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define mod 1e9 + 7
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define int64 long long int
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
bool cmp(int a, int b) {return a > b;}
#define MOD 1000000007


int main()
{
    fast

    string s;
    cin >> s;
    if (s[0] == 'R' and s[1] == 'R' and s[2] == 'R')
        cout << 3;
    else if (s[0] == 'R' and s[1] == 'R' or s[1] == 'R' and s[2] == 'R')
        cout << 2;
    else if (s[0] == 'R' or s[1] == 'R' or s[2] == 'R')
        cout << 1;
    else
        cout << 0; s[1] == 'R' and s[2] == 'R';

    return 0;
}

Measured memory_bytes: 3572
#define DEBUG 1
#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...); }
#if DEBUG
#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);
    std::string s; std::cin >> s;
    std::cout << std::string(s.length(),'x') << std::endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]
L, R, U, D = [[[0]*W for _ in range(H)] for i in range(4)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if S[h][W-1-w] == '.':
            R[h][-w-1] = R[h][-w]+1
        if S[H-1-h][w] == '.':
            D[-h-1][w] = D[-h][w]+1

ans = 0
for i in range(H):
    for j in range(W):
        light = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, light)

print(ans)


Measured memory_bytes: 183640
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

if K>N:
    K = N-1
    
dp = [0]*N
for i in range(1,K+1):
    dp[i] = abs(h[0]-h[i])
    
for i in range(K+1, N):
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, K+1)])
print(dp[-1])

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

int main() {
    char str[26];
    cin >> str;
    // int N = (int)str.size();
    int N = 26;
    int i, j;

    for(i=0; i<N; ++i) {
        for(j=0; j<N; ++j) {
            if(i==j) continue;
            if(str[i] == '\0') break;
            if(str[i] == str[j]) {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256