akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int i = sc.NextInt();

        int answer = n - i + 1;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;
llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int N, K;
	cin >> N >> K;
	if (K == 1)cout << 0 << endl;
	else cout << N - K << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include<vector>
#define inf 1e9
using namespace std;
struct activity
{
    int a,b,c;
};
int solve(vector<activity> ar,int n)
{
    int dp[n+1][3];
    dp[1][0]=ar[1].a;
    dp[1][1]=ar[1].b;
    dp[1][2]=ar[1].c;
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=ar[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=ar[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=ar[i].c+max(dp[i-1][1],dp[i-1][0]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]) );

}
int main() {
   int n;
   cin>>n;
   vector<activity> ar(n+1);
   for(int i=1;i<=n;i++)
   {
       cin>>ar[i].a;
       cin>>ar[i].b;
       cin>>ar[i].c;
   }
   cout<<solve(ar,n);
}


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

long GCD(long a, long b){
  long dividend, divisor;
  if (a >= b) {
    dividend = a;
    divisor = b;
  } else {
    dividend = b;
    divisor = a;
  }
  long remainder;
  while (1) {
    if (divisor == 1) {
      return 1;
    }
    remainder = dividend % divisor;
    if (remainder == 0) {
      break;
    } else {
      dividend = divisor;
      divisor = remainder;
    }
  }
  return divisor;
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long *a;
  a = (long *)malloc(sizeof (long) * n);
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long *d_prime,*check;
  d_prime = (long*)malloc(sizeof (long) * 1000001);
  check = (long*)malloc(sizeof (long) * 1000001);
  for (long i = 0; i <= 1000000; i++) {
    d_prime[i] = i;
    check[i] = 0;
  }
  for (long i = 2; i <= 1000000; i++) {
    if (d_prime[i] == i) {
      for (long j = 2; i*j <= 1000000; j++) {
        d_prime[i*j] = i;
      }
    }
  }
  long number,div;
  int flag = 1;
  for (long i = 0; i < n; i++) {
    number = a[i];
    while (number != 1) {
      div = d_prime[number];
      if (check[div] == 1) {
        flag = 0;
        break;
      }
      while (number%div == 0) {
        number /= div;
      }
      check[div] = 1;
    }
    if (flag == 0) {
      break;
    }
  }
  if (flag == 1) {
    printf("pairwise coprime\n");
    return 0;
  }
  long gcd_all = a[0];
  for (long i = 1; i < n; i++) {
    gcd_all = GCD(gcd_all,a[i]);
  }
  if (gcd_all == 1) {
    printf("setwise coprime\n");
  } else {
    printf("not coprime\n");
  }

  return 0;
}

Measured memory_bytes: 25092
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];
ll p[111];
bool flag[111];

