akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
        a[i] -= a[i - 1];
    }
    if (n % 2 == 0) {
        a[n - 2] -= 2 * a[n - 1];
        for (int i = n - 3; i >= 0; --i) {
            if (i % 2 == 0)
                a[i] -= a[n - 1];
            else
                a[i] += a[n - 1];
        }
    } else {
        a[n - 1] = a[n - 1] / 2;
        for (int i = n - 2; i >= 0; --i) {
            if (i % 2 == 0)
                a[i] -= a[n - 1];
            else
                a[i] += a[n - 1];
        }
    }
    cout << 2 * a[n - 1] << " ";
    for (int i = 0; i < n - 1; ++i) {
        cout << 2 * a[i];
        if (i == n - 2)
            cout << "\n";
        else
            cout << " ";
    }
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define Mx 2000001
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef long long  L;
typedef pair<L, L> pii;
L in,a,a1,a2,a3,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx,mn,flg,flg1,flg2,id1,id2,id3,id4,lim,tm1,st,en;
L A[101];
int main()
{
    memset(A,-1,sizeof(A));
    flg=0;
    scanf("%lld%lld",&n,&m);
    for(L i=0;i<m;i++){
        scanf("%lld%lld",&a1,&a2);
        if(flg)continue;
        if(A[a1]==-1){
            A[a1]=a2;
        }else if(A[a1]!=a2){
            flg=1;
        }
    }
    if(flg){
        printf("-1\n");return 0;
    }else if(n==1){
        if(A[1]==-1){
            printf("0\n");
        }else{
            printf("%lld\n",A[1]);
        }return 0;
    }
    for(L i=1;i<=n;i++){
        if(i==1){
            if(A[i]==-1){
                A[i]=1;
            }else if(A[i]==0){
                printf("-1\n");return 0;
            }
        }else{
            if(A[i]==-1)A[i]=0;
        }
        printf("%lld",A[i]);
    }
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
int n;
char c[100][15];
int p[100];
std::pair<long long, long long>a[100];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", c[i]);
		scanf("%d", p + i);
	}
	for (int i = 0; i < n; i++) {
		a[i].first = 0;
		a[i].second = 0;
		for (int j = 0; j < 6; j++) {
			if (c[i][j] - 'a' >= 0 && c[i][j] - 'z' <= 0) {
				a[i].first += c[i][j] - 'a' + 1;
			}
			a[i].first *= 30;
		}
		for (int j = 0; j < 4; j++) {
			if (c[i][j + 6] - 'a' >= 0 && c[i][j + 6] - 'z' <= 0) {
				a[i].second += c[i][j + 6] - 'a' + 1;
			}
			a[i].second *= 30;
		}
		a[i].second *= 4;
		a[i].second += 100-p[i];
		a[i].second *= 120;
		a[i].second += i;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		printf("%lld\n", a[i].second % 120 + 1);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cill(a);
    cill(b);
    cill(h);
    cill(m);
    double kakua = h * 30 + m * 0.5, kakub = m * 6, kaku;
    if (kakua>=kakub){
        kaku = kakua - kakub;
    }else{
        kaku = kakub - kakua;
    }
    if (kaku > 180){
        kaku = 360 - kaku;
    }
    double ans2 = (double)a * a + b * b - 2 * a * b * cos(PI * (kaku/180));
    double ans = sqrt(ans2);
    co(ans);
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    string s; cin>>s;
    if (s[0] != s[1] || s[1] != s[2]) {
        cout << "Yes\n";
    } else {
        cout <<"No\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las



main :: IO ()
main = do
  readTuple2 >>= (\(a, b) -> print $ a * b)





Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>

const int N = 4e5 + 1;

bool vis[N];
int fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320};
std::queue<std::pair<std::vector<int>, int>> q;

int get_rank(std::vector<int> &cur) {
  int rank = 0;
  for (int i = 0; i < 9; ++i) {
    int cnt = 0;
    for (int j = i + 1; j < 9; ++j) {
      if (cur[j] < cur[i]) cnt ++;
    }
    rank += cnt * fac[8 - i];
  }
  return rank;
}

void extend(std::vector<int> &cur, int pos, int step, int opr, int opc) {
  auto nxt = cur;
  int r = pos / 3;
  int c = pos % 3;
  int nr = r + opr;
  int nc = c + opc;
  if (nr >= 0 && nr < 3 && nc >= 0 && nc < 3) {
    int np = nr * 3 + nc;
    std::swap(nxt[pos], nxt[np]);
    int rank = get_rank(nxt);
    if (!vis[rank]) {
      q.push({nxt,  step + 1});
      vis[rank] = 1;
    }

  }
}

int main() {
  while (!q.empty()) q.pop();
  memset(vis, 0, sizeof(vis));
  std::vector<int> goal = {1, 2, 3, 4, 5, 6, 7, 8, 0};
  int target = get_rank(goal);
  std::vector<int> st(9);
  for (int i = 0; i < 9; ++i) std::cin >> st[i];
  q.push({st, 0});
  vis[get_rank(st)] = 1;
  while (!q.empty()) {
    auto cur = q.front();
    q.pop();
    auto p = cur.first;
    int step = cur.second;
    if (get_rank(p) == target) {
      std::cout << step << std::endl;
      return 0;
    }
    if (step + 1 > 45) continue;
    int pos;
    for (int i = 0; i < 9; ++i) {
      if (p[i] == 0) pos = i;
    }
    extend(p, pos, step, 0, 1);
    extend(p, pos, step, 0, -1);
    extend(p, pos, step, 1, 0);
    extend(p, pos, step, -1, 0);
  }
  return 0;
}



Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    sort(H.begin(), H.end(), greater<int>());

    long long sum=0;
    for (int i = K; i < N; i++) {
        sum += H[i];
    }

    cout << sum << endl;
}

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

