akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	char c;
	rep(i, 0, N)
	{
		cin >> c;
		if (c == 'Y')
		{
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]
sm = sum(l)
a = l[0]
b = sm-l[0]
ans = min(abs(b-a), sm)
for i in range(1, n-1):
    a += l[i]
    b -= l[i]
    ans = min(abs(b-a), ans)
print(ans)

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

using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int cnt = 0, t;
    for (int i = 0; i < N; i++) {
        cin >> t;
        if (A <= t && t < B) ++cnt;
    }
    cout << N - cnt << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu9c()

fun yorukatsu9c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val scList = (1..m).map {
        readLine()!!.split(' ').map { it.toInt() }.let { Sc(it[0], it[1]) }
    }

    for (i in 0..999) {
        if (i.toString().length != n) continue
        val s = i.toString().map { Character.getNumericValue(it) }
        if (scList.all { s[it.s - 1] == it.c }) return println(i)
    }

    println(-1)
}

private data class Sc(val s: Int, val c: Int)


Measured memory_bytes: 38260
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int zero=0, one=0;
    rep(i,s.length()){
        if(s[i]=='0'){
            zero++;
        }
        else{
            one++;
        }
    }
    int minn=min(zero,one);
    cout<<minn*2<<endl;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

Measured memory_bytes: 256
use std::io::{BufRead, Write, stdin, stdout};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let n: u32 = s.split_whitespace().next().unwrap().parse().unwrap();
    s.clear();
    let mut a = vec![0u32; 100000];
    input.read_line(&mut s).unwrap();
    for buf in s.split_whitespace() {
        let x: u32 = buf.parse().unwrap();
        a[(x - 1) as usize] += 1;
    }
    for i in &mut a {
        if *i == 0 {
            continue;
        }
        *i = match *i % 2 {
            0 => 2,
            1 => 1,
            _ => unreachable!(),
        }
    }
    let mut base: i64 = 0;
    'outer: for i in 0..a.len() {
        if a[i] == 2 {
            a[i] = 1;
            for j in i + 1..a.len() {
                if a[j] == 2 {
                    a[j] = 1;
                    continue 'outer;
                }
            }
            // Unfortunately, we need to sacrifice one
            assert_eq!(base, 0);
            base = -1;
        }
    }
    writeln!(output, "{}", a.iter().fold(base, |acc, &x| acc + x as i64)).unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("5
1 2 1 3 7\n",
             "3\n");
    }
    #[test]
    fn case2() {
        test("15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n",
             "7\n");
    }
}

Measured memory_bytes: 1404
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int p[100000];
int y[100000];
int z[100000];
int ans[100000];

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

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

int getpattern(int w) {
	int a;
	switch (w) {
	case 0:
	case 1:
		a = 1;
		break;
	case 2:
		a = 2;
		break;
	case 3:
		a = 3;
		break;
	case 4:
		a = 5;
		break;
	case 5:
		a = 8;
		break;
	case 6:
		a = 13;
		break;
	case 7:
		a = 21;
		break;
	}

	return a;
}

int main() {
	int h,w,k;
	scanf("%d%d%d", &h,&w,&k);

	int num[8][8];
	REP(i, w) {
		if (i != 0) {
			num[i][i - 1] = getpattern(i - 1)*getpattern(w - (i + 1));
		}
		num[i][i] = getpattern(i)*getpattern(w - (i + 1));
		if (i != w - 1) {
			num[i][i + 1] = getpattern(i)*getpattern(w - (i + 1) - 1);
		}
	}

	ll ans[101][8] = { 0 };
	ans[0][0] = 1;
	REPS(i, h) {
		REP(j, w) {
			if (j != 0) {
				ans[i][j] += (ans[i-1][j - 1] * num[j - 1][j]) % MOD;
			}
			ans[i][j] += (ans[i - 1][j] * num[j][j]) % MOD;
			if (j != w-1) {
				ans[i][j] += (ans[i - 1][j + 1] * num[j + 1][j]) % MOD;
			}
			ans[i][j] %= MOD;
		}
	}
	PRINTL(ans[h][k-1]);
}

Measured memory_bytes: 128
#include<stdio.h>

using namespace std;