//long longしか使わない
//素数は1より大きい
int main() {
	ll x, n;
	cin >> x >> n;
	rep(i, n) {
		cin >> p[i];
		flag[p[i]] = true;
	}
	ll dist = INF;
	ll ans = 0;
	for (ll i = -100;i < 200;++i) {
		if (flag[i] == false) {
			if (abs(x - i) < dist) {
				dist = abs(x - i);
				ans = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
S=str(input())
right_str = S[0]

for i in range(1,len(S)):
    if right_str[i-1] == '0':
        right_str+="1"
    else:
        right_str+="0"
ans = 0
for i in range(len(S)):
    if not right_str[i] == S[i]:
        ans +=1
print(ans)
    

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

using namespace std;

char s[200010], t[200010];
int main()
{
    scanf("%s %s", s, t);

    int c = 0;
    for (int i = 0; s[i] != '\0'; i++)
    {
        if (s[i] != t[i])
            c++;
    }
    printf("%d", c);

    return 0;
}

Measured memory_bytes: 4196
//SILENT KILLER
              //HARD WORK BEATS TALENT WHEN TALENT DOESNOT WORK HARD
#include<bits/stdc++.h>
//typedef long long ll;
int a[4];
using namespace std;
int main()
  {
    cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+1+3);
	if(a[1]==5&&a[2]==5&&a[3]==7) cout<<"YES";
	else cout<<"NO";
  }














Measured memory_bytes: 3592
package main

import (
  "fmt"
)

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}

func main(){
  var P, Q, R int
  fmt.Scan(&P, &Q, &R)
  graph := [][]int{
    []int{0, P, R},
    []int{P, 0, Q},
    []int{R, Q, 0},
  }

  ans := 100+100+100
  for i := 0; i < 3; i++ {
    for j := 0; j < 3; j++ {
      if j == i {continue}
      for k := 0; k < 3; k++ {
        if k == i || k == j {continue}
        ans = min(ans, graph[i][j] + graph[j][k])
      }
    }
  }
  fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[100009],vis[100009],vis2[100009];
vector<ll> v[100009];
void bfs(ll node,ll n)
{
    vis[node] = 1;
    for(ll i = 1;i<=n;i++)
        par[i] = -1;
    queue<ll> q;
    q.push(node);
    while(!q.empty())
    {
        ll temp = q.front();
        q.pop();

        if(temp==n)
            break;
        for(ll i=0;i<v[temp].size();i++)
        {
            if(vis[v[temp][i]]==0)
            {
                vis[v[temp][i]]= 1;
                q.push(v[temp][i]);
                par[v[temp][i]] = temp;
            }
        }
    }
}
ll bfs2(ll node)
{
    vis2[node] = 1;
    queue<ll> q;
    q.push(node);
    ll cnt = 1;
    while(!q.empty())
    {
        ll temp = q.front();
        q.pop();
        //cout<<"temp "<<temp<<endl;
        for(ll i=0;i<v[temp].size();i++)
        {
            if(vis2[v[temp][i]]==0)
            {
                cnt++;
                vis2[v[temp][i]]= 1;
                q.push(v[temp][i]);
            }
        }
    }
    return cnt;
}
vector<ll> p;
void path(ll n)
{

    if(n==-1)
        return;
    path(par[n]);
    p.push_back(n);
}
int main()
{
    ll i,n,j,x,y;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);

    }
    bfs(1,n);
    path(n);
    vector<ll> v1,v2;
    for(i=0,j=p.size()-1;i<=j;i++,j--)
    {
        v1.push_back(p[i]);
        v2.push_back(p[j]);
        vis2[p[i]] = 1;
        vis2[p[j]] = 2;
    }
    ll pq = 0;

    for(i=0;i<v1.size();i++)
    {
        //cout<<v1[i]<<"\n";
        pq+= bfs2(v1[i]);
    }
    if(pq<=n-pq)
    {
        cout<<"Snuke"<<endl;
    }
    else cout<<"Fennec"<<endl;
    //cout<<pq<<" "<<n-pq<<endl;



}


Measured memory_bytes: 13172
MOD = pow(10, 9) + 7

n, m = map(int, input().split())
slist = list(map(int, input().split()))
tlist = list(map(int, input().split()))

dp = [[1 for _ in range(n+1)] for _ in range(m+1)]
for i, s in enumerate(slist):
  for j, t in enumerate(tlist):
    if s != t:
      dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD
    else:
      if slist[i] == t and tlist[j] == s:
        dp[j+1][i+1] = (dp[j+1][i] + dp[j][i+1]) % MOD
      else:
        dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD

print(dp[-1][-1])


Measured memory_bytes: 74716
class Dice(object):
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def get_top(self):
        return self.top

    def rotate(self, directions):
        for direction in directions:
            if direction == 'S':
                self.prev_top = self.top
                self.top = self.north
                self.north = self.bottom
                self.bottom = self.south
                self.south = self.prev_top
            elif direction == 'E':
                self.prev_top = self.top
                self.top = self.west
                self.west = self.bottom
                self.bottom = self.east
                self.east = self.prev_top
            elif direction == 'W':
                self.prev_top = self.top
                self.top = self.east
                self.east = self.bottom
                self.bottom = self.west
                self.west = self.prev_top
            elif direction == 'N':
                self.prev_top = self.top
                self.top = self.south
                self.south = self.bottom
                self.bottom = self.north
                self.north = self.prev_top

dice = Dice(*map(int, input().split()))
dice.rotate(input())
print(dice.get_top())

Measured memory_bytes: 7776
import numpy as np

MOD = 10**9 + 7

N,K = map(int, input().split())
k = np.arange(K,N+2)
low = (k-1)*k//2
high = (N-k+1)*k + low + 1
ans = (high-low)%MOD
print(ans.sum()%MOD)

Measured memory_bytes: 34864
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  int a,b,c; cin>>a>>b>>c;
  int n = (b/a);
  cout << ((n > c) ? c : n) << endl;
}


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