const ll mod = 1e9 + 7;

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

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

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

    int n, k, s;
    cin >> n >> k >> s;
    rep(i, k) cout << s << " ";
    rep(i, n - k) cout << (s == 1e9 ? 1 : s + 1) << " ";
}

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

s = input()
k = int(input())
flag = 1
lenth = 1
ans = 0
flag2 = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        lenth += 1
    else :
        flag = 0
    if flag == 0:
       ans += lenth//2
       lenth = 1
       flag = 1
if lenth == len(s):
    print(lenth*k//2)
    flag2 = 4
ans += lenth//2
lenth = 1
flag = 1

ji = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        lenth += 1
    else :
        flag = 0
    if flag == 0:
       # print(lenth)
       if lenth%2 == 1:
            ji += 1
       break
if lenth%2 == 1 and flag ==1:
    ji += 1
lenth = 1
flag = 1
for i in range(len(s)-1):

    if s[len(s)-i-1] == s[len(s)-1-(i+1)]:
        lenth += 1
    else :
        flag = 0
    if flag == 0:
       # print(lenth)
       if lenth%2 == 1:
            ji += 1
       break
if lenth%2 == 1 and flag == 1:
    ji += 1
ans = ans*k
# print(ans, ji)
if flag2 == 0:
    if ji == 2 and s[0] == s[len(s)-1]:
        ans = ans+k-1
    if len(s) == 1:
        print(k//2)
    else:
        print(ans)



Measured memory_bytes: 3064
#!/usr/bin/python3
# -*- coding:utf-8 -*-

N, K = map(int, input().split())
sunukes = {n+1 for n in range(N)}
# print(sunukes)

for i in range(K):
    d_i = int(input())
    for n in map(int, input().split()):
        n in sunukes and sunukes.remove(n)

print(len(sunukes))


Measured memory_bytes: 9116
k, n = map(int, input().split())
a = list(map(int, input().split()))
dmax = k - (a[n - 1] - a[0])
for i in range(n - 1):
    if (a[i + 1] - a[i]) > dmax:
        dmax = a[i + 1] - a[i]
print(k - dmax)

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

using namespace std;

#define int long long

signed main(){
	int n,m; cin>>n>>m;
	int a[n][m];
	for(int i=0;i<n;i++)
	   for(int j = 0;j <m ;j++)
	      cin>>a[i][j];
	
	int res = 0;
	for(int i=0;i<n;i++){
		for(int j = i+1; j<n; j++){
			int pro = 0;
			for(int k = 0;k<m;k++){
				pro += (a[j][k] - a[i][k])*(a[j][k] - a[i][k]);
			}
			
			if(pro == (int)sqrt(pro)*sqrt(pro)) res++;
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    x, y, t = 0, 0, 0
    for i in range(int(input())):
        tt, tx, ty = map(int, input().split())
        m = abs(x - tx) + abs(y - ty)
        if m > (tt - t):
            print("No")
            return
        if (m - (tt - t)) % 2 == 1:
            print("No")
            return
        x, y, t = tx, ty, tt
    print("Yes")

if __name__=="__main__":
    solve()


Measured memory_bytes: 3060
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}


function Main(input){
    let s = input.trim();
    
    let l = s.length;
    let c = 0;
    for(let i=0;i<l;i++){
        if(s[i] == 'x') c++;
    }
    if(c >= 8){
        console.log('NO');
    }else{
        console.log('YES');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int X, Y;

pair<int, int> gcd_cnt(int x, int y){
    int cnt = 0;
    while(y > 0){
        cnt++;
        x %= y;
        swap(x, y);
    }
    return make_pair(x, cnt);
}

int main(){
    while(cin >> X >> Y){
        if(X == 0 && Y == 0){
            return 0;
        }
        if(X < Y){
            swap(X, Y);
        }
        pair<int, int> ret = gcd_cnt(X, Y);
        cout << ret.first << " " << ret.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, a, b, c;
  cin >> A >> B >> C;
  int X = max(A, B);
  int Y = max(B, C);
  int Z = max(X, Y);
  cout << A + B + C- Z << endl;
}


Measured memory_bytes: 3588
n=int(input())
s=input()

r=s.count("R")
g=s.count("G")
b=s.count("B")

tmp=r*g*b

for i in range(n):
    for dist in range(n):
        j=i+dist
        k=j+dist
        if k>=n: break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            tmp-=1

print(tmp)

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

const int maxn = 1e5+10;

int fa[maxn<<1], cnt[maxn<<1];
int find(int x) {
//	printf(" %d %d\n", x, fa[x]);
	return fa[x]>0?fa[x]=find(fa[x]):x;
}
bool merge(int x, int y) {
	int fx = find(x), fy = find(y);
	if (fx == fy) {
		if (cnt[fx] == 0) return false;
		cnt[fx]--;
	}
	else {
		if (cnt[fx]+cnt[fy] == 0) return false;
		if (fa[fx] < fa[fy]) swap(fx, fy);
		fa[fx] = fy;
		fa[fy]--;
		cnt[fy] = cnt[fy]+cnt[fx]-1;
	}
	return true;
}

int n, h, w;
pair<int, pair<int, int> > e[maxn];
long long ans = 0;
#define mp make_pair
#define fi first
#define se second

int main() {
	for (int i = 0; i < (maxn<<1); ++i) cnt[i] = 1;
	cin >> n >> h >> w;
	int r, c, a;
	for (int i = 0; i < n; ++i) {
		cin >> r >> c >> a;
		e[i] = mp(a, mp(r, c+h));
	}
	sort(e, e+n);
	reverse(e, e+n);
	for (int i = 0; i < n; ++i) {
		if (merge(e[i].se.fi, e[i].se.se))
			ans += e[i].fi;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int input_id;
	char name[4];
	int win;
	int lose;
} team_t;

int qsort_comp(const void* x,const void* y) {
	const team_t* a=(const team_t*)x;
	const team_t* b=(const team_t*)y;
	if((a->win)<(b->win))return 1;
	if((a->win)>(b->win))return -1;
	if((a->lose)>(b->lose))return 1;
	if((a->lose)<(b->lose))return -1;
	if((a->input_id)>(b->input_id))return 1;
	if((a->input_id)<(b->input_id))return -1;
	return 0;
}

int main(void) {
	int team_num;
	team_t teams[10];
	int seiseki;
	int i,j;
	while(1) {
		scanf("%d",&team_num);
		if(team_num==0)break;
		for(i=0;i<team_num;i++) {
			teams[i].input_id=i;
			scanf("%s",teams[i].name);
			teams[i].win=teams[i].lose=0;
			for(j=1;j<team_num;j++) {
				scanf("%d",&seiseki);
				if(seiseki==0)teams[i].win++;
				else if(seiseki==1)teams[i].lose++;
			}
		}
		qsort(teams,team_num,sizeof(team_t),qsort_comp);
		for(i=0;i<team_num;i++)puts(teams[i].name);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int abs(x){
	return (x>0)?x:(-x);
}
int main() {
	int h, w, d, q;
	int a;
	int x[100000] = {}, y[100000] = {};
	int dis[100000] = {};
	scanf("%d%d%d", &h, &w, &d);
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			scanf("%d", &a);
			x[a] = i;
			y[a] = j;
		}
	}
	scanf("%d", &q);
	for (int i = d + 1; i <= h*w; i++)
	{
		dis[i] = dis[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
	}
	int l, r;
	for (int i = 0; i < q; i++)
	{
		scanf("%d%d",&l, &r);
		printf("%d\n", dis[r] - dis[l]);
	}
	return 0;
}

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

const int INF = 1<<29;

int dp[10010];

int main() {
  int H,N;
  cin >> H >> N;
  vector<int> A(N); //体力
  vector<int> B(N); //魔力
  for(int i=0;i<N;++i) cin >> A[i] >> B[i];
  for(int i=0;i<=H;++i) dp[i] = INF;
  dp[0] = 0;
  for(int i=0;i<=H;++i){
    for(int j=0;j<N;++j){
      if(i-A[j]>=0) dp[i] = min(dp[i],dp[i-A[j]]+B[j]);
      else dp[i] = min(dp[i],B[j]);
    }
  }
  cout << dp[H] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    int a, b, c, temp, temp2 ;

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

    temp=a ;
    a=b ;
    b=temp ;

    temp=a ;
    a=c ;
    c=temp ;

    printf("%d %d %d", a, b, c) ;

    return 0;
}

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

int factorial(int n){
  int f = 1;
  for(int i = 2;i<=n;i++){
    f = f * i;
  }
  return f;
}


int main() {

  int N;
  cin >> N;
  int P[N];
  int Q[N];
  int a,b;
  a = 0;
  b = 0;
  int eg = 0;
  for(int i = 0; i<N;i++){
    cin >> P[i];
  }
  for(int i = 0; i<N;i++){
    cin >> Q[i];
  }
  if(P == Q){
    cout << 0 << endl;
  }
  for(int i = 0; i < N-1; i++){
    if(i != 0){
      for(int j = 0; j<i; j++){
        if(P[j] < P[i]){
          eg++;
        }
      }
    }else{
      eg = 1;
    }
    a += (P[i]-eg)*factorial(N-i-1);
    eg = 0;
  }
  for(int i = 0; i < N-1; i++){
    if(i != 0){
      for(int j = 0; j<i; j++){
        if(Q[j] < Q[i]){
          eg++;
        }
      }
    }else{
      eg = 1;
    }
    b += (Q[i]-eg)*factorial(N-i-1);
    eg = 0;
  }

  if(a-b >= 0){
    cout << a-b << endl;
  }else{
    cout << b-a << endl;
  }
  

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int changed[200005];

int main(void) {
    int N, K; cin >> N >> K;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }

    int ans = 1;
    set<int> s;
    for (int i = N-K; i < N; i++) {
        s.insert(P[i]);
    }
    for (int i = N-K-1; 0 <= i; i--) {
        s.erase(P[i+K]);
        s.insert(P[i]);
        auto itr = s.begin();
        if ((*itr) != P[i]) {
            changed[i] = 1;
        }
    }

    s.clear();
    int cnt = 1;
    int flag = 0;
    for (int i = 0; i < K; i++) {
        s.insert(P[i]);

        if (0 < i && P[i-1] < P[i]) {
            cnt++;
        } else {
            cnt = 1;
        }
        if (cnt >= K) {
            flag = 1;
        }
    }
    for (int i = K; i < N; i++) {
        if (0 < i && P[i-1] < P[i]) {
            cnt++;
        } else {
            cnt = 1;
        }
        s.erase(P[i-K]);
        s.insert(P[i]);
        auto itr = s.end();
        itr--;
        if ((*itr) != P[i]) {
            ans++;
        } else {
            if (changed[i-K] == 1 && (flag == 0 || cnt < K)) {
                ans++;
            }
        }
        if (cnt >= K) {
            flag = 1;
        }
    }
    cout << ans << endl;
}


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

int main(){
	int n, i, ac=0, wa=0, tle=0, re=0;
	scanf("%d", &n);
	char vet[n];
	for(i=0; i<n; ++i)
		scanf("%s", &vet[i]);

	for(i=0; i<n; ++i){
		if(vet[i]=='A')
			ac++;
		else if(vet[i]=='W')
			wa++;
		else if(vet[i]== 'T')
			tle++;
		else if(vet[i]== 'R')
			re++;
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 1828
def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

kosuu = int(input())
nums = list(map(int,input().split()))

L = []
R = []
for temp in range(kosuu-1):
    if temp == 0:
        L.append(nums[0])
    else:
        L.append(gcd(L[temp-1],nums[temp]))

for temp in range(kosuu-1):
    if temp == 0:
        R.append(nums[kosuu-1])
    else:
        R.append(gcd(R[temp-1],nums[len(nums)-temp-1]))

saidai=[]
for i in range(kosuu):
    if i == 0:
        saidai.append(L[-1])
    elif i == kosuu-1:
        saidai.append(R[-1])
    else:
        saidai.append(gcd(L[i-1],R[-1-i]))

print(max(saidai))

Measured memory_bytes: 14488
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    M1, D1 = list(map(int, input().split()))
    M2, D2 = list(map(int, input().split()))

    if M1 == M2:
        print(0)
    else:
        print(1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	
	int N;
	int L;
	int sum;


	cin >> N >> L;

	if (L<=0 && L+N-1>=0)
	{
		sum = (2 * L+N - 1)*N / 2;
	}
	else if (L<0 && L+N-1<0)
	{
		sum = (2 * L + N - 2)*(N-1) / 2;
	}
	else { sum = (2 * L + N)*(N-1)/2; }
	
	cout << sum << endl;
}


Measured memory_bytes: 256
// C - Walk on Multiplication Table
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = LLONG_MAX;
	for(ll a=1; a*a<=N; ++a){
		if(N%a) continue;
		ll b = N/a;
		ans = min(ans, a + b - 2);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N, K;
  cin >> N >> K;
  ll ans;
  ans = K * pow(K - 1, N - 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MAX 25

void preParse(int);
void inParse(int);
void postParse(int);

typedef struct node{int p,l,r;}Node;
Node T[MAX];
int n;

int main(){
  int i,l,r,p,root,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=-1) T[l].p=v;
    if(r!=-1) T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==-1) root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

void preParse(int u){
  if(u==-1) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==-1) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==-1) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

Measured memory_bytes: 616
import numpy as np
n=int(input())
alist=np.array(list(map(int,input().split())))
counter=0
flag=0
while flag==0:
  for a in alist:
    if a%2==1:
      flag=1
      break
  if flag==0:
    alist=alist/2
    counter=counter+1
print(counter)

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

int main(){
  int x,y;
  cin >> x >> y;
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if( a[x] == a[y] ) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  

Measured memory_bytes: 256
#!/usr/bin/python
#compat with both Py2/Py3
import sys
if sys.version_info[0]>=3: raw_input=input

def main(roman):
	m={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
	r=0
	for i in range(len(roman)):
		r+=m[roman[i]]*(1 if i==len(roman)-1 or m[roman[i]]>=m[roman[i+1]] else -1)
	print(str(r))

if __name__=='__main__':
	try:
		while True:
			main(raw_input().rstrip())
	except EOFError:
		pass

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

int main() {
  string s;
  cin >> s;
  string ans;
  if(s == "Sunny") ans = "Cloudy";
  else if(s == "Cloudy") ans = "Rainy";
  else ans = "Sunny";
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int x;
    int a, b;
    cin >> x >> a >> b;
    int ans = 0;
    for ( int i = 1; i <= x; ++i ) {
        int tempNum = i;
        int tempSum = 0;
        while (tempNum > 0) {
            tempSum += tempNum % 10;
            tempNum /= 10;
        }
        if (tempSum >= a && tempSum <= b ) {
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for _ in range(n)]
    cnt = 0
    for i in range(n-1):
        for j in range(i+1, n):
            dist = np.linalg.norm(np.array(x[i]) - np.array(x[j])).item()
            if dist.is_integer():
                cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 12280
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public void exec() throws IOException {
        Scanner input = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = input.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i=1; i<=n; i++){
        	if(i%3==0 || appearance3(i)) {
        		sb.append(" ").append(i);
        	}
        }
        out.println(sb.toString());
        out.flush();
        input.close();
    }
    
    private boolean appearance3(int num) {
    	for(;num>0; num/=10) {
    		if(num % 10 == 3) return true;
    	}
    	return false;
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }

}
 

Measured memory_bytes: 27464
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
#include<cassert>
using namespace std;

int main(void) {
	string s;
	long long int k, cnt = 0, ans = 0, front = 0, back = 0;
	cin >> s >> k;

	if (s.size() == 1) {
		cout << k / 2 << endl;
		return 0;
	}

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			for (i; (s[i] == s[i + 1]) && (i < s.size() - 1); i++) {
				cnt++;
			}
			cnt++;
			if (cnt == s.size()) {
				cout << cnt * k / 2 << endl;
				return 0;
			}
			ans += cnt / 2;
			cnt = 0;
		}
	}

	if (s[0] == s[s.size() - 1]) {
		for (int i = 0; s[i] == s[i + 1]; i++) {
			front++;
		}
		front++;

		for (int i = s.size() - 1; s[i] == s[i - 1]; i--) {
			back++;
		}
		back++;
		if (back % 2 == 1 && front % 2 == 1) {
			cout << (ans + 1) * k - 1 << endl;
			return 0;
		}
	}

	cout << ans * k << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;

int main() {
    int a, b;cin >>a>>b;
    int sum=0;

    for(int i=a;i<=b;i++){
        //cout<<i%10<< " "<<i/10000<<endl;
        int n = i;
        if((n%10)==(n/10000)){
            //cout<<i%10<< " "<<i/10000<<endl;
            if(((n-n%10)/10%10)==(n-n/10000*10000)/1000)
                sum++;
           // cout<<"ddd"<<(i-i%10)%10<< " "<<(i-i/10000*10000)/1000<<endl;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int x = A + B;
  int y = C + D;
  
  if ( x > y ) {
    cout << "Left" << endl;
  }
  else if ( x == y ){
    cout << "Balanced" << endl;
  }
  else 
    cout << "Right" << endl;
}
  

Measured memory_bytes: 3644
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

  int a, b, k;
  cin >> a >> b >> k;

  set<int> bag;
  int x;
  rep(i, k) {
    x = a + i;
    if (a <= x && x <= b) bag.insert(x);
    x = b + 1 - k + i;
    if (a <= x && x <= b) bag.insert(x);
  }

  for(auto x : bag) {
    cout << x << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(str,input().split()))
dp = [[-float("inf")] *4 for i in range(n+1)]
dp[0][0] = 0
for i in range(len(a)):
    b = i//2+1
    if a[i] == "-":
        tmp = [-float("inf"),0,0,0]
        for j in range(3):
            tmp[j+1] = dp[b][j]
        dp[b] = tmp
        continue
    elif a[i] == "+":
        continue
    for j in range(4):
        for k in range(3):
            if j >= k:
                dp[b][k] = max(dp[b][k],dp[b-1][j]+((-1)**j)*int(a[i]))
print(dp[n][0])
    

Measured memory_bytes: 107988
#include <algorithm> //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main()
{
  ll n;
  cin >> n;
  vector<tuple<int, int, int>> v;
  int t, x, y;
  v.push_back(make_tuple(0, 0, 0));
  for (int i = 0; i < n; i++)
  {
    cin >> t >> x >> y;
    v.push_back(make_tuple(t, x, y));
  }
  sort(v.begin(), v.end());

  int dt, dx, dy;
  bool ok = true;
  for (int i = 0; i < n; i++)
  {
    dt = get<0>(v[i + 1]) - get<0>(v[i]);
    dx = get<1>(v[i + 1]) - get<1>(v[i]);
    dy = get<2>(v[i + 1]) - get<2>(v[i]);

    ok &= (dt - (abs(dx) + abs(dy))) >= 0;
    ok &= (dt - (abs(dx) + abs(dy))) % 2 == 0;
  }

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

  return 0;
}


Measured memory_bytes: 1912
#include <iostream>
using namespace std;
int main(void){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int left = a + b;
  int right = c + d;
  
  if(left > right)
    cout << "Left" << endl;
  else if(left == right)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 10)

int a[MAXN][MAXN];
int b[MAXN][MAXN];
int v[MAXN];
int n, m;
bool ok;

void dfs(int k, int col) {
	if (v[k] >= 0) {
		return;
	}
	v[k] = col;
	for (int i = 1; i <= n; i++) {
		if (!b[k][i]) {
			continue;
		}
		dfs(i, col ^ 1);
	}
}

set<int> s[MAXN];

int main() {
	memset(v, -1, sizeof(v));
	cout << fixed << setprecision(12);	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int t1, t2;
		cin >> t1 >> t2;
		a[t1][t2] = 1;
		a[t2][t1] = 1;	
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == j) {
				continue;
			}
			b[i][j] = 1 - a[i][j];
		}
	}
	ok = true;
	int cnt = 0;
	vector<int> vv;
	for (int i = 1; i <= n; i++) {
		if (v[i] < 0) {
			dfs(i, cnt);
			int d = 0;
			for (int j = 1; j <= n; j++) {
				if (v[j] == cnt) {
					d++;
				} else if (v[j] == cnt + 1) {
					d--;
				}
			}
			vv.push_back(d);
			cnt += 2;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (b[i][j] && (v[i] == v[j])) {
				ok = false;
				break;
			}
		}
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	s[0].insert(0);
	for (int i = 1; i <= vv.size(); i++) { 
		int cur = vv[i - 1];
		for (auto& e: s[i - 1]) {
			s[i].insert(e + cur);
			s[i].insert(e - cur);
		}
	}
	int mindiff = n;
	for (auto& e: s[vv.size()]) {
		mindiff = min(mindiff, abs(e));
	}
	int n1 = (n + mindiff) / 2;
	int n2 = (n - mindiff) / 2;
	int e1 = (n1 * (n1 - 1)) / 2;
	int e2 = (n2 * (n2 - 1)) / 2;
	cout << e1 + e2 << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 20776
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN=10005;
int n;
vector<int> v[MAXN];
int c[MAXN];
int ans=0;
int index=0;
int xans[MAXN];
bool cmp(int x,int y)
  {
	return x>y;
}
void dfs(int no,int father)
{
	xans[no]=++index;
	for(int i=0;i<v[no].size();i++)
  {
		int u=v[no][i];
		if(u!=father) dfs(u,no);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
  {
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=1;i<=n;i++) cin>>c[i];
	sort(c+1,c+1+n,cmp);
	for (int i=2;i<=n;i++) ans+=c[i];
	cout<<ans<<'\n';
	dfs(1,-1);
	for(int i=1;i<=n;i++) cout<<c[xans[i]]<<" ";
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
n = int(input())

res = defaultdict(int)
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i + j*j + k*k + i*j + j*k + k*i
            res[v] += 1

for i in range(1, n + 1):
    print(res.get(i, 0))


Measured memory_bytes: 11912
import sys
S = sys.stdin.readline().rstrip()
L = []
R = []
rev = 0
for _ in range(int(sys.stdin.readline().rstrip())):
    A = sys.stdin.readline().rstrip().split()
    if A[0] == "1":
        rev ^= 1
    else:
        if (int(A[1]) ^ rev) & 1:
            L.append(A[2])
        else:
            R.append(A[2])

if rev:
    print("".join(R[::-1]) + S[::-1] + "".join(L))
else:
    print("".join(L[::-1]) + S + "".join(R))

Measured memory_bytes: 6252
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 505;
int grid[N][N];

struct Move
{
    int a,b,c,d;
};

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

    int n, m;
    cin>>n>>m;

    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
            cin>>grid[i][j];

    vector<Move> ans;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) {
            if (grid[i][j] %2 == 0)     continue;
            if (i==n-1 && j==m-1)       continue;
            int nx = i, ny = j;
            if (j==m-1) nx++;
            else        ny++;
            grid[i][j]--;
            grid[nx][ny]++;
            ans.push_back({i+1,j+1,nx+1,ny+1});
        }

    cout<<ans.size()<<endl;
    for (auto m : ans)
        cout<<m.a<<" "<<m.b<<" "<<m.c<<" "<<m.d<<"\n";
}


Measured memory_bytes: 5232
#include <iostream>

using namespace std;

int main()
{
    int a, b, sum;
    char ope;
    cin >> a >> ope >> b;

    if (ope == '+')
    {
        sum = a + b;
    }
    else
    {
        sum = a - b;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n, k;
    int[] a;

    scan(n, k);
    a = readln.split.to!(int[]);

    a.sort();

    bool check(int mid) {
        if (a[mid] >= k) {
            return true;
        }
        
        auto dp = new bool[](k + 1);
        dp[0] = 1;

        foreach (i ; 0 .. n) {
            if (i == mid) continue;
            foreach_reverse (j ; a[i] .. k + 1) {
                dp[j] |= dp[j - a[i]];
            }
        }

        foreach (i ; max(0, k - a[mid]) .. k) {
            if (dp[i]) {
                return true;
            }
        }

        return false;
    }


    int btm = -1, top = n;

    while (top - btm > 1) {
        int mid = (top + btm) / 2;

        if (check(mid)) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    writeln(btm + 1);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC068C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, M;
            string[] vals = Console.ReadLine().Split(' ');
            N = int.Parse(vals[0]);
            M = int.Parse(vals[1]);

            List<int>[] lists = new List<int>[N + 1];
            for (int i = 1; i <= N; i++)
                lists[i] = new List<int>();
                        
            for(int i=0; i< M; i++)
            {
                vals = Console.ReadLine().Split(' ');
                lists[int.Parse(vals[0])].Add(int.Parse(vals[1]));
            }


            bool possible = false;

            foreach(int i in lists[1])
            {
                if(lists[i].Contains(N))
                {
                    possible = true;
                    break;
                }
            }

            if(possible)
            {
                Console.WriteLine("POSSIBLE");
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }

        }
    }
}


Measured memory_bytes: 32432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long N = nl();
        if(N%2==1){
            out.println(0);
            return;
        }else{
            long ans = 0;
            long div = 10;
            while(div<=N){
                long count = N/div;
                ans += count;
                div *= 5;
            }
            out.println(ans);
        }
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33240
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200005;
const int NN=2005;
const ll md=998244353;

ll _gcd(ll a,ll b){
    while (a>0 && b>0){
        if (a>b)
            swap(a,b);
        b%=a;
    }
    return a+b;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    cout << (n*360/_gcd(n,360))/n << E;
    return 0;
}


/*







*/


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX = 100005;
vector<pair<int,int>> odd(MAX);
vector<pair<int,int>> even(MAX);
int main(){
  int n; cin >> n;
  for(int i=0;i<n/2;i++){
    int v,w; cin >> v >> w;
    odd[v].second = v;
    odd[v].first++;
    even[w].second = w;
    even[w].first++;
  }
  sort(odd.rbegin(),odd.rend());
  sort(even.rbegin(),even.rend());
  if(odd[0].second == even[0].second){
    int sub1 = n - odd[0].first - even[1].first; 
    int sub2 = n - even[0].first - odd[1].first;
    cout << min(sub1, sub2) << endl;
  }else{
    cout << n - odd[0].first - even[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#define N 100

int main()
{
  int i,j,m,flag=1,count=0,tmp=0;
  int A[N];
  
  scanf("%d",&m);
  for(i = 0;i < m;i++){
    scanf("%d",&A[i]);
  }
  
  i = 0;
  
  while(flag){
    flag = 0;
    for(j = m-1;j >= i+1;j--){
      if(A[j] < A[j - 1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flag = 1;
	count++;
      }
    }
    i++;
  }
  
  for(i = 0;i < m-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[m-1]);
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 600
N = int(input())
if N == 1:
  print(1)
  exit()
A = [int(i) for i in input().split()]
ans = 1
if A[1] - A[0] > 0:
  pre = 1
elif A[1] - A[0] == 0:
  pre = 0
else:
  pre = -1

for i in range(2,N):
  if A[i] - A[i-1] > 0:
    now = 1
  elif A[i] - A[i-1] == 0:
    now = pre
  else:
    now = -1
  if now*pre < 0:
    ans += 1
    pre = 0
  else:
    pre = now
  
print(ans)
    

Measured memory_bytes: 14224
# Aizu Problem 0227: Thanksgiving

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



while True:
    n, m = [int(_) for _ in input().split()]
    if n == m == 0:
        break
    prices = sorted([int(_) for _ in input().split()], reverse=True)
    for i in range(m - 1, n, m):
        prices[i] = 0
    print(sum(prices))

Measured memory_bytes: 7828