akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    let mut right = 0;
    let mut sum = 0;
    for left in 0..n {
        while right < n && sum ^ v[right] == sum + v[right] {
            sum ^= v[right];
            right += 1;
        }

        ans += right - left;

        if right == left {
            right += 1;
        }  else {
            sum -= v[left];
        }
    }
    println!("{}", ans);
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	vector<pair<ll,ll> > v;
	for (int i = 0; i < n; ++i){
		ll a,b;
		cin>>a>>b;
		v.pb(make_pair(b,a));
	}

	sort(all(v));


	ll time=0;
	for (int i = 0; i < n; ++i){
		time+=v[i].second;
		if(time>v[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;


	return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, q;
	int array[100001] = { 0 };
	long tmp_sum;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		array[a]++;
		tmp_sum += a;
	}
	scanf("%d", &q);
	long *sum;
	sum = (long *)malloc(sizeof(long) * q);
	for(int j=0; j<q; j++){
		int b;
		int c;
		scanf("%d", &b);
		scanf("%d", &c);
		tmp_sum += (c-b)*array[b];
		sum[j] = tmp_sum;
		array[c] += array[b];
		array[b] = 0;
	}
	for(int k=0; k<q; k++){
		printf("%ld\n", sum[k]);
	}
	return 0;
}

Measured memory_bytes: 2888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
ll N, M;
int t[210000];
int d[210000];
int main(){
   cin >> N >> M;
   REP(i,N) cin >> t[i];
   REP(i,N-1) d[i] = t[i+1] - t[i];
   ll ans = M + t[N-1];
   REP(i,N-1){
       if(M < d[i]) ans -= d[i] - M;
   }
   cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

input()
x = list(map(int,sys.stdin.readline().split()))
input()
a = tuple(map(int,sys.stdin.readline().split()))
for i in range(len(a)):
    idx = a[i] - 1
    # print(idx, x[idx])
    if x[idx] == 2019:
        pass
    elif idx+1 == len(x):
        x[idx] += 1
    elif x[idx]+1 != x[idx+1]:
        x[idx] += 1

for i in x:
    print(i)


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

string s;
int l;

int main() {
    cin >> s;
    l = s.size();
    int res = INT_MAX;
    REP(i,l){
        if(s[i]!=s[i+1]){
            res = min(max(i+1,l-i-1),res);
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

const lim = 1e5

func main() {
	ps := primes(lim)
	ss := make([]int, lim+1)
	cnt := 0
	for n := 1; n <= lim; n++ {
		if ps[n] == 0 && ps[(n+1)/2] == 0 {
			cnt++
		}
		ss[n] = cnt
	}

	var q, l, r int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		fmt.Scan(&l, &r)
		c := ss[r] - ss[l-1]
		fmt.Println(c)
	}
}

func primes(n int) []int {
	np := make([]int, n+1)
	np[0] = 1
	np[1] = 1
	for i := 2; i*i <= n; i++ {
		if np[i] == 0 {
			for j := i + i; j <= n; j += i {
				np[j] = 1
			}
		}
	}
	return np
}


Measured memory_bytes: 6328
w, h, n = map(int, input().split())

s = [[1 for j in range(w)] for i in range(h)]

for i in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        for m in range(h):
            for n in range(x):
                s[m][n] = 0
    elif a == 2:
        for m in range(h):
            for n in range(x, w):
                s[m][n] = 0
    elif a == 3:
        for m in range(y):
            for n in range(w):
                s[m][n] = 0
    elif a == 4:
        for m in range(y, h):
            for n in range(w):
                s[m][n] = 0

print(sum(map(sum, s)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  mat dp(n+1,vec(k+1));
  vec sum(k+10);
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<=k;j++) {
      sum[j+1]=(sum[j]+dp[i][j])%mod;
    }
    for(ll j=0;j<=k;j++) {
      dp[i+1][j]=(sum[j+1]-sum[max(0LL,j-a[i])]+mod)%mod;
    }
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;

    
    char pretype = s1[0]==s2[0]? 'a':'b';
    ll ans = pretype=='a'? 3:6;
    int s = pretype=='a'? 1:2;
    
    repr(i, s, n){
        if(s1[i]==s2[i]){
            if(pretype=='a'){
                ans*=2; chmod(ans);
            }
            else{
                chmod(ans); pretype='a';
            }
        }
        else{
            if(pretype=='a'){
                ans*=2; chmod(ans); pretype='b'; ++i;
            }
            else{
                ans*=3; chmod(ans); ++i;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int tinh(int n){
        return (n*(n-1))/2;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N, M;
        N = sc.nextInt();
        M = sc.nextInt();
        System.out.println(tinh(N) + tinh(M));
    }
}

Measured memory_bytes: 35644
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int cnt=0;
    for(int i=0;i<N;i++){
        if(vec[i]==vec[i+1]){
            cnt++;
        }
    }
    cout << N-cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"class UnionFind():\n"
"    def __init__(self,size):\n"
"        self.table=[-1]*size\n"
"    def root(self,x):\n"
"        while self.table[x]>=0:\n"
"            x=self.table[x]\n"
"        return x\n"
"    def unite(self,x,y):\n"
"        s1=self.root(x)\n"
"        s2=self.root(y)\n"
"        if s1!=s2:\n"
"            if self.table[s1]>self.table[s2]:\n"
"                s1,s2=s2,s1\n"
"            self.table[s1]+=self.table[s2]\n"
"            self.table[s2]=s1\n"
"        return\n"
"    def same(self,x,y):\n"
"        return self.root(x)==self.root(y)\n"
"    def size(self,x):\n"
"        return -self.table[self.root(x)]\n"
"input=open(0).readline\n"
"n,k,l=map(int,input().split())\n"
"u=UnionFind(n)\n"
"v=UnionFind(n)\n"
"for _ in range(k):\n"
"    p,q=map(int,input().split())\n"
"    u.unite(p-1,q-1)\n"
"for _ in range(l):\n"
"    r,s=map(int,input().split())\n"
"    v.unite(r-1,s-1)\n"
"d=defaultdict(int)\n"
"a=[]\n"
"for i in range(n):\n"
"    t=(u.root(i),v.root(i))\n"
"    d[t]+=1\n"
"    a.append(t)\n"
"print(*[d[i]for i in a])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 43896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
#include <stack>
#include <unordered_set>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 3e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n, m;
map<int, int> mp;
vector<int> vec[2];
int dp[16000];

bool ok2(int index, int sum) {
    int i, j;
    dp[0] = 1;
    for (i = 1; i <= sum; ++i)
        dp[i] = 0;
    for (i = 0; i < vec[index].size(); ++i) {
        int curNum = vec[index][i];
        for (j = sum; j >= curNum; --j) {
            dp[j] = dp[j] | dp[j - curNum];
        }
    }
    return dp[sum];
}

bool ok(int index, int num) {
    int sum = 0;
    for (int i = 0; i < vec[index].size(); ++i) {
        sum += vec[index][i];
    }
    if (sum == num)
        return 1;
    if (sum < num)
        return 0;
    if ((sum - num) % 2)
        return 0;
    return ok2(index, (sum - num) >> 1);
}

int main() {
    int i, j;
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    if (y < 0)
        y = -y;
    int dx = 1, dy = 0;
    if (x < 0) {
        x = -x;
        dx = -1;
    }
    i = 0;
    while (i < s.size() && s[i] == 'F') {
        ++i;
    }
    int nx = i * dx, ny = 0;
    if (i == s.size()) {
        if (nx == x && y == ny)
            cout << "Yes\n";
        else
            cout << "No\n";
        return 0;
    }

    int len = 0, index = 0;
    for(; i < s.size(); ++i) {
        if (s[i] == 'F') {
            ++len;
        }
        else {
            if (len) {
                vec[index].push_back(len);
            }
            index ^= 1;
            len = 0;
        }
    }
    if (len)
        vec[index].push_back(len);
    if (ok(0, abs(x - nx)) && ok(1, y))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

vector <int> ret;

inline void Solve(int a, int b, int c, int d, int u, int v) {
  int n = a + b, k = n / (b + 1), L = 0, R = a / k + 1, x, y;
  while (R - L > 1) {
    int mid = L + R >> 1;
    if (k * mid + (b - mid) / k <= a) {
      L = mid;
    } else {
      R = mid;
    }
  }
  x = L, y = (b - x) / k, a -= k * x + y;
  for (int i = c; i <= d; ++i) {
    if (i <= x * (k + 1)) {
      if (i % (k + 1)) {
        ret.pb(u);
      } else {
        ret.pb(v);
      }
    } else if (n - i + 1 <= y * (k + 1)) {
      if ((n - i + 1) % (k + 1)) {
        ret.pb(v);
      } else {
        ret.pb(u);
      }
    } else {
      if (i <= x * (k + 1) + a) {
        ret.pb(u);
      } else {
        ret.pb(v);
      }
    }
  }
}

int Main() {
  int a, b, c, d;
  Read(a), Read(b), Read(c), Read(d), ret.clear();
  if (a > b) {
    Solve(a, b, c, d, 0, 1);
  } else if (a < b) {
    Solve(b, a, a + b + 1 - d, a + b + 1 - c, 1, 0);
    reverse(ret.begin(), ret.end());
  } else {
    for (int i = c; i <= d; ++i) {
      ret.pb(!(i & 1));
    }
  }
  for (int i = 0; i < ret.size(); ++i) {
    putchar(ret[i] + 'A');
  }
  putchar(10);
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int T;
  for (Read(T); T; --T) {
    Main();
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x, n;
    cin >> x >> n;
    int a;
    set<int> s;
    forn(i, n) cin >> a, s.insert(a);
    forn(d, 1000) {
        if (!s.count(x - d)) {
            cout << x - d << "\n";
            return 0;
        }
        if (!s.count(x + d)) {
            cout << x + d << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define r(i,a,n) for(int i=a;i<n;i++)
int n,k[1919];
string s[1919];
vector<int>v[1919];
void dfs(int u,int d){
	r(i,0,d)cout<<'.';
	cout<<s[u]<<endl;
	r(i,0,v[u+1].size())dfs(v[u+1][i],d+1);
}
int main(){
	cin>>n;
	r(i,0,n){cin>>k[i]>>s[i];
		v[k[i]].push_back(i);
	}dfs(0,0);
}

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

long long calculate(const vector<int> &seq){
    vector<int> pos(seq.size(), 0);
    for(int i=0; i<(int)seq.size(); i++){
        pos[seq[i]-1]=i;
    }
    long long foo=0LL;
    set<int> border;
    border.insert(-1);
    border.insert(seq.size());
    for(int e=0; e<(int)seq.size(); e++){
        set<int>::iterator it=border.upper_bound(pos[e]);
        int rigLen=*it-pos[e];
        it--;
        int lefLen=pos[e]-*it;
        foo+=(e+1)*1LL*lefLen*rigLen;
        border.insert(pos[e]);
    }
    return foo;
}

int main(){
    int n;
    while(scanf("%d", &n)!=EOF){
        vector<int> a(n, 0);
        for(int i=0; i<n; i++){
            scanf("%d", &a[i]);
        }
        printf("%lld\n", calculate(a));
    }
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n;
    cin >> n;
    ll tmp = n;
    ll s = 0;
    while (n > 0){
        s += n % 10;
        n /= 10;
    }
    if(tmp % s == 0){
        print("Yes");
    }
    else{
        print("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    ll n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll cnt = 0;
    ll m = 0;
    vi d;
    vi f(200500, false);
    int tmp = 0;
    while(1){
        if(f[a[m]]){
            if(m != 0)
            rep(i, d.size()){
                if(d[i] == a[m]) tmp = i;
            }
            break;
        }
        f[a[m]] = true;
        cnt++;
        d.push_back(a[m]);
        //cout << d[cnt-1] << " ";
        m = a[m]-1;
        if(k == cnt){
            cout << d[k-1] << endl;
            return 0;
        }
    }
    d.push_back(d.at(tmp));
    rep(i, d.size()){
        //cout << d[i] << " ";
    }
    //cout << endl;
    //cout << cnt << " " << tmp << endl;
    ll ans = (k-tmp-1)%(cnt-tmp);
    //cout << ans << "  " << tmp << endl;
    //cout << cnt << " " << k% cnt << endl;
    cout << d[ans+tmp] << endl;
    return 0;
}

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

using namespace std;

int main(){
  set<string> prize;
  int N, i;
  string s;
  cin >> N;
  i=0;
  while(cin >> s){
    i++;
    prize.insert(s);
    if(i>=N){
      break;
    }
  }
  cout << prize.size() << endl;
  return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  const auto K {get_value<int>(cin)}, S {get_value<int>(cin)};
  auto res {0u};
  for (auto X {0u}; X <= K; ++X)
    for (auto Y {0u}; Y <= K; ++Y) {
      const auto Z = S - X - Y;
      if (0 <= Z && Z <= K)
        ++res;
    }

  cout << res << '\n';
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
    a = list(map(int, input().split()))
    for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1

ans = 0
for c in cnt:
    if c == n:
        ans += 1
print(ans)


Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,k;
  cin >> n >> k;
  
  vector<int> cont(n);
  
  for(int i = 0 ; i < n ; i++){
    cin >> cont.at(i);
  }
  
  int mnum = min(n,k);
  
  int64_t ans = 0;
  
  for(int i = 0 ; i <= mnum ; i++){
    for(int j = 0 ; j <= i ; j++){
      int a = j;
      int b = i - j;
      
      int64_t active = 0;
      
      vector<int> cnt(0); 
      
      for(int s = 0 ; s < a ; s++){
        active += cont.at(s);
        cnt.push_back( cont.at(s) );
      }
      

      ///問題点
      for(int s = n-1 ; s > n-1-b ; s--){
        active += cont.at(s);
        cnt.push_back( cont.at(s) );
      }
      ///問題点
      sort(cnt.begin() , cnt.end());
      
      for(int s = 0 ; s < k-i ; s++){
        if(s >= i){
          break;
        }
        if(cnt.at(s) < 0){
          active -= cnt.at(s);
        }
        else{
          break;
        }
      }
      
      ans = max(ans,active);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{	
	int n;
	cin >> n;
	cout << n * n * n;

}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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


int main() {
    //input
    int n;
    std::cin >> n;

    string str;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for (int i = n-2; i >= 0; i--) {
        if(h[i] - h[i+1] > 1){
            cout << "No";
            return 0;
        }else if (h[i] - h[i+1] == 1) {
            h[i]--;
        }
    }


    cout << "Yes";
    //std::cout << ans << std::endl;
    //for (int i=0;i<n;i++){
    //    std::cout << vec.at(i) << std::endl;
    //}


    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int c[22][22];
int dp[2][1<<19];
int trs[1<<19][19];
int lowbit(int x)
{
	return x&(-x);
}
int main()
{
	int n,m,k,a,b,cc;
	int now=0,to=1;
	int ans=0,nn;
	scanf("%d%d%d",&n,&m,&k);
	memset(c,-1,sizeof(c));
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d%d",&a,&b,&cc);
		c[a][b-1]=cc;
	}
	n--;
	nn=(1<<n);
	memset(dp,0,sizeof(dp));
	for(int i=0;i<nn;i++)
		for(int j=0;j<n;j++)
			if((1<<j)&i)
				trs[i][j]=i;
			else
				trs[i][j]=i^(1<<j)^(lowbit(i>>j)<<j);
	dp[now][0]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<nn;k++)
				if(dp[now][k])
				{
					if((!(k&(1<<j)))&&c[i][j]!=1)
						(dp[to][k]+=dp[now][k])%=mod;
					if(c[i][j]!=0)
						(dp[to][trs[k][j]]+=dp[now][k])%=mod;
					dp[now][k]=0;
				}
			swap(now,to);
		}
	for(int i=0;i<nn;i++)
		(ans+=dp[now][i])%=mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 43392
#include<iostream>
#include<vector>
using namespace std;
int f[110][11];
int p[110][11];
int earn[1024]={};
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
for(int i=1;i<=n;i++){
    for(int j=0;j<=10;j++){
        cin>>p[i][j];
    }
}
int sum;
int max=-1000000007;
for(int i=1;i<1024;i++){
    sum=0;
    vector<int> buf(n+1,0);
    for(int j=0;j<10;j++){
        if(i&(1<<j)){
            for(int k=1;k<=n;k++){
                if(f[k][j]==1)buf[k]++;
            }
        }
    }
    for(int k=1;k<=n;k++){
        sum+=p[k][buf[k]];
    }
    earn[i]=sum;
    if(max<sum)max=sum;
}
cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    REP(i, B){
            REP(j, A){
                printf("%d", 1);
            }
            REP(j, W-A){
                printf("%d", 0);
            }
            printf("\n");
    }
    REP(i, H-B){
            REP(j, A){
                printf("%d", 0);
            }
            REP(j, W-A){
                printf("%d", 1);
            }
            printf("\n");
    }

    return 0;
}


Measured memory_bytes: 1280
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	iostream::sync_with_stdio(false);
	while (true) {
		string s;
		cin >> s;
		if (s == "#") return 0;
		vector<string> ans;
		for (int i = 0; i < (1 << (s.length())); ++i) {
			string b;
			int ok = 1;
			int gone[27] = {};
			gone[0] = 1;
			REP(q, s.length()) {
				if (((1 << q) & i) != 0) {
					if (s[q] == 'z') {
						ok = 0;
						break;
					}
					if (gone[s[q]+1 - 'a'] == 1) {
						ok = 0;
						break;
					}
					gone[s[q]+1 - 'a'] = 1;
					b.push_back(s[q] + 1);
				}
				else {
					if (gone[s[q] - 'a'] == 0) {
						ok = 0;
						break;
					}
					b.push_back(s[q]);
				}
			}
			if (ok == 0)continue;
			ans.push_back(b);
		}
		if (ans.size() == 0) {
			cout << 0 << endl;
		}
		else {
			cout << ans.size() << endl;
			sort(ans.begin(), ans.end());
			if (ans.size() > 10) {
				for (int j = 0; j < 5; ++j) {
					cout << ans[j] << endl;
				}
				for (int j = 0; j < 5; ++j) {
					cout << ans[ans.size() - 5 + j] << endl;
				}
			}
			else {
				REP(j, ans.size()) {
					cout << ans[j] << endl;
				}
			}
		}
	}
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{

    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> students(n);
    vector<pair<ll, ll>> checkpoints(m);
    rep(i, n)
    {
        cin >> students[i].first >> students[i].second;
    }
    rep(i, m)
    {
        cin >> checkpoints[i].first >> checkpoints[i].second;
    }
    rep(i, n)
    {
        ll mindist = (1ll << 60);
        int ans = -1;
        rep(j, m)
        {
            ll curdist = labs(students[i].first - checkpoints[j].first) + labs(students[i].second - checkpoints[j].second);
            //cerr << i << " " << j << " " << curdist << endl;
            if (curdist < mindist)
            {
                mindist = curdist;
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
from math import floor,ceil
S = 'g'*ceil(n/2)+'p'*floor(n/2)
ans = 0
for i in range(len(s)):
    if s[i]=='g' and S[i]=='p':
        ans += 1
    elif s[i]=='p' and S[i]=='g':
        ans -= 1
print(ans)

Measured memory_bytes: 3316
n = int(input())
s1 = input()
s2 = input()
if s1[0] == s2[0]:
    preState = 0
    ans = 3
    index = 1
else:
    preState = 1
    ans = 6
    index = 2
while index < n:
    if s1[index] == s2[index]:
        if preState == 0:
            ans *= 2
        else:
            pass
        preState = 0
        index += 1

    else:
        if preState == 0:
            ans *= 2
        else:
            ans *= 3
        preState = 1
        index += 2
print(ans % 1000000007)

Measured memory_bytes: 3064
package main

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

func solve(ss []string) map[string]int {
  result := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

  for _, s := range ss {
    result[s] += 1
  }

  return result
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line1 := scanner.Text()

	n, _ := strconv.Atoi(line1)
  ss := make([]string, 0, n)
  for i := 0; i < n; i++ {
    scanner.Scan()
    l := scanner.Text()
    ss = append(ss, l)
  }

  result := solve(ss)

  fmt.Printf("AC x %d\n", result["AC"])
  fmt.Printf("WA x %d\n", result["WA"])
  fmt.Printf("TLE x %d\n", result["TLE"])
  fmt.Printf("RE x %d\n", result["RE"])
}


Measured memory_bytes: 3708
IDENTIFICATION DIVISION.
      PROGRAM-ID. 045A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 A PIC 9(3).
      01 B PIC 9(3).
      01 H PIC 9(3).
      01 ANS PIC 9(9).
      01 ANSS PIC Z(9).
      
      PROCEDURE DIVISION.
      ACCEPT A .
      ACCEPT B .
      ACCEPT H .
            
      COMPUTE ANS = ( A + B ) * H / 2.
      MOVE ANS TO ANSS.
      DISPLAY ANSS.
      
      STOP RUN.

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

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

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

	a, b := readInt64(), readInt64()

	for k := 1; k <= 10000; k++ {
		if floor(float64(k)*0.08) == a && floor(float64(k)*0.1) == b {
			fmt.Printf("%d\n", k)
			return
		}
	}
	fmt.Println("-1")
}

func floor(a float64) int64 {
	return int64(a)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++){
    int l,r;
    cin >> l >> r;
    count += r - l + 1;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>D(N);
    vector<int>cnt(13);
    for(int i = 0; i < N; i++) {
        cin >> D[i];
        cnt[D[i]]++;
    }
    int ans = 0;
    int sum = INF;
    vector<int>cnt2;
    vector<int>cnt3;
    cnt[0]++;
    for(int i = 0; i <= 12; i++) {
        if(cnt[i] == 1) {
            cnt2.push_back(i);
        }
        if(cnt[i] >= 2) {
            sum = min(sum,min(abs((24-i)-i),24-abs((24-i)-i)));
            cnt3.push_back(i);
            cnt3.push_back(24-i);
        }
        if(cnt[i] >= 3) {
            cout << 0 << endl;
            return 0;
        }
    }
    int n = cnt2.size();
    for(int i = 0; i < (1 << n); i++) {
        int res = INF;
        vector<int>res2(n,0);
        for(int j = 0; j < n; j++) {
            if(1 & (i >> j)) {
                res2[j] = cnt2[j];
            }
            else {
                res2[j] = 24-cnt2[j];
            }
        }
        for(int j = 0; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                res = min(res,min(abs(res2[j]-res2[k]),24-abs(res2[j]-res2[k])));
            }
        }
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < cnt3.size(); k++) {
                res = min(res,min(abs(res2[j]-cnt3[k]),24-abs(res2[j]-cnt3[k])));
            }
        }
        if(sum != INF) {
            res = min(res,sum);
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, a;

int main(){
    vector<int> h;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        h.push_back(a);
    }

    sort(h.begin(), h.end());

    cout << h[n-1] - h[0];

}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
import copy
n = int(input())
X = [0]+[int(i) for i in input().split()]
Copy = copy.deepcopy(X)

X.sort()
index_right = int(n/2+1)
index_left = index_right-1
key_r = X[index_right]
key_l = X[index_left]

for i in range(1,n+1):
    if Copy[i] <= key_l:
        print(key_r)
    else:
        print(key_l)

Measured memory_bytes: 26724
#include<cstdio>
using namespace std;
#define N 2005
#define mod 1000000007
int dp[N][N],su[N][N],n,k;
int pw(int a,int p){if(p<0)return 1;int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d%d",&n,&k);
	dp[n-1][0]=1;
	for(int i=n-1;i>=0;i--)
	for(int j=0;j<n;j++)
	{
		dp[i][j]=(dp[i][j]+su[i+1][j-1])%mod;
		if(i)if(n<=i+j&&j)dp[i-1][j]=(dp[i-1][j]+dp[i][j])%mod;
		su[i][j]=(su[i][j-1]+dp[i][j])%mod;
	}
	int as=0;
	for(int i=0;i<=n;i++)
	as=(as+1ll*dp[n-k][i]*pw(2,n-k-1))%mod;
	printf("%d\n",as);
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

ll n, a, b;

int main() {
	scanf("%lld%lld%lld", &n, &a, &b);
	ll ans = -1;
	if (!((b - a) & 1)) {
		ans = (b - a) >> 1;
	} else {
		ans = min(a, n - b + 1) + ((b - a - 1) >> 1);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;



int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll ans = 0;
    rep(i,n-1){
        ll p = a[i]/2;
        ans += p;
        a[i] -= p*2;
        ll k = min(a[i],a[i+1]);
        ans += k;
        a[i]-=k;
        a[i+1]-=k;
    }
    ans += a[n-1]/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
//string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

using mint = modint998244353;

struct S {
	mint x;
	int n;
	//S(int _x = 0, int _n = 0) : x(_x), n(_n){}
};

struct F {
	mint a, b;
	//F(mint _a = 1, mint _b = 0) : a(_a), b(_b){}
};

S op(S s, S t){
	return S{s.x + t.x, s.n + t.n};
}

S e(){ return S{0, 0}; }

S mapping(F f, S s){
	return S{f.a * s.x + f.b * s.n, s.n};
}

F composition(F f, F g){
	return F{f.a * g.a, f.a * g.b + f.b};
}

F id(){ return F{1, 0}; }

int main() {
	cin>>N>>Q;
	vector<S> a(N);
	rep(i, N){
		cin>>A;
		a[i] = S{A, 1};
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	rep(_, Q){
		int t, l, r, b, c;
		cin>>t>>l>>r;
		if(t == 0){
			cin>>b>>c;
			seg.apply(l, r, F{b, c});
		}else{
			cout<<seg.prod(l, r).x.val()<<endl;
		}
	}
}


Measured memory_bytes: 19336
#include<stdio.h> 
int main()
{
    int a,b,sol;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?') break;
        else if(op=='+'){printf("%d\n",a+b);}
        else if(op=='-'){printf("%d\n",a-b);}
        else if(op=='*'){printf("%d\n",a*b);}
        else if(op=='/'){printf("%d\n",a/b);}
        else {break;}
    }
    return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	int n;cin>>n;
	int ten=1,nine=1,eight=1;
	for(int i=1;i<=n;i++){
		ten=(ten*10)%MOD;
		nine=(nine*9)%MOD;
		eight=(eight*8)%MOD;
	}
	int val=(ten-nine*2+eight)%MOD;
	if(val<0ll) val+=MOD;
	cout<<val<<endl;
	return 0;
}

Measured memory_bytes: 3644
N=int(input())
if N==2:
  print(1)
  exit()
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

    # divisors.sort()
  return divisors
#N-1の約数(1は除く)　Nそのもの
#2
d=make_divisors(N-1)
if not 2 in d:
  d.append(2)
#print(d)
d2=make_divisors(N)
#print(len(d))
for i in d2:
  if i!=N and i!=1 and i not in d:
    now=N
    while now%i==0:
      now/=i
    if now%i==1:
      d.append(i)
print(len(d))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n;
int A[maxn];
map<int,int> mp;
vector<int> ids,toe;
bool check(int ans)
{
	mp.clear();
//	cout<<ans<<endl;
	for(int i=0;i<ids.size();i++)
	{
//		cout<<i<<endl;
		int pos=A[ids[i]];
		toe.clear();
		for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		{
			if(it->first>pos)toe.push_back(it->first);
		}
		for(int j=0;j<toe.size();j++)
			mp.erase(toe[j]);
		while(pos>=1&&mp.count(pos)&&mp[pos]+1>=ans)pos--;
		if(pos<1)pos=1;
		mp[pos]++;
		if(mp[pos]>=ans)return 0;
		toe.clear();
		for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		{
			if(it->first>pos)toe.push_back(it->first);
		}
		for(int j=0;j<toe.size();j++)
			mp.erase(toe[j]);
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		if(i&&A[i]<=A[i-1])
			ids.push_back(i);
	}
	int l=0,r=n;
//	cout<<ids.size()<<endl;
	while(r-l>1)
	{
		int mid=(l+r)/2;
		if(check(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2168
import Data.Array.IO
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  arr <- newArray (1, n) 0 :: IO (IOArray Int Int)
  forM_ [1..n] $ \i -> do
    a <- readLn :: IO Int
    writeArray arr i a

  cnt <- loop 1 0 n arr
  print cnt

loop :: Int -> Int -> Int -> IOArray Int Int -> IO Int
loop 2 cnt _ _ = return cnt
loop i cnt n arr
  | cnt == n + 1 = return (-1)
  | otherwise = do
      a <- readArray arr i
      loop a (cnt + 1) n arr


Measured memory_bytes: 27004
N=int(input())
input_seisu=input()

temp=input_seisu.split(" ")
seisu = [int(s) for s in temp]

i = 0
exec_con=0
rerun_flg=True

while(rerun_flg == True):
    for atai in seisu:
        if atai % 2 == 0:
            seisu[i]= atai / 2
            i+=1
        ##奇数
        else:
            rerun_flg=False
            break
    if N == i:
        exec_con+=1
        i=0

print("{}".format(exec_con))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

//#include<bits/stdc++.h>

// #include "beginner_138/beginner_138.h"
// Still dunno how to put linker 

using namespace std; 



void a_sol01(){
    int n ;
    cin >> n;

    // Possible passwords..?
    // Permutation problem.
    int ans = n * n * n;
    cout << ans;
}

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

    a_sol01();
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

//input
int main(void)
{
    lli K, S;
    cin >> K >> S;
    lli cnt = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            if (0 <= S - x - y && S - x - y <= K)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
一番近いろうそくに火を付ける？
-1 100 101 102
-101 -100 -1 99 100

一番狭い区間に火を付ける？
10 13 16 100 101 102

いずれにせよ、連続したk個のろうそくに火を付けるので、
連続したk個のろうそくに火を付ける為に必要なコストを計算する
区間が0を含んでいなければ、最も遠いろうそくまでの距離
0を含んでいれば、[-p,0][0,q]とし、
min(2*p+q,p+2*q)
*/

void solve(){
    ll n;
    ll k;
    cin >> n >> k;
    ll x[n+10];
    rep(i,n){
        cin >> x[i];
    }
    ll ans = INF;
    for(ll i=k-1; i<n; i++){
        ll cost=0;
        //区間 x[i-k+1], x[i-k+2], ..., x[i]
        if(x[i]<=0){
            cost = -x[i-k+1];
        }
        else if(x[i-k+1]>=0){
            cost = x[i];
        }
        else{
            ll p=-x[i-k+1];
            ll q=x[i];
            cost = min(2*p+q, p+2*q);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 1024
#include<cstdio>
#include<string>
#include<iostream>
#include<set>
using namespace std;

set<string> gift;

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

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        gift.insert(s);
    }

    int ans = gift.size();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19288
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, X, T, res;
    std::cin >> N >> X >> T;

    if(N % X == 0)
    {
        print((int)(N/X)*T);
    }
    else
    {
        print((int)(N/X)*T + T);
    }

    return 0;
}

Measured memory_bytes: 3632
from heapq import heappop, heappush

INF = 1000000
N, M = map(int, input().split())
d = [INF]*(N+1)
d[1] = 0
prev = [0]*(N+1)
G = {}
for i in range(M):
  a, b = map(int, input().split())
  try:
    G[a].append(b)
  except:
    G[a] = [b]
  try:
    G[b].append(a)
  except:
    G[b] = [a]

que = []
heappush(que, (0, 1))
    
while True:
  if len(que) == 0:
    break
  p = heappop(que)
  v = p[1]
  
  for u in G[v]:
    if (d[u] > d[v] + 1):
      d[u] = d[v] + 1
      heappush(que, (d[u], u))
      prev[u] = v
      
if 0 in prev[2:]:print('No')
else:
  print('Yes')
  for i in range(2, N+1):
    print(prev[i])

Measured memory_bytes: 44208
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
void solve(ll k){
	ll c=0,r,s,i;
	priority_queue <ll,vector <ll>,greater<ll> > p;
	for(i=1;i<=9;++i){
		p.push(i);
	}
	while(true){
		s=p.top();
		p.pop();
		c++;
		if(c==k){
			cout<<s;
			break;
		}
		r=s%10;
		p.push(s*10+r);
		if(r!=0){
			p.push(s*10+r-1);
		}
		if(r!=9){
			p.push(s*10+r+1);
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k;
    cin>>k;
    solve(k);
}

Measured memory_bytes: 2420
#include<iostream>
#include<fstream>

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1154&lang=jp


using namespace std;


ifstream fin;
ofstream fout;

int main(){

	fin.open("input.ans");
	fout.open("output.txt");

	int n;			//input
	int a[2];		//月曜土曜素因数
	int b[300] = {};		//因数記憶
	int j = 0;
	bool isPrime = true;

	while (true){
		cin >> n;

		//初期化
		a[0] = 6;
		a[1] = 8;
		b[0] = 3;
		j = 0;

		if (n == 1)break;

		cout << n << ':';
		//fout << n << ':';

		while (a[0] <= n / 6){
			for (int k = 0; k < 2; k++){

				isPrime = true;

				if (n%a[k] == 0){
					for (int m = 0; m < j; m++)
						if (a[k] % b[m] == 0)isPrime = false;
					if (isPrime == true){
						cout << ' ' << a[k];
					//	fout << ' ' << a[k];
						b[j] = a[k];
//					//	cout << " b[" << j << "]= " << b[j] << endl;
						j++;
					}
				}
				a[k] += 7;
//				for (int m = 0; m < j; m++)
//					if (a[k] % b[m] == 0)a[k] += 7;

			}
		}

		if (b[0] == 3){
			cout << ' ' << n;
		//	fout << ' ' << n;
		}
		cout << endl;
		//fout << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 300000;

vector<int> msprimes;
bool isprime[MAXN + 1];

void seive(){
    for(int i=0;i<=MAXN;i++) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i=2;i<=MAXN;i++){
        if(i %7 != 1 && i %7 != 6) continue;
        if(isprime[i]){
            msprimes.push_back(i);
            for(int j=2*i;j<=MAXN;j+=i) isprime[j] = false;
        }
    }
}

void solve(int x){
    printf("%d:", x);
    for(int p: msprimes){
        if(p > x) break;
        if(x %p == 0){
            printf(" %d", p);
        }
    }
    printf("\n");
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    // get Monday-Saturday Primes
    seive();
    // for(int p: msprimes) cout << p << endl;
    while(1){
        int x; cin >> x;
        if(x == 1) break;
        solve(x);
    }
}


Measured memory_bytes: 3524
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n=int(input())
soin=factorization(n)
minus=factorization(n-1)

ans=0
tmp=1
for i in range(len(minus)):
    if minus[i][0]!=1:
        tmp*=minus[i][1]+1
tmp-=1
ans+=tmp

lst=make_divisors(n)
for i in lst:
    if i==1:
        continue
    tmp=n
    while tmp%i==0:
        tmp//=i
    if tmp%i==1:
        ans+=1
print(ans)

Measured memory_bytes: 66540