int n;
string s;

// 右端からx個の'I'を終端と決め打ったときにx個構成できるか
bool f(int x){
    int icnt=0, ocnt=0, y=0, r=x;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='J'){
            if(ocnt>0){
                y++;
                ocnt--;
            }
        }
        if(s[i]=='O'){
            if(icnt>0){
                ocnt++;
                icnt--;
            }
        }
        if(s[i]=='I'){
            if(r>0){
                icnt++;
                r--;
            }else if(ocnt>0){
                y++;
                ocnt--;
            }
        }
    }
    return y==x;
}

int solve(){
    cin >> n >> s;
    int ok = 0, ng = n/3+1;
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(f(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 3968
n = int(input())
if 400 <= n <= 599:
    print(8)
elif 600 <= n <= 799:
    print(7)
elif 800 <= n <= 999:
    print(6)
elif 1000 <= n <= 1199:
    print(5)
elif 1200 <= n <= 1399:
    print(4)
elif 1400 <= n <= 1599:
    print(3)
elif 1600 <= n <= 1799:
    print(2)
elif 1800 <= n <= 1999:
    print(1)

Measured memory_bytes: 9188
let () =
    let main () =
        let s = read_line () in
        let len = String.length s in
        let rec loop i mode acc =
            if i = len then List.rev acc else match s.[i], mode with
            | 'A', 0 -> loop (i + 1) 0 (0 :: acc)
            | 'A', 1 -> loop (i + 1) 0 (0 :: 2 :: acc)
            | 'A', _ -> loop (i + 1) 0 (0 :: 2 :: acc)
            | 'B', 0 -> loop (i + 1) 1 acc
            | 'B', _ -> loop (i + 1) 2 acc
            | 'C', 1 -> loop (i + 1) 0 (1 :: acc)
            | _      -> loop (i + 1) 2 acc
        in
        (* mode 0 - clear stack / mode 1 - prev = B / mode 2 - otherwise *)
        let l = loop 0 0 [] in
        let rec loop stack acc = function
            | [] -> acc
            | 2 :: tl -> loop 0 acc tl
            | 0 :: tl -> loop (stack + 1) acc tl
            | _ :: tl -> loop stack (acc + stack) tl
        in
        Printf.printf "%d\n" (loop 0 0 l)
    in
    main ()

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int n,a[24],b[24],c[24],sum=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int j=0;j<n;j++)
	{
		cin>>b[j];
		sum+=b[j];
	}
	for(int i=0;i<n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]==a[i]+1)
			sum+=c[a[i]-1];
	}
	cout<<sum<<endl;
	return 0;
}

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

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

collect = sorted(p)

if p == collect:
    print('YES')
    exit()

for i in range(N):
    for j in range(N):
        p[i],p[j] = p[j],p[i]
        if p == collect:
            print('YES')
            exit()
        p[i],p[j] = p[j],p[i]

print('NO')


Measured memory_bytes: 38640
// Contest2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<string>
#include<vector>

using namespace std;

