akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     string s;
     cin>>s;
     int n=s.length();
     for(int i=0;i+1<n;++i)
     {
     	    if(s[i]==s[i+1])
     	    {
     	    	 cout<<i+1<<" "<<i+2<<endl;
     	    	 return 0;
     	    }
     	    if(i+2<n)
     	    {
     	    	   if(s[i]==s[i+2])
     	    	   {
     	    	   	   cout<<i+1<<" "<<i+3<<endl;
     	    	   	   return 0;
     	    	   }
     	    }
     }
     cout<<"-1 -1"<<endl;
     time();
     return 0;
}

Measured memory_bytes: 512
s = input()
f = 0
for i in range(len(s)):
    if i%2 == 0: # odd
        if s[i] == "L":
            f = 1
    else: # even
        if s[i] == "R":
            f = 1
if f == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    int n;
    std::cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        if(tmp1 == tmp2) ++cnt;
        else cnt = 0;
        if(3 == cnt){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define N 100

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

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

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

int main(){
    ll n;
    cin>>n;
    ll ans=0;

    vector<pair<ll,ll>> g;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(i!=1){
                ll res=i;
                while(n%res==0){
                    res*=i;
                }
                g.pb({i,res/i});
            }
            if(i*i!=n) g.pb({n/i,n/i});
        }
    }

    for(ll i=1;i<=sqrt(n-1);i++){
        if((n-1)%i==0){
            ans+=2;
            if(i*i==(n-1)) ans--;
        }
    }
    ans--;

    rep(i,g.size()){
        ll x=n/g[i].second;
        ll y=g[i].first;
        if(x%y==1) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3684
def c_peaks():
    N, M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    Roads = [[int(i) for i in input().split()] for j in range(M)]

    graph = [[] for _ in range(N)]
    for a, b in Roads:
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    ans = 0
    for v, neighbor in enumerate(graph):
        if not neighbor:
            ans += 1
            continue

        height = H[v]
        for to in neighbor:
            if height <= H[to]:
                break
        else:
            ans += 1
    return ans

print(c_peaks())

Measured memory_bytes: 106152
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx*dx+dy*dy, 0.5);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];

	vector<int> v;
	int factorial = 1;
	for (int i = 1; i <= n; i++) {
		v.pb(i);
		factorial *= i;
	}

	double ans = 0;
	do {
		for (int i = 0; i < n-1; i++) ans += dist(v[i], v[i+1]);
	} while (next_permutation(ALL(v)));

	ans /= factorial;

	printf("%8lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ret = max(A + B, A - B, A * B)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int main(void) {
	char P[101], S[101];
	int i, c;
	
	scanf("%s%s", P, S);
	
	for(i = 0; strlen(P) > i; i++){
		int f = 0;
		for(c = 0; strlen(S) > c; c++){
			if(P[(i+c)%strlen(P)] != S[c]){
				f = 1;
				break;
			}
		}
		if(f == 0){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int y = 0;
  // ここにプログラムを追記
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if (s == "Y")
      y++;    
  }
  if (y > 0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

void solve()
{
	string s;
	cin >> s;
	if (s[s.length() - 1] == 's')cout << s + "es" << endl;
	else cout << s + "s" << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

int main() {
  string S,T;
  cin>>S>>T;
  bool ans=false;
  for(int i=0;i<S.size();i++){
    if(S==T){
      ans=true;
      break;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  if(ans){
    cout<<"Yes"<< endl;
  }
  else{
    cout<<"No"<< endl;
  }
}

Measured memory_bytes: 256
n , m , c = map(int , input().strip().split())
b = list(map(int, input().strip().split()))
a = [list(map(int, input().split())) for _ in range(n)]
count = 0

for i in a:
  total = 0
  for j in range(m):
    total += i[j] * b[j]
  if total > -c:
    count += 1

print(count)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int MAXN=int(1e2+5);
int n,k;
char s[MAXN],t[MAXN];
int main()
{
    scanf("%s%d",s+1,&k);
    n=strlen(s+1);
    s[0]='*';
    bool f=0;
    for(int i=2;i<=n;i++)
        if(s[i]!=s[i-1]) {
            f=1;
            break;
        }
    if(!f) {
        printf("%lld",(LL)n*k/2);
        return 0;
    }
    memcpy(t,s,sizeof(s));
    LL cnt=0,ans=0;
    for(int i=1;i<=n;i++)
        if(s[i]==s[i-1])
            s[i]='.',cnt++;
    if(s[1]!=s[n]) {
        printf("%lld",cnt*k);
        return 0;
    }
    ans=cnt*k+k-1,cnt=0;
    t[1]='.',cnt++;
    for(int i=2;i<=n;i++)
        if(t[i]==t[i-1])
            t[i]='.',cnt++;
    printf("%lld",min(ans,cnt*k));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(n) ((n + 1LL) * (n) / 2)
using namespace std;
const int mod = 1e9 + 7;
int main() {
    int n, k; cin >> n >> k;
    long long ans = 1;
    for (int i = k; i <= n; i++) 
        ans = (ans + f(n) - f(n - i) - f(i - 1) + 1) % mod;
    cout << ans;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/


const int MAX = 1000;
const int VMAX = 10000;

int n, A[MAX], s; // s 全体の中での最小値
int B[MAX], T[VMAX+1];

int solve(){
    int ans = 0;

    bool seen[MAX];
    for(int i=0; i<n; ++i){
        B[i] = A[i];
        seen[i] = false;
    }
    sort(B, B+n);
    for(int i=0; i<n; ++i) T[B[i]] = i;
    for(int i=0; i<n; ++i){
        if(seen[i]) continue;

        int cur = i;
        int S = 0; // S:= サイクル内の重さの和
        int m = VMAX; // m := サイクル内の重さの最小値
        int an = 0; // an := サイクルの要素数

        while(1){
            seen[cur] = true;
            ++an;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if(seen[cur]) break;
        }

        ans += min(S+(an-2)*m, m+S+(an+1)*s);
    }

    return ans;
}

int main(){
    cin >> n;
    s = VMAX;
    for(int i=0; i<n; ++i){
        cin >> A[i];
        s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << endl;
}


Measured memory_bytes: 3172
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;


int main(void) {
	int n;
	cin >> n;
	if (n % 2 != 0) {
		cout << "No" << endl;
	}
	else {
		string s;
		cin >> s;

		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[i + n / 2]) {
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	return 0;
}


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

int main() {
	string S; cin >> S;
	bool T = true;
	for (int i = 0; i < S.size()-1; i++)
	{
		for (int j = i+1; j < S.size(); j++)
		{
			if (S[i] == S[j]) {
				T = false;
				break;
			}
		}
	}
	if (T)cout << "yes";
	else cout << "no";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

judge = True
ans = 1

if 0 in a:
  print(0)
else:
  for i in range(n):
    ans *= a[i]
    if ans>10**18:
      judge = False
      break

  if judge:
    print(ans)
  else:
    print(-1)

Measured memory_bytes: 21632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}
///////////////////////////

ll beki(ll n) {
	if (n == 0) { return 1; }
	return 2 * beki(n - 1);
}

ll one(ll n, ll i) {
	ll zero = (n / beki(i + 1))*beki(i) + min(beki(i), n%beki(i + 1));
	return n - zero;
}

int main() {

	ll A, B;
	cin >> A >> B;

	ll ans = 0;

	rep(i, 50) {
		if ((one(B+1, i) - one(A,i)) % 2 == 1) { ans += beki(i); }
	}

	cout << ans;


	
	system("PAUSE");
}

Measured memory_bytes: 504
// https://atcoder.jp/contests/abc139/tasks/abc139_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        s: chars, t: chars
    };
    let a = s.into_iter().zip(t.into_iter()).filter(|w| w.0 == w.1).collect::<Vec<_>>().len();

    println!("{}", a);
}


Measured memory_bytes: 4352
#include <stdio.h>
 
int main()
{
  int n, a, b;
  int i, j, high, mid, x, y, z;
  int m;
  int max = -1;
  int low = 1;
  int h[100001] = {};
  scanf("%d %d %d", &n, &a, &b);
 
  for(i=0; i<n; i++)
  {
    scanf("%d", &h[i]);
    if(max < h[i])
    {
      max = h[i];
    }
  }
 
  high = max / b;
 
  while(low <= high)
  {
    mid = (low + high) / 2;
    z = 0;
    m = mid;
    for(j=0; j<n; j++)
    {
      x = h[j] - mid * b;
      if(x > 0)
      {
        y = x / (a-b);
        if(x % (a-b) != 0) y++;
        m = m - y;
          if(m < 0)
          {
            z = 1;
            break;
          }
      }
    }
    if(z == 1)
    {
      low = mid + 1;
    }
    else
    {
      high = mid - 1;
    }
  }
 
  printf("%d\n", low);
 
  return 0;
}

Measured memory_bytes: 512
import collections

n = int(input())

s=[]
for i in range(n):
    s.append(input())
    
c = collections.Counter(s)
c = sorted(c.items())
c_sorted = sorted(c, key=lambda x:x[1],reverse=True)

num=c_sorted[0][1]
for i in c_sorted:
    if num==i[1]:
        print(i[0])
    else:
        break

Measured memory_bytes: 45900
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] dishes = new int[5];
        int idx = -1;
        int max = -1;
        int sum = 0;
        int tmp ;
        for(int i=0;i<5;i++){
            tmp = Integer.parseInt(sc.next());
            if((tmp+9)/10*10-tmp > max){
                idx = i;
                max = (tmp+9)/10*10-tmp;
            }
            dishes[i] = tmp;
        }
        sc.close();
        for(int i=0;i<5;i++){
            if(i==idx){
                sum+=dishes[idx];
            }else{
                sum+=(dishes[i]+9)/10*10;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 25300
n, k = map(int, input().split())
l = [0] * n
for i in range(k):
    d = int(input())
    a = map(int, input().split())
    for j in a:
        l[j-1] += 1

counter = 0
for s in l:
    if s == 0:
        counter+=1

print(counter)

Measured memory_bytes: 9192
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n,q;

struct r_wa{
	string s; //10^6
	ll sum_a[1'000'000] = {0}; //sum array

	void trigger(ll i){//i番目では、求める和はどうなりますか?(i-1番目と比べて)
		if(i!=0)sum_a[i] += sum_a[i-1];
		if(i!=0)if(s[i]=='C'&&s[i-1]=='A')sum_a[i]++;
	}/* ↑和の条件とか */

	void set(ll size){// size := 与えられる配列の大きさ
		rep(i,size+1)sum_a[i]=0;//init
		rep(i,size)trigger(i);
	}

	ll get_sum(ll l,ll r){// 閉区間[l,r]の和
		if(l>r)swap(l,r);
		if(l==0){
			return sum_a[r];
		}else{
			return sum_a[r] - sum_a[l];
		}
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	r_wa r;
	cin>>n>>q>>r.s;
	r.set(n);
	ll lll,rrr;
	vector<Pair> v;
	rep(i,q){
		cin>>lll>>rrr;
		v.pb(mp(lll-1,rrr-1));
	}
	rep(i,q){
		cout<<r.get_sum(v[i].first,v[i].second)<<endl;
	}
	return 0;
}

Measured memory_bytes: 10432
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,x,m;
    cin>>n>>x>>m;
    //idいつ訪れたか
    vll id(m,-1);
    vll a;
    ll len=0;
    ll tot=0;
    while(id[x]==-1){
        a.push_back(x);
        id[x]=len;
        len++;
        x=x*x%m;
    }

    ll loop_sum=0;
    for(int i=id[x];i<len;i++){
        loop_sum+=a[i];
    }

    ll ans=0;
    if(n<=len){
        rep(i,n)ans+=a[i];       
    }else{
        rep(i,id[x])ans+=a[i];
        n-=id[x];
        ans+=loop_sum*(n/(len-id[x]));
        rep(j,n%(len-id[x]))ans+=a[id[x]+j];
    }

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

Measured memory_bytes: 4564
n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()

ret = []
my_s = set()

for item in a:
    if item in my_s:
        ret.append(item)
        if len(ret) == 2:
            print(ret[0] * ret[1])
            exit()
        my_s.remove(item)
    else:
        my_s.add(item)

print(0)


Measured memory_bytes: 14224
#include <stdio.h>
#include <string.h>

char s[112345];

int main()
{
	scanf("%s", s);
	if ((strlen(s) % 2 == 0) ^ (s[0] == s[strlen(s) - 1]))
	{
		printf("Second\n");
	}
	else
	{
		printf("First\n");
	}
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    int a, b;
    int result;
    for(int i = 1; i < 10000; ++i) {
        a = i * 0.08;
        b = i * 0.1;

        if(a == A && b == B) {
            result = i;
            break;
        }

        if(i == 9999) {
            result = -1;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	long double a, b;cin >> a >> b;
	cout << (ll)(a * b + 1e-9) << endl;

	return 0;
}


Measured memory_bytes: 3744
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b==c||a+c==b||b+c==a)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,W;
	int i,j;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////

int w,h;
bool m[55][55];

void dfs(int k,int l){
    
    rep(i,-1,1)rep(j,-1,1){
        int x=k+i;int y=l+j;
        if(0<=x&&x<=h-1&&0<=y&&y<=w-1&&m[x][y]){
            
            m[x][y]=false;
            dfs(x,y);
        }
    }
}


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    while(cin>>w>>h){
        if(w==0)break;
        rep(i,0,h-1)rep(j,0,w-1)cin>>m[i][j];
        int ans=0;
        rep(i,0,h-1)rep(j,0,w-1){
            if(m[i][j]){
                ans++;
                m[i][j]=false;
                dfs(i,j);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n,a,b;
    cin>>n>>a>>b;
    if(n==1)
    {
        if(a==b)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    else if(a>b)
        cout<<0<<endl;
    else
    cout<<(b-a)*(n-2)+1<<endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] S = in.next().toCharArray();
		StringBuilder sb = new StringBuilder();
		sb.append(S[0]);
		for (int i = 1; i < S.length; i++) {
			if (S[i] != sb.charAt(sb.length() - 1)) {
				sb.append(S[i]);
			}
		}
		System.out.println(sb.length() - 1);
		in.close();
	}
}

Measured memory_bytes: 28116
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

const ll mod = (ll)1e9 + 7;
int n, a, b;

ll power(ll x, ll y){
	ll ret = 1;
	while(y){
		if(y & 1){
			ret = (ret * x) % mod;
		}
		x = (x * x) % mod;
		y >>= 1;
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> a >> b;
ll sol = power(2, n);
ll dole = 1;
for(ll i = 1 ; i <= a ; ++i){
	dole = (dole * i) % mod;
}
dole = power(dole, mod - 2);
ll gore = 1;
for(ll i = n ; i > n - a ; --i){
	gore = (gore * i) % mod;
}
ll sad = (gore * dole) % mod;
sol = (sol - sad + mod) % mod;
gore = 1;
dole = 1;
for(ll i = 1 ; i <= b ; ++i){
	dole = (dole * i) % mod;
}
dole = power(dole, mod - 2);
gore = 1;
for(ll i = n ; i > n - b ; --i){
	gore = (gore * i) % mod;
}
sad = (gore * dole) % mod;
sol = (sol - sad + mod) % mod;
sol = (sol - 1 + mod) % mod;
cout << sol << endl;

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int q,h[100010][2],i,rmax=0,n,a,t[100010]={};
  bool isprime[100010]={false};
  cin >> q;
  for (i=0;i<q;i++){
    cin >> h[i][0] >> h[i][1];
    if (rmax<h[i][1]) rmax=h[i][1];
  }
  for (n=2;n<=rmax;n++){
    for (a=2;a*a<=n;a++) if (n%a==0) break;
    if (a*a>n) isprime[n]=true;
  }
  for (i=3;i<=rmax;i+=2) if (isprime[i] && isprime[(i+1)/2]) t[i]=1;
  for (i=3;i<=rmax;i++) t[i]+=t[i-1];
  
  for (i=0;i<q;i++) cout << t[h[i][1]]-t[h[i][0]-1] << endl;
  return 0;
}

Measured memory_bytes: 1920
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64 c:i64));
    let mut list = vec![a, b, c];
    let mut count = 0;
    while !(list[0] == list[1] && list[0] == list[2]) {
        list.sort();
        if list[1] == list[2] {
            list[0] += 2;
        } else {
            list[0] += 1;
            list[1] += 1;
        }
        count += 1;
    }
    count.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 5 4" => "2",
    test2: "2 6 3" => "5",
    test3: "31 41 5" => "23",
}


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

int main() {
  int X, Y, Z; cin >> X >> Y >> Z;
  int ans = 0;
  X -= Z;
  while (X >= Y + Z) {
    X -= Y;
    X -= Z;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  ll n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  ll INF = pow(10,18);
  FOR(i,0,n-1) {
    cin >> a[i];
    sum += a[i];
  }

  ll middlesum = INF;
  ll middle = 0;
  ll lsum = 0;

  FOR(i,0,n-1){
    lsum += a[i];
    sum -= a[i];


    if(abs(sum-lsum)<abs(middlesum)) {
        middlesum = abs(sum-lsum);
        middle = lsum;
    }
  }

  cout << abs(middlesum) << endl;



}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
//#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a;
    cin>>n;
    cin>>a;
    ll minm=a;
    ll count=1;
    REP(i,1,n)
    {
        cin>>a;
        if(a<minm)
        {
            count++;
            minm=a;
        }
    }
    cout<<count<<"\n";
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
ll n,m,num,L,R;
ll l[N],r[N];
int flag[N];

int solve() {
  rep(i,m) {
    L = max(L,l[i]);
    R = min(R,r[i]);
  }
  
  return R - L < 0 ? 0 : R - L + 1;
}

int main () {
  ios::sync_with_stdio(false);cin.tie(nullptr);
  cin >> n >> m;
  rep(i,m) {
    cin >> l[i] >> r[i];
  }
  L = 1;R = n;
  
  
  cout << solve() << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>
#include<fstream>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

int N,M;
queue<int> que;
vector<int> stone;
vector<vector<int>> path;
void bfs(){
	while(!que.empty()){
		int idx=que.front();
		que.pop();
		int sz=path[idx].size();
		REP(i,0,sz){
			if(stone[path[idx][i]]==-1){
				stone[path[idx][i]]=idx;
				que.push(path[idx][i]);
			}
		}
	}
}
int main()
{
	
	cin>>N>>M;
	stone.resize(N);
	path.resize(N);
	REP(i,0,N){
		stone[i]=-1;
	}
	REP(i,0,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	que.push(0);
	bfs();
	cout<<"Yes"<<endl;
	REP(i,1,N){
		cout<<stone[i]+1<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 10052
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        char[] array = sc.next().toCharArray();
        Arrays.sort(array);
        for (int i=0;i<array.length;i++) {
            char c = array[i];
            int j = i+1;
            int count = 1;
            while (j < array.length && c == array[j]) {
                count++;
                i = j;
                j++;
            }
            if (count%2==1) {
                bl = false;
                break;
            }
        }
        System.out.println(bl?"Yes":"No");

    }
}

Measured memory_bytes: 21332
n = int(input())
p_list = list(map(int, input().split()))

res_count = 0
for i in range(0, n-2):
    if( sorted([p_list[i], p_list[i+1], p_list[i+2]])[-2] == p_list[i+1] ):
        res_count += 1
print(res_count)

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    C = zip(A, B)
    C = sorted(C, key=lambda x: x[1])
    A, B = zip(*C)
    t = 0
    ok = True
    for i in range(N):
        t += A[i]
        if t > B[i]:
            ok = False
            break

    print('Yes' if ok else 'No')


if __name__ == "__main__":
    main()

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

int main() {
    int a;
    rep (i, 5) {
        cin >> a;
        if (a==0) {
            cout << i+1 << endl;
            return 0;
        }

    }   
    return 0;
}

Measured memory_bytes: 3632
S = input()
if len(S)%2!=0:
    t = S[(len(S)-1)//2:(len(S)+2)//2]
    n_s = S.replace(t, "")
    L,R = n_s[:len(n_s)//2],n_s[len(n_s)//2:]
    if L == R: print ("Yes")
    else: print ("No")
else: 
    L,R = S[:len(S)//2],S[len(S)//2:]
    if L == R: print ("Yes")
    else: print ("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int o(int x)
{
	int re=0;
	while(x)re^=(x&1),x>>=1;
	return re;
}
int n,A,B,ans[18][1<<17];
void solve(int k,int A,int B,int *a,int l,int r)
{
	if(k==1){a[l]=A,a[r]=B;return;}
	int C=A^B,t=(C&-C),mid=l+r>>1;
	int tA=A%t+A/(t<<1)*t,tB=B%t+B/(t<<1)*t,tC=tA^1;
	solve(k-1,tA,tC,ans[k-1],l,mid),solve(k-1,tC,tB,ans[k-1],mid+1,r);
	for(int i=l;i<=mid;i++)
	a[i]=ans[k-1][i]%t+ans[k-1][i]/t*(t<<1)+((A&t)?t:0);
	for(int i=mid+1;i<=r;i++)
	a[i]=ans[k-1][i]%t+ans[k-1][i]/t*(t<<1)+((B&t)?t:0);
//	printf("%d %d %d\n",k,A,B);
//	for(int i=l;i<=r;i++)printf("%d ",a[i]);puts("");
}
int main()
{
	n=read(),A=read(),B=read();
	if(o(A)==o(B))return puts("NO"),0;
	solve(n,A,B,ans[n],0,(1<<n)-1);
	puts("YES");
	for(int i=0;i<(1<<n);i++)printf("%d ",ans[n][i]);
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll a[410],sum[410],dp[410][410];

ll fun(int x,int y)
{
    if(x==y)return 0;
    if(dp[x][y]>-1)return dp[x][y];
    ll ans=1e15;
    for(int i=0; i<(y-x); i++){
        ans=min(fun(x,x+i)+fun(x+i+1,y)+sum[y+1]-sum[x],ans);
    }
    return dp[x][y]=ans;
}
void solve()
{
    int n;
    cin>>n;
    sum[0]=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum[i+1]=a[i]+sum[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<fun(0,n-1);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 4976
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        String s=in.next();
        String t=in.next();
        boolean flag=true;
        for(int i=0;i<s.length();i++)
            if(s.charAt(i)!=t.charAt(i))
                flag=false;
            if(flag&&t.length()-s.length()==1)
                out.println("Yes");
            else
                out.println("No");
        out.flush();
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}

Measured memory_bytes: 32684
S_=input()
T=input()
ns=len(S_)
nt=len(T)
cand=[]

def f(x, y):
  n=len(x)
  out=True
  for i in range(n):
    if x[i]!=y[i] and x[i]!='?':
      out=False
  return out

for i in range(ns-nt+1):
  if f(S_[i:i+nt], T)==True:
    temp=''
    for j in range(i):
      if S_[j]=='?':
        temp+='a'
      else:
        temp+=S_[j]
    temp+=T
    for j in range(i+nt, ns):
      if S_[j]=='?':
        temp+='a'
      else:
        temp+=S_[j]
        
    cand.append(temp)
    
cand.sort()
cand.append('UNRESTORABLE')
print(cand[0])

Measured memory_bytes: 3064
K = int(input())
A, B = map(int, input().split())

if A == B:
  if A % K == 0:
    print("OK")
    quit()
  else:
    print("NG")
    quit()

for i in range(A, B + 1):
  if i % K == 0:
    print("OK")
    quit()
  
print("NG")

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

int main(int argc, char *argv[]) {
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n-k;i++){
        if(a[i]<a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 4416
N, K = map(int, input().split())
ans = 0
memory = [0]*(10**5+1)

for i in range(N):
    a, b = map(int, input().split())
    memory[a] += b

for i in range(10**5+1):
    ans += memory[i]
    if ans >= K:
        print(i)
        break
    

Measured memory_bytes: 5736
import numpy as np
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(raw_input())
C = np.zeros(shape=(10,10))

for i in range(N+1):
    i_char = str(i)
    i_first = int(i_char[0])
    i_last = int(i_char[-1])

    C[i_first][i_last] = C[i_first][i_last] + 1

ans = 0

#print "--"                                                                                                                           
#print C                                                                                                                              
#print "--"                                                                                                                           

for i in range(1,10):
    for j in range(1,10):
        n = C[i][j]
        m = C[j][i]
        ans = ans + n*m

print int(ans)


Measured memory_bytes: 25328
import static java.util.Arrays.*;
import static java.util.stream.Collectors.*;

import java.util.*;

public class Main {
    private class Data {
        int n, p;

        public Data(int n, int p) {
            this.n = n;
            this.p = p;
        }

        @Override
        public String toString() {
            return n + ":" + p;
        }
    }

    private class Range {
        int src, dst;

        public Range(int src, int dst) {
            this.src = src;
            this.dst = dst;
        }

        public int len() {
            return dst - src + 1;
        }

        public boolean isInc(int tgt) {
            return src <= tgt && tgt <= dst;
        }

        @Override
        public String toString() {
            return src + "-" + dst;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int a[] = new int[n];
        Data data[] = new Data[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            data[i] = new Data(a[i], i);
        }
        sc.close();
        sort(data, (o1, o2) -> o1.n - o2.n);

        Map<Integer, Range> map = new HashMap<>();
        map.put(0, new Range(0, n - 1));
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n;) {
            LinkedList<Integer> tmp = new LinkedList<>();
            for (Range r : map.values()) {
                tmp.addAll(stream(copyOfRange(a, r.src, r.dst + 1)).sorted().limit(r.len() - k + 1)
                    .boxed().collect(toList()));
            }
            Collections.sort(tmp);
            if (tmp.size() < q) {
                break;
            }

            int y = tmp.get(q - 1);
            int x = data[i].n;
            ans = Math.min(ans, y - x);

            splash(map, k, data[i].p);
            while (i < n && data[i].n == x) {
                splash(map, k, data[i].p);
                i++;
            }
        }

        System.out.println(ans);
    }

    private void splash(Map<Integer, Range> map, int minSize, int p) {
        for (Range r : new ArrayList<>(map.values())) {
            if (r.isInc(p)) {
                Range newR = new Range(p + 1, r.dst);
                if (newR.len() >= minSize) {
                    map.put(p + 1, newR);
                }

                r.dst = p - 1;
                if (r.len() < minSize) {
                    map.remove(r.src);
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
    }
}


Measured memory_bytes: 93864
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
sum_A =0
for i in range(N):
    sum_A += A[i]

ans = 0
for i in range(N):
    if (4*M*A[i] >= sum_A):
        ans+=1
    else:
    	ans+=0
    	
if (ans >= M):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int N;
vector<pair<int, bool>> b;
vector<int> ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  b.resize(N + 1);
  ans.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    int bi;
    cin >> bi;
    b[i] = make_pair(bi, true);
  }

  int pos = N;
  for (int i = 1; i <= N; i++) {
    int unused_idx = 1;
    int r = 0;
    for (int j = 1; j <= N; j++) {
      if (b[j].second) {
        if (unused_idx == b[j].first) {
          r = j;
        }
        unused_idx++;
      }
    }

    if (r == 0) {
      break;
    }
    ans[pos] = b[r].first;
    b[r].second = false;
    pos--;
  }

  if (pos == 0) {
    for (int i = 1; i <= N; i++) {
      cout << ans[i] << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256