int gcd(int x, int y) {
    if(y == 0) return x;
    else
        return x%y == 0 ? y : gcd(y, x%y);

}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", gcd(a, b));
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
using namespace std;


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

    int l = S.length();
    int lim = (K > l) ? l : K;
    for(int i=0; i < lim; i++){
        if(S[i] == '1'){
            if(i == lim-1)
                cout << 1 << endl;
            else
                continue;
        }
        else{
            cout << S[i] << endl;
            break;
        }

    }
    //REP(index, K){
    //    if(S[index] == '1') continue;
    //    else{
    //        cout << S[index] << endl;
    //        break;
    //    }
    //    if(index == S.length()-1)
    //        cout << 1 << endl;
    //}

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  else return Pow(A * A % MOD, N / 2) * A % MOD;
}

ll Pow25[int(1e6 + 5)], Pow26[int(1e6 + 5)];
ll nCr[int(2e6 + 5)];

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

  Pow25[0] = 1; Pow26[0] = 1;
  for (int i = 1; i <= K; i++){
    Pow25[i] = Pow25[i - 1] * 25 % MOD;
    Pow26[i] = Pow26[i - 1] * 26 % MOD;
  }

  int N = S.length();
  nCr[N - 1] = 1;
  for (ll i = N; i <= N + K; i++){
    nCr[i] = nCr[i - 1] * i % MOD;
    nCr[i] *= Pow(i - N + 1, MOD - 2);
    nCr[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 0; i <= K; i++){
    ll now = Pow25[K - i] * Pow26[i] % MOD;
    now *= nCr[K - i + N - 1]; now %= MOD;
    ans += now; ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


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

void Main() {
  string s;
  cin >> s;

  for (int bit = 0; bit < (1 << 3); bit++) {
    int ret = s[0] - '0';
    for (int i = 1; i < s.length(); i++) {
      int num = s[i] - '0';
      if (bit & (1 << (i - 1))) {
        ret += num;
      } else {
        ret -= num;
      }
    }
    if (ret == 7) {
      cout << s[0];
      for (int i = 1; i < s.length(); i++) {
        if (bit & (1 << (i - 1))) {
          cout << '+';
        } else {
          cout << '-';
        }
        cout << s[i];
      }
      cout << "=7" << endl;
      return;
    }
  }
}

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

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  long a[n];
  long long sum = 0;
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  long long min = sum;
  long long sum2 = a[0];
  min = abs(sum2-(sum-sum2));
  for(int i = 1; i < n-1; i++){
    sum2 += a[i];
    if(abs(sum2-(sum-sum2))<min){
      min = abs(sum2 - (sum-sum2));
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var Input = input.split(" ");
	
	var a = parseInt(Input[0], 10);
  
  	if(a % 9 == 0 && a / 9 < 10 ||
       a % 8 == 0 && a / 8 < 10 ||
       a % 7 == 0 && a / 7 < 10 ||
       a % 6 == 0 && a / 6 < 10 ||
       a % 5 == 0 && a / 5 < 10 ||
       a % 4 == 0 && a / 4 < 10 ||
       a % 3 == 0 && a / 3 < 10 ||
       a % 2 == 0 && a / 2 < 10 ||
       a % 1 == 0 && a / 1 < 10
      ){
      	console.log("Yes");
    }else{
      	console.log("No");
    }
	

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
from collections import defaultdict

N ,M = map(int,input().split())
H = list(map(int,input().split()))
graph = defaultdict(int)
for _ in range(M):
    A, B = map(int,input().split())
    graph[A]= max(graph[A],H[B-1])
    graph[B]= max(graph[B],H[A-1])

print(sum(H[i-1] > graph[i] for i in range(1,N+1)))

Measured memory_bytes: 24712
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define read(a) scanf("%d", &a)
#define x first
#define y second

#define N 1514

int n, K;
char s[N];
int dp[N][26];

int main() {
	scanf("%s%d", s, &K);
	n = int(strlen(s));
	bool all = 1;
	for (int i = 1; i < n; i++) all &= s[i] == s[i - 1]; 
	if (all) {
		cout << LL(n) * K / 2 << endl;
		return 0;
	}
	int R = min(K, 5), m = R * n;
	for (int i = 1; i < R; i++) for (int j = 0; j < n; j++) s[i * n + j] = s[(i - 1) * n + j];
	memset(dp, 0x3f, sizeof dp);
	for (int i = 0 ;i < 26; i++) dp[0][i] = (s[0] - 'a' != i);
	for (int i = 1; i < m; i++) {
		int x = s[i] - 'a';
		for (int j = 0; j < 26; j++) {
			for (int k = 0; k < 26; k++) if (j != k){
				dp[i][k] = min(dp[i][k], dp[i - 1][j] + (k != x));
			}
		}
	}
	if (R == K) {
		int ans = 0x3f3f3f3f;
		for (int i = 0; i < 26; i++) ans = min(ans, dp[m - 1][i]); 
		cout << ans << endl;
	}
	else {
		int ans1 = 0x3f3f3f3f, ans2 = 0x3f3f3f3f;
		for (int i = 0; i < 26; i++) ans1 = min(ans1, dp[m - 1][i]); 
		for (int i = 0; i < 26; i++) ans2 = min(ans2, dp[m - n - 1][i]); 
		long long ans = LL(ans2 - ans1) * (R - K) + ans1;
		cout << ans << endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	int  a[256] = {};
	string W;
	cin >> W;
	for (int i = 0; i < W.size(); i++) {
		a[int(W[i])]++;
	}
	for (int i = 97; i < 123; i++) {
		if (a[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	string S;
	cin >> S;
	int mind = 0;

	rep(i, 4) {
		if (S.substr(i, 1) == "+") mind++;
		else mind--;
	}

	cout << mind << "\n";
	Would you please return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD=1e9+7;

int main()
{
    
  	IOS
	ll n,W;
	cin>>n>>W;
	ll dp[100005];
	for(ll i=1;i<=100004;i++)
	{
		dp[i]=MOD;
	}
	ll w[n],v[n];
	for(ll i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	dp[0]=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=100000;j>=v[i];j--)
		{
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=100000;i++)
	{
		if(dp[i]<=W)
		{
			ans=i;
		}
	}
	cout<<ans<<endl;




}
    
 
    
    


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int left = 0, right = 0;
    REP(i,m){
        int a = in();
        if (a < x) left++;
        else right++;
    }
    cout << min(left, right) << endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  
  int b[n];
  for(int i=0; i<n; i++){
    b[a[i]-1] = i+1;
  }
  for(int i=0; i<n; i++){
    cout << b[i] << " ";
  }
  cout << endl;
}
    
    
  

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    int count=A.size();
    int chk=0;
    for(int i=0; i<N; i++)
    {
        chk+=A.at(i);
    }
    sort(A.begin(),A.end());
    while(chk<M)
    {
        chk+=A.at(0);
        if(chk>M) break;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main()
{
    int N, A, B;
    cin >> N;
    cin >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % N == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";

    return 0;
}

Measured memory_bytes: 3588
#!/usr/bin/php
<?php
$nums = explode(' ', trim(fgets(STDIN)));
$answer = false;
if ($nums[0] == $nums[1] && $nums[1] != $nums[2]) {
  $answer = true;
} else if ($nums[0] == $nums[2] && $nums[1] != $nums[2]) {
  $answer = true;
} else if ($nums[1] == $nums[2] && $nums[0] != $nums[2]) {
  $answer = true;
}

if ($answer) {
  echo 'Yes';
} else {
  echo 'No';
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {

    int N,K; cin >> N >> K;
    vector<mint> dp(K+1,(mint)0);
    REPR(i,K){
        if(i==0) continue;
        int x = K/i;
        dp[i] = modpow((mint)x,N);
        int num = 2*i;
        while(num<=K){
            dp[i] -= dp[num];
            num += i;
        }
    }
    mint ans = 0;
    FOR(i,1,K+1){
        ans += (mint)i*dp[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15920
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,p;
long long m,v,a[100100],b[100100],del[100100],cur,vote;
bool ok(int x){
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		del[i]=0;
	}
	cur=a[x]+m;
	vote=m*v-m;
	b[x]+=m;
	int tmp=x;//交换，排序 
	while(tmp>1&&b[tmp]>b[tmp-1]){
		swap(b[tmp],b[tmp-1]);
		tmp--;
	}
	int xxx;
	for(int i=1;i<=n;i++)//找到它的位置 
		if(b[i]==cur){
			xxx=i;
			break;
		}
	xxx--;
	if(xxx>=p)
		return false;
	for(int i=n;i>xxx+1;i--){//计算：比它小的 
		long long delta=min((cur-b[i]),m);//尽力补 
		vote-=delta;
		del[i]=delta;
		b[i]+=delta;
		if(vote<=0){
			return true;//投完了 
		}
	}
	for(int i=1;i<=xxx;i++){
		vote-=m;
		b[i]+=m;
		if(vote<=0){
			return true;
		}
	}
	int fore=xxx;
	for(int i=xxx+2;i<=n;i++){
		vote-=(m-del[i]);
		if(b[i]+(m-del[i])>cur)
			fore++;
		if(vote<=0){
			if(fore<p)
				return true;
		}
	}
	return false;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int l=1,r=n,mi;
	while(l<r){
		mi=(l+r+1)/2;
		if(ok(mi))
			l=mi;
		else
			r=mi-1;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(A>0&&C>0)
    {
        if(m%2)
        {
            A-=D;
        }
        else
        {
            C-=B;
        }
        m++;
    }
    if(C<=0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3660
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int R = n - 1;
  int ans = 0;
  bool done = false;
  for (int L = 0; L < n; L++) {
    if (s[L] == 'W') {
      while (s[R] == 'W') {
        --R;
        if (R < L) {
          done = true;
          break;
        }
      }
      if (done) {
        break;
      }
      ++ans;
      swap(s[L], s[R]);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3728
#include<iostream>
using namespace std;
string s;
int dp[2<<17][26];
main()
{
	cin>>s;
	for(int i=s.size();i--;)
	{
		int m=1e9;
		for(int j=0;j<26;j++)
		{
			if(m>dp[i+1][j])m=dp[i+1][j];
			dp[i][j]=dp[i+1][j];
		}
		dp[i][s[i]-'a']=m+1;
	}
	string ans="";
	int id=0;
	while(id<s.size())
	{
		int mi=0;
		for(int i=0;i<26;i++)if(dp[id][i]<dp[id][mi])mi=i;
		char c=mi+'a';
		ans+=c;
		while(id<s.size()&&s[id]!=c)id++;
		id++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 20996
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner scanf =new Scanner (System.in);
		
		int a []= new int[10];
		int x,i,k,j;
		
		for (i=0; i<10 ;i++)
		a[i]=scanf.nextInt();
		
		for (j=9; j>0 ;j--)
		for (k=0; k<j ;k++)
		if (a[k]>a[k+1]) {
			x=a[k]; a[k]=a[k+1]; a[k+1]=x;} 
		System.out.println(a[9]+"\n"+a[8]+"\n"+a[7]);
		
	}
}

Measured memory_bytes: 17376
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
  int a,b;
  char c;
  cin >> a >> c >> b;
  if(c == '+') cout << a+b<<endl;
  else cout << a-b<<endl;
    
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 256
A, B = (int(x) for x in input().split())

if A>0:
    A -= 1
    
count = 0

binary_a = [False]*40
binary_b = [False]*40

for i in range(1,40):
    if int((A / (2 ** i))) % 2 == 1:
        if A % 2 == 0:
            binary_a[i] = True
    if int((B / (2 ** i))) % 2 == 1:
        if B % 2 == 0:
            binary_b[i] = True
            
if A%4 == 1 or A%4 ==2:
    binary_a[0] = True
if B%4 == 1 or B%4 ==2:
    binary_b[0] = True
    
#print(binary_a)
#print(binary_b)

for i in range(40):
    if not(binary_a[i] == binary_b[i]):
        count += 2 ** i
        
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void solve(long long a, long long b, long long c, long long d, long long e, long long k){
    if(e - a > k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    long long e;
    scanf("%lld",&e);
    long long k;
    scanf("%lld",&k);
    solve(a, b, c, d, e, k);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;

vi graph[8];
bool vis[8];
int res,n,m;
void dfs(int u,int cnt){
    if(cnt==n){
        res++;
        return;
    }
    vis[u]=1;
    for(auto v:graph[u]){
        if(!vis[v]){
            vis[v]=1;
            dfs(v,cnt+1);
            vis[v]=0;
        }
    }
}

int32_t main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    dfs(1,1);
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3640
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int x;cin>>x;
		int ans=x^1;
		cout<<ans;
    }
    return 0;
} 


Measured memory_bytes: 3632
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  vec a(5);
  REP(i,5) cin >> a[i];
  
  sort(a.begin(),a.end());
  int ans = INF;
  do{
    int tmp = 0;
    REP(i,5){
      tmp += a[i];
      if(i != 4 && tmp%10) tmp -= tmp%10, tmp += 10;
    }
    ans = min(ans,tmp);
  }while(next_permutation(a.begin(),a.end()));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	int i, count = 0;
	char s[1001], t[11];
	char END[] = "END_OF_TEXT";
	scanf("%s", t);
	int c;
	int k;
	int len, len2;

	len = strlen(t);
	for (k = 0; k < len; k++)
	{
		t[k] = tolower(t[k]);
	}

	while (1)
	{
		scanf("%s", s);

		if (strcmp(END, s) == 0)
		{
			printf("%d\n", count);
			return 0;
		}

		len2 = strlen(s);
		for (k = 0; k < len2; k++)
		{
			s[k] = tolower(s[k]);
		}

		if (strcmp(s, t) == 0)
		{
			count++;
		}
	}
}

Measured memory_bytes: 2712
S = sorted(list(set(list(input()))))
test = sorted('abcdefghijklmnopqrstuvwxyz')

if S == test:
    print('None')

elif S[-1] == test[len(S)-1]:
    print(test[len(S)])

else:
    for num in range(len(S)):
        if test[num] != S[num]:
            print(test[num])
            break

Measured memory_bytes: 3956
read N
tr ' ' '\n'|awk -v N=$N '{s+=$0;for(i=0;i<N-1;i++)if(i+NR>=N&&i+NR<2*N)b[i+NR]+=$0}END{for(i in b){print s-b[i];l++}if(!l)print s}'|sort -nr|head -1

Measured memory_bytes: 852
def compute_gcm(x, y):
  if x == y:
    return x
  if x < y:
    s = x
    x = y
    y = s
  if x==1:
    return 1
  a = x%y
  if a == 0:
    return y
  return compute_gcm(y, a)

#print(compute_gcm(4,compute_gcm(2,2)))
k = int(input())
res = k**3-(k-1)**3
same1 = 0
same2 = 0
rate = [6,3,1]
for p in range(2,k+1):
  for q in range(p, k+1):
    same1 = int(p==q)
    gcm1 = compute_gcm(q,p)
    for r in range(q, k+1):
      same2 = int(q==r)
      gcm = compute_gcm(r,gcm1)
      res += gcm*rate[same1+same2]
      #print("p:{}, q:{}, r:{}, gcm:{}, rate:{}, sum:{}".format(p,q,r,gcm,rate[same1+same2],res))
print(res)

Measured memory_bytes: 9236
///******* In the name of Allah *******///

#include<bits/stdc++.h>
using namespace std;

int main()
{
   int a,b,c,m,n,i,j,k,l,x,ans;
   cin>>k>>x;
   ans = k*500;
   if(ans>=x)
   {
      cout<<"Yes"<<endl;
   }
   else
   {
     cout<<"No"<<endl;
   }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

double get_ev(int n) {
	return (double) (n * (n + 1) / 2) / n;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

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

	double max_sum = 0.0;
	for (int i = 0; i < k; ++i) {
		max_sum += get_ev(p[i]); 	
	}

	int i = 0, j = k;
	double curr = max_sum;
	while (j < n) {
		curr -= get_ev(p[i]);
		curr += get_ev(p[j]);
		max_sum = max(max_sum, curr);
		++j;
		++i;
	}

	cout << setprecision(12) << max_sum << "\n";

	return 0;

}

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

#define MAX 100

int isEmpty();
int isFull();
void push(int);
int pop();

int top=0;
int s[MAX];

int main(){
  int x,a,b,i;
  char in;

  while( scanf("%s", &in) != EOF )
    {
      if ( in == '+' )
	{
	  a = pop();b = pop();
	  push(a+b);
	}
      else if ( in == '-' )
	{
	  a = pop();b = pop();
	  push(b-a); 
	}
      else if ( in == '*' )
	{
	  a = pop();b = pop();
	  push(a*b);
	}
      else  push(atoi(&in));
    }
  printf("%d\n", s[1]);
  return 0;
}

int isEmpty()
{
  if(top == 0)return 1;
  else return 0;
}

int isFull()
{
  if(top >=  MAX)return 1;
  else return 0;
}

void push(int x)
{
  
  if(isFull())
    {
      printf("Stack Over Flow!\n");exit(1);
    }
  top++;
  s[top] = x;
}

int pop()
{
  if(isEmpty())
    {
      printf("Stack Under Flow!\n");exit(2);
    }
  top--;
  return s[top+1];
}





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

using namespace std;

int digits(long long a)
{
	int count=0;
	while(a)
	{
		count++;
		a /= 10;
	}
	return count;
}

int main()
{
	long long n;
	cin >> n;
	int answer = digits(n);
	int i;
	for (i=2;i<=sqrt(n);i++)
	{
		if (n%i==0)
		{
			int temp = digits(n/i);
			if (temp<answer)
			{
				answer = temp;
			}
		}
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 256
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	
	ans := 1

	for i := 1; i <= a; i++ {
		ans = (ans * i) % (1e+9 + 7)
	}
	

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll n;
    cin>>n;
    ll a[n+1];
    ll s=0;
    for(ll i=0;i<=n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(n==0)
    {
        if(a[0]==1)
        {
            cout<<1;
        }
        else
            cout<<-1;
        return 0;
    }
    if(a[0]!=0)
    {
        cout<<-1;
        return 0;
    }
    ll act=1;
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ll now=a[i];
        ll pos=act*2;
        //cout<<i<<' '<<act<<endl;
        if(now>pos)
        {
            cout<<-1;
            return 0;
        }
        ans+=now;
        pos-=now;
        s-=now;
        act=min(pos,s);
        ans+=act;
    }
    cout<<ans;
}



Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
  int a, b;

  cin >> a >> b;

  string judgStr;
  int count = 0;
  for(int judgNum = a; judgNum<=b; judgNum++){
    judgStr = to_string(judgNum);
    int start = 0;
    int end = judgStr.size()-1;
    bool palindrome = true;


    while(start <= end){
      if(judgStr.at(start) != judgStr.at(end)){
        palindrome = false;
      }
      start++;
      end--;
    }

    if(palindrome){
      count++;
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAXN 1001
int Stick[MAXN];


int main()
{
#ifdef _WIN32
	freopen("input.txt", "r", stdin);
#endif
	
	int N;
	scanf("%d", &N);

	for (int n = 0; n < N; n++)
		scanf("%d", &Stick[n]);

	for(int i = 0; i < N; i++)
		for(int j = i; j < N; j++)
			if (Stick[i] > Stick[j])
			{
				int Temp = Stick[i];
				Stick[i] = Stick[j];
				Stick[j] = Temp;
			}

	int Result = 0;
	for (int x = 0; x < N; x++)
		for (int y = x + 1; y < N; y++)
			for (int z = y + 1; z < N; z++)
					if (Stick[x] + Stick[y] > Stick[z])
							Result++;

	printf("%d", Result);
}

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

using namespace std;
#define int long long int
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007
#define r0 return 0
/*
//gcd in O(log(a))
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/
/*
int gcd, x, y;

void extendedEuclid (int a, int b)
{
    if (b==0)
    {
        x=1;
        y=0;
        gcd=a;
        return;
    }
    extendedEuclid(b, a%b);
    int x1=y;
    int y1=x-(a/b)*y;
    x=x1;
    y=y1;
}

int nCr (int n, int r)
{
    int p=1, k=1, modInv;
    if (n-r<r)
        r=n-r;
    if (r!=0)
    {
        while (r)
        {
            p=(p*n)%MOD;
            k*=r;
            n--;
            r--;
        }
        extendedEuclid(k, MOD);
        modInv=(x+MOD)%MOD;
        p=(p*modInv)%MOD;
    }
    else
        p=1;
    return p;
}
*/
int memo[100001];
int32_t main(void)
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int arr[n+1];
        for(int i=1;i<=n;i++)
            cin>>arr[i];
        memo[1]=0;
        memo[2]=abs(arr[2]-arr[1]);
        for(int i=3;i<=n;i++)
        {
            int ans=MOD;
            for(int j=max((int)1,i-k);j<i;j++)
            {
                ans=min(ans,memo[j]+abs(arr[i]-arr[j]));
            }
            memo[i]=ans;
        }
        cout<<memo[n]<<endl;






    }
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define eps 1e-9
#define MAX_N 5000

int par[MAX_N];
int val[MAX_N];
int Rank[MAX_N];

void init(int n){
    rep(i,n){
        par[i]=i;
        Rank[i]=0;
    }
}

int find(int x){
    if(par[x]==x) {
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    
    if(Rank[x]<Rank[y]){
        par[x]=y;
        val[y]=min(val[x],val[y]);
    }else{
        par[y]=x;
        val[x]=min(val[x],val[y]);
        if(Rank[x]==Rank[y])Rank[x]++;
    }
}

int main(){
    int n;
    cin>>n;
    int c=0;
    vector<string> v;
    map<string,int> hash;
    rep(i,n){
        string s;
        int a;
        cin>>s>>a;
        v.pb(s);
        val[i]=a;
        hash[s]=c;
        c++;
    }
    int m;
    init(n);
    cin>>m;
    rep(i,m){
        string a,b;
        cin>>a>>b;
        unite(hash[a],hash[b]);
    }
    int sum=0;
    rep(i,n){
        sum+=val[find(hash[v[i]])];
    }
    cout<<sum<<endl;
    
//    rep(i,n){
//        cout<<v[i]<<" "<<find(hash[v[i]])<<endl;
//    }
}

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

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    char ch;
    cin>>a>>ch>>b;

    if(ch == '+'){
        cout<<a+b<<endl;
    }
    else
    {
        cout<<a-b<<endl;
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long long int count = 0;

    for (int i = 0; i <= n; i++) {
        if (i % 15 == 0 || i % 5 == 0 || i % 3 == 0)
            continue;
        else 
            count += i; 
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
double n,ans;
int main()
{
	cin>>n;
	ans=n/3.000000000000;
	printf("%.12lf",ans*ans*ans);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if (l[i]+l[j]>l[k])&(l[i]+l[k]>l[j])&(l[k]+l[j]>l[i])&(l[i]!=l[j])&(l[i]!=l[k])&(l[k]!=l[j]):
                cnt += 1
print(cnt)

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


int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    char buf[100000];
    sprintf(buf, "%d%d", a, b);
    int x;
    sscanf(buf, "%d", &x);
    int root = (int)sqrt(x);
    if(root * root == x) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	if(a.size()==b.size())
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<a[i]<<b[i];
		}
		
	}
	else
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<a[i];
			if(i<b.size())
			{
				cout<<b[i];
			}
		}
	}
}

Measured memory_bytes: 3568
"""
上半分を真っ黒、下半分を真っ白に塗る

その後、境界線に触れないように黒の内部に縦横1つおきに白マスを足していく。
同様に白の内部に黒マスを足していく。
ざっと50*100/(2*2) = 1250 個は置けるので、500個は構成できる！
"""

white, black = list(map(int, input().split()))

print("50 100")

n_col = 100
for row_i in range(25):
	if row_i % 2 == 0:
		print("#" * n_col)
	else:
		if white > 1:
			white_in_row = min(49, white - 1) 
			print("#." * white_in_row + "#" * (n_col - 2 * white_in_row))
			white -= white_in_row
		else:
			print("#" * n_col)

for row_i in range(25):
	if row_i % 2 == 0:
		print("." * n_col)
	else:
		if black > 1:
			black_in_row = min(49, black - 1) 
			print(".#" * black_in_row + "." * (n_col - 2 * black_in_row))
			black -= black_in_row
		else:
			print("." * n_col)


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

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

int W, H, maze[64][64];
bool visited[64][64];

bool check(int x, int y){
	return x >= 0 && x < W && y >= 0 && y < H && maze[y][x] == 1 && !visited[y][x];
}

void dfs(int x, int y){
	visited[y][x] = true;
	
	for(int i = 0; i < 8; ++i){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(check(nx, ny)){
			dfs(nx, ny);
		}
	}
	return;
}

int main() {
	while(cin >> W >> H && (W || H)){
		memset(visited, 0, sizeof(visited));
		
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				scanf("%d", &maze[i][j]);
			}
		}
		int ans = 0;
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				if(maze[i][j] == 1 && !visited[i][j]){
					ans++;
					dfs(j, i);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1364
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 998244353;
const double eps = DBL_EPSILON;

map<int, int> cnt;
vector<int> g[201000];

void go(int v, int n) {
    vector<bool> used(n + 1);
    vector<int> d(n + 1);
    queue<int> q;
    q.push(v);
    used[v] = true;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        for (int i : g[cur]) {
            if (!used[i]) {
                used[i] = true;
                d[i] = d[cur] + 1;
                q.push(i);
            }
        }
    }
    for (int& i : d) cnt[i]++;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    int n, x, y;
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[y].push_back(x);
    g[x].push_back(y);
    for (int i = 1; i <= n; i++) go(i, n);
    for (int i = 1; i < n; i++) cout << cnt[i] / 2 << "\n";
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  for(int i=0;i<n;i++)
    for(int j=0;j<d;j++)
      cin>>x.at(i).at(j);
  int c=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int e=0;
      for(int k=0;k<d;k++)
        e+=(x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      for(int k=0;k*k<=e;k++)
        if(k*k==e)
          c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256