int fun1(string str, int num)
{
	int count = 0;
	bool similar = true;
	vector<char>strchar;
	for (int i = 0; i < num; i++)
		strchar.push_back(str[i]);

	for (int i = 0; i < strchar.size()-1; i++)
	{
		if (strchar[i] == strchar[i + 1])
		{
			strchar.erase(strchar.begin() + i);
			i--;
		}
	}
	return strchar.size();


}
int main()
{
	int num; cin >> num;
	string str; cin >> str;
	cout << fun1(str, num) << endl;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <decimal/decimal>
using namespace std;
using namespace __gnu_pbds;

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> c(n);
	rep(i, 0, n) {
		cin >> c[i];
	}
	int ans = 0;
	rep(x, 0, (1 << n)) {
		rep(y, 0, (1 << m)) {
			int z = 0;
			rep(i, 0, n) {
				rep(j, 0, m) {
					z += ((x >> i | y >> j) & 1 ^ 1) & (c[i][j] == '#');
				}
			}
			debug(x, y, z);
			ans += k == z;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
/*      ex4_3
        Tarara  */
#include <stdio.h>

int cal_snow_height(int west_residual_height, int east_residual_height);
int cal_tower_height(int i);

int main(void)
{
    int west_residual_height; // 西側の埋もれていない高さ
    int east_residual_height; // 東側の埋もれていない高さ
    scanf("%d %d", &west_residual_height, &east_residual_height);

    printf("%d\n", cal_snow_height(west_residual_height, east_residual_height));
    return 0;
}

// 積雪量を計算する
int cal_snow_height(int west_residual_height, int east_residual_height)
{
    // 東側の塔の番号
    int east_ind = east_residual_height - west_residual_height;

    // 東側の塔の高さ - 東側の塔の埋もれていない部分 = 降雪量
    return cal_tower_height(east_ind) - east_residual_height;
}

// 西からi番目の塔の高さを求める
int cal_tower_height(int i)
{
    return i * (i + 1) / 2;
}


Measured memory_bytes: 128
//
// Created by 遠藤護 on 7/16/18.
//

#include <iostream>
using namespace std;

int totalDigit(int num) {
    int dig;
    int sum = 0;

    while (num) {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}

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

    if (N % totalDigit(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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


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

	int n,m,sum=0;
	cin>>n>>m;

	vector<int> v(n);

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


	int count=0;

	for(int i=0;i<n;i++){
		
		if(v[i]*(4*m) >= sum)
			count++;
	
	}

	if(count>=m)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
	}

		

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

int main(){
    int n,k;
    cin >> n>> k;
    int ans=0;
    rep(i,n){
        int h;
        cin >> h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
X=list(map(int,input().split()))
cnt=0
for i in range(N-1):
    if A*(X[i+1]-X[i])>B:
        cnt=cnt+B
    else:
        cnt=cnt+A*(X[i+1]-X[i])
print(cnt)

Measured memory_bytes: 62704
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   int cnt=0;
   while(n>0)
   {
       n/=k;
       cnt++;
   }
   cout<<cnt<<endl;
}


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

int main(){
    int n,m,X,Y,x,y,mx=-100,my=100,i;
    cin>>n>>m>>X>>Y;
    for(i=0;i<n;i++){
        cin>>x;
        mx=max(mx,x);
    }
    for(i=0;i<m;i++){
        cin>>y;
        my=min(my,y);
    }
    for(i=mx;i<my;i++){
        if(i>=X && i<Y){
            break;
        }
    }
    cout<<(i<my?"No War":"War")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	  static int[] a;
	  static int num;

	  public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);
		  
		  int n = sc.nextInt();
		  int mae = sc.nextInt();
		  System.out.print(n-mae+1);
		  
		  sc.close();
	  }
}

Measured memory_bytes: 23124
#include <iostream>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
  long long A, B, C;
  cin >> A >> B >> C;

  long long canC = min(A + B + 1LL, C);
  cout << B + canC << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public Main(){}
  
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String line = scanner.nextLine();
    
    if(line.contains("a") || line.contains("e") || line.contains("i") || line.contains("o") || line.contains("u")){
 	  System.out.println("vowel");
    }
    else{
      System.out.println("consonant");
    }
  }
}

Measured memory_bytes: 21844
#                               #
    # author : samars_diary #
    # 18-09-2020 │ 19:20:45 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a,b=mii()
    if b==0: print(a) ; return
    c=lii();d=111;e=0
    for i in range(max(c)+2):
        if i not in c:
            if abs(i-a)<d:
                d=abs(i-a)
                e=i
    print(e)
                
for _ in range(1):
    solve()

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

int n, x, k;
vector<int> pos, neg;
int ans = INT_MAX;
int main(){
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    cin >> x;
    if(x < 0) neg.push_back(x);
    else pos.push_back(x);
  }
  reverse(neg.begin(), neg.end());
  for(int i = 0; i < k - 1; ++i){
    if(pos.size() > i && neg.size() > k - i - 2)
      ans = min(ans, pos[i] * 2 + abs(neg[k - i - 2]));
  }
  for(int i = 0; i < k - 1; ++i){
    if(neg.size() > i && pos.size() > k - i - 2)
      ans = min(ans, abs(neg[i]) * 2 + pos[k - i - 2]);
  }
  if(neg.size() >= k) ans = min(ans, abs(neg[k - 1]));
  if(pos.size() >= k) ans = min(ans, pos[k - 1]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1020
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll r, D, x0;
    cin >> r >> D >> x0;

    ll x = x0;
    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    
    cout << fixed << setprecision(20);

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int A, B;
  string S;
  bool flag = true;

  cin >> A >> B >> S;

  for(int i = 0; i < S.size(); i++){
    if(i < A){
      if(S[i] == '-') flag = false;

    }else if(A < i){
      if(S[i] == '-') flag = false;

    }else{
      if(S[i] != '-') flag = false;
    }

  }

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

	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var XY = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (X, Y) = (XY[0], XY[1]);

        if((X + Y) % 3 != 0)
        {
            WriteLine(0);
            return;
        }

        var n = (X + Y) / 3;
        X -= n;
        Y -= n;

        if(X < 0 || Y < 0)
        {
            WriteLine(0);
            return;
        }

        var c = new ModCombination(X + Y);
        var ans = c.Combination(X + Y, X);

        WriteLine(ans);
    }
}

struct ModInt
{
    public const int Mod = 1000000007;

    public long X { get; }

    public ModInt(long x = 0) => X = (x % Mod + Mod) % Mod;

    public static ModInt operator +(ModInt mint) => mint;
    public static ModInt operator -(ModInt mint) => new ModInt(-mint.X);
    public static ModInt operator +(ModInt mint1, ModInt mint2) => new ModInt(mint1.X + mint2.X);
    public static ModInt operator -(ModInt mint1, ModInt mint2) => new ModInt(mint1.X - mint2.X);
    public static ModInt operator *(ModInt mint1, ModInt mint2) => new ModInt(mint1.X * mint2.X);
    public static ModInt operator /(ModInt mint1, ModInt mint2) => mint1 * Inv(mint2);

    public static ModInt Pow(ModInt mint, long t)
    {
        if (t == 0)
            return new ModInt(1);

        var a = Pow(mint, t >> 1);
        a *= a;

        if (t % 2 == 1)
            a *= mint;

        return a;
    }

    public static ModInt Inv(ModInt mint) => Pow(mint, Mod - 2);

    public override string ToString() => X.ToString();
}

class ModCombination
{
    private ModInt[] fact, ifact;
    public int MaxN { get; }

    public ModCombination(int maxN)
    {
        if (maxN < 0 || ModInt.Mod <= maxN)
            throw new ArgumentException();

        MaxN = maxN;

        fact = new ModInt[maxN + 1];
        ifact = new ModInt[maxN + 1];

        fact[0] = new ModInt(1);
        for (int i = 1; i <= maxN; ++i)
            fact[i] = fact[i - 1] * new ModInt(i);

        ifact[maxN] = ModInt.Inv(fact[maxN]);
        for (int i = maxN; i >= 1; --i)
            ifact[i - 1] = ifact[i] * new ModInt(i);
    }

    public ModInt Combination(int n, int k)
    {
        if ((n < 0 || MaxN < n) || (k < 0 || n < k))
            throw new ArgumentException();

        return fact[n] * ifact[k] * ifact[n - k];
    }
}



Measured memory_bytes: 38580
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    R = [0] * K
    for i in range(1, N + 1):
        R[i % K] += 1

    ans = 0
    for a in range(K):
        b = c = (K - a) % K
        if (b + c) % K == 0:
            ans += R[a] * R[b] * R[c]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10388
#include<bits/stdc++.h>
#define $ for(i=0;i++<n;)
using namespace std;
int n,m,g[777][777],C[777],t[777][2],A,c,i,j;
vector<int>G[777];
bitset<777>P(1);
int f(int u,int c){
	int t=1,i=0;
	for(C[u]=c;i<G[u].size();i++)t&=C[G[u][i]]<0?f(G[u][i],c^1):C[G[u][i]]^c;
	return t;
}
main(){
	for(cin>>n>>m;cin>>i>>j;)g[i][j]=g[j][i]=1;
	$ for(j=i;j++<n;)if(!g[i][j])G[i].push_back(j),G[j].push_back(i);
	$ C[i]=-1;
	$ A+=C[i]<0&&!f(i,c+=2);
	A=A?-1:1e9;
	$ t[C[i]/2][C[i]%2]++;
	$ P=P<<t[i][0]|P<<t[i][1];
	$ A=min(A,P[i]?i*(i-1)/2+(n-i)*(n-i-1)/2:A);
	cout<<A;
}

Measured memory_bytes: 3200
def run_magic_tiles(magic_tiles, past_matrix):
    def move_up(x, y):
        return x - 1, y

    def move_down(x, y):
        return x + 1, y

    def move_left(x, y):
        return x, y - 1

    def move_right(x, y):
        return x, y + 1

    def goal():
        return -1, -1

    i, j = 0, 0
    while True:
        res = {
            '^': move_up(i, j),
            'v': move_down(i, j),
            '<': move_left(i, j),
            '>': move_right(i, j),
            '.': goal()
        }.get(magic_tiles[i][j])
        if res[0] == -1 and res[1] == -1:
            return j, i
        else:
            i, j = res
            if past_matrix[i][j]:
                return 'LOOP'
            past_matrix[i][j] = 1


def main():
    while True:
        c, r = map(int, input().split(' '))
        if c == 0 and r == 0:
            break

        past_matrix = [[0 for _ in range(r)] for _ in range(c)]
        tiles = []
        for _ in range(c):
            tiles.append(list(input()))

        res = run_magic_tiles(tiles, past_matrix)
        print('LOOP' if res == 'LOOP' else '%d %d' % (res[0], res[1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7900
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *P = map(int, read().split())

P = sorted(P)
print(sum(P[:K]))

Measured memory_bytes: 27240
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int N = scan.nextInt();
    double x;
    double sum = 0;
    String str;
    for(int i = 0;i < N; i++){
      x = scan.nextDouble();
      str = scan.next();
      if(str.equals("BTC")) x = x*380000;
      sum = sum+x;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 24916
#include <stdio.h>

int main (void){
  int charcters[26] = {0};
  char ch;
  int i;

  while (scanf("%c", &ch) != EOF) {
    if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
      if('a' <= ch && ch <= 'z') {
        charcters[ch - 'a']++;
      } else {
        charcters[ch - 'A']++;
      }
    }
  }

  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, charcters[i]);
  }

  return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<string> s(9);
vector<bool> check(9, false);
vector<int> a(9), b(9);

int solve(int k){
    if(k == 9)
        return 1;

    int ret = 0;
    for(int i=0; i<9; ++i){
        if(check[i])
            continue;
        check[i] = true;
        a[k] = i;
        for(int j=0; j<4; ++j){
            b[k] = j;
            if(k > 2 && abs(s[i][j] - s[a[k-3]][(b[k-3]+2)%4]) != abs('a'-'A'))
                continue;
            if(k % 3 != 0 && abs(s[i][(j+3)%4] - s[a[k-1]][(b[k-1]+1)%4]) != abs('a'-'A'))
                continue;
            ret += solve(k+1);
        }
        check[i] = false;
    }

    return ret;
}

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

    while(--n >= 0){
        for(int i=0; i<9; ++i)
            cin >> s[i];

        int ret = solve(0);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 928
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n;
	cin>>n;
	
	int alpha[n][26]={0};
	int i,j;
	string s;
	rep(i,n){
		cin>>s;
		rep(j,s.length())
		{
			alpha[i][s[j]-'a']++;
		}
	}
	int ans=0,tmp;
	string anss="";
	for(i=0;i<26;i++){
		tmp=INF;
		for(j=0;j<n;j++){
			tmp=min(tmp,alpha[j][i]);
		}
		rep(j,tmp)anss+='a'+i;
	}
	fin(anss);
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 256
<?php 
  
  fscanf(STDIN,"%d",$N);

$p_list = explode(" ",trim(fgets(STDIN)));

$p_corect = $p_list;

sort($p_corect);
$count=0;

for($i=0;$i<$N;$i++){
  if($p_corect[$i] != $p_list[$i]){
     $count++;
  }
}

if($count==2 || $count==0){
  echo "YES\n";
}else{
  echo "NO\n";
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define EPS 1e-7
using namespace std;

int n, q;

int x[50], y[50], z[50], r[50];
long long l[50];

int main(){
	cin >> n >> q;
	rep(i,n) scanf("%d%d%d%d%lld",x+i,y+i,z+i,r+i,l+i);
	rep(i,q){
		int sx, sy, sz, dx, dy, dz;
		scanf("%d%d%d%d%d%d",&sx,&sy,&sz,&dx,&dy,&dz);
		long long ans = 0;
		rep(u,n){
			double s = 0.0, e = 1.0, smid, emid;
			double sd, ed;
			sd = sqrt(pow(sx-x[u],2.0)+pow(sy-y[u],2.0)+pow(sz-z[u],2.0));
			ed = sqrt(pow(dx-x[u],2.0)+pow(dy-y[u],2.0)+pow(dz-z[u],2.0));
			rep(j,1000){
				smid = s + (e-s)/3;
				emid = e - (e-s)/3;
				double sxx = sx + smid*(dx-sx);
				double syy = sy + smid*(dy-sy);
				double szz = sz + smid*(dz-sz);
				double exx = sx + emid*(dx-sx);
				double eyy = sy + emid*(dy-sy);
				double ezz = sz + emid*(dz-sz);
				if(sqrt(pow(sxx-x[u],2.0)+pow(syy-y[u],2.0)+pow(szz-z[u],2.0)) > sqrt(pow(exx-x[u],2.0)+pow(eyy-y[u],2.0)+pow(ezz-z[u],2.0))){
					sd = sqrt(pow(sxx-x[u],2.0)+pow(syy-y[u],2.0)+pow(szz-z[u],2.0));
					s = smid;
				} else{
					ed = sqrt(pow(exx-x[u],2.0)+pow(eyy-y[u],2.0)+pow(ezz-z[u],2.0));
					e = emid;
				}
			}
			if(sd < r[u]+EPS) ans += l[u];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1244
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> A(N);
	bool flag = true;
	rep(i, 0, N) {
		int tmp;  cin >> tmp;
		A[i] = tmp;
		if ((tmp % 2) == (N % 2))flag = false;
	}
	if (flag) {
		sort(A.begin(), A.end());
		if (N % 2 == 1) {
			if (A[0] != 0)flag = false;
			for (int i = 1; i < N;i+=2) {
				if (!(A[i] == i + 1 && A[i + 1] == i + 1))flag = false;
			}
		}
		else {
			for (int i = 0; i < N; i += 2) {
				if (!(A[i] == i + 1 && A[i + 1] == i + 1))flag = false;
			}
		}
	}
	int ans;
	if (flag) {
		ans = 1;
		rep (i, 0, N / 2) {
			ans = (ans * 2) % MOD;
		}
	}
	else ans = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define rep1c(i, n) for (int i = 1; i <= (int)n; i++)
int main()
{
  int k;
  cin >> k;
  lint ans = 0;
  rep1c(a, k) rep1c(b, k)
  {
    int gab = __gcd(a, b);
    rep1c(c, k) { ans += __gcd(gab, c); }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#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;
#define mp make_pair
#define int long long

const int N = 2e5+2;
int up[N][65];
void solve_case()
{
    int n,k;
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> up[i][0];
    for(int j=1; j<=62; j++)
    {
        for(int i=1; i<=n; i++) up[i][j] = up[up[i][j-1]][j-1];
    }
    int st = 1;
    for(int i=62; i>=0; i--)
    {
        if(k & (1LL<<i)) st = up[st][i];
    }
    cout << st << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int T = 1;
    //cin >> T;
    while(T--)
    {
        solve_case();
    }
    return 0;
}


Measured memory_bytes: 105224
#include <stdio.h>

void delcntland( char map[13][13], int y, int x )
{
        map[y][x] = '0';
        if ( x+1 < 12 && map[y][x+1] == '1' ) { delcntland( map, y, x+1 ); }
        if ( y+1 < 12 && map[y+1][x] == '1' ) { delcntland( map, y+1, x ); }
        if ( x-1 >= 0 && map[y][x-1] == '1' ) { delcntland( map, y, x-1 ); }
        if ( y-1 >= 0 && map[y-1][x] == '1' ) { delcntland( map, y-1, x ); }
}

int main()
{
        char map[13][13];
        int i = 0, j = 0, island = 0;

        while ( 1 ) {
                for ( i = 0 ; i < 12 ; i++ ) {
                        if ( scanf( "%s", map[i] ) == EOF ) { return 0; }
                }

                island = 0;
                for ( i = 0 ; i < 12 ; i++ ) {
                        for ( j = 0 ; j < 12 ;j++ ) {
                                if ( map[i][j] == '1' ) {
                                        delcntland( map, i, j );
                                        island++;
                                }
                        }
                }
                printf( "%d\n", island );
        }

        return 0;
}



Measured memory_bytes: 1932
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	if (S.back() == 's') S += "es";
	else S += "s";

	co(S);


	Would you please return 0;
}

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

int main(){

    int N,M;
    cin >> N >> M;
    vector<int> s(M);
    vector<int> c(M);

    vector<int> num(N,0);
    vector<bool> exist(N,false);
    bool ok = false;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        if(exist.at(a-1) && num.at(a-1) != b){
            ok = true;
            break;
        }
        else{
            num.at(a-1) = b;
            exist.at(a-1) = true;
        }

    }
    int ans = 0;
    rep(i,N){
        ans+=pow(10,N-1-i)*num.at(i);
    }
    if(N>=2&&exist.at(0) == false) ans += pow(10,N-1);
    bool mendou =false;
    if(N>=2&&num.at(0) == 0&&exist.at(0)) mendou = true;
    if(ok || mendou) cout << -1 << endl;
    else cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long int
int main(){
   ll x,y;
   cin>>x>>y;
   if(y>=2*x && y<=4*x&&y%2==0){
       cout<<"Yes";
   }
   else{
       cout<<"No";
   }
}


Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        var tempstr = Console.ReadLine ().Split (' ');
        var A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = int.Parse (tempstr[i]);
        }
        long stocknow = 0;
        long moneynow = 1000;
        var B = new bool[N];
        var S = new bool[N];
        for (int i = 0; i < N - 1; i++) {
            if (A[i] < A[i + 1]) {
                B[i] = true;
                S[i + 1] = true;
            }
        }
        for (int i = 0; i < N; i++) {
            if (S[i]) {
                moneynow += stocknow * A[i];
                stocknow = 0;
            }
            if (B[i]) {
                stocknow += moneynow / A[i];
                moneynow -= stocknow * A[i];
            }
        }
        moneynow += stocknow * A[N - 1];
        stocknow = 0;
        Console.WriteLine (moneynow);
    }

}

//dotnet run --project test

Measured memory_bytes: 27528