akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
using namespace std;

const int maxn=1000003;

long long sum[maxn];
int n;
inline void update(int x){
	for(int i=x;i<maxn;i+=lowbit(i))
		++sum[i];
}
inline int query(int x){
	static int rt;rt=0;
	for(int i=x;i>0;i-=lowbit(i))
		rt+=sum[i];
	return rt;
}
long long KK=5e5,a[maxn],pre[maxn];
inline bool check(int x){
	static long long res;res=0;
	pre[0]=0;
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+(a[i]>=x?1:-1);
	memset(sum,0,sizeof(sum));
	for(int i=0;i<=n;++i){
		res+=query(pre[i]+KK);
		update(pre[i]+KK);
	}
	return res>=1ll*n*(n+1)/4;
}

int main(){
	scanf("%d",&n);
	if(n==1){
		scanf("%lld",&a[1]);
		printf("%lld\n",a[1]);
		return 0;
	}
	for(int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	int l=-1,r=1e9+7;
	while(l<r-1){
		int mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	printf("%d\n",l);
	return 0;
}
////

Measured memory_bytes: 14208
/*BISMILLAHIR RAHMANIR RAHIM*/
#include <bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define all(x)          x.begin(), x.end()
#define all(y)          y.begin(), y.end()
#define all(z)          z.begin(), z.end()
#define pi              acos(-1.0)

int main()
{
    ll int a;
    scanf("%lld", &a);
    printf("%lld\n", a+(a*a)+(a*a*a));
}
/*ALHAMDULILLAH*/


Measured memory_bytes: 3788
import sys
from collections import deque

input = sys.stdin.readline

N, M = map(int, input().split())
relations = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    relations[a].append(b)
    relations[b].append(a)

ans = 0
visited = set()
for i in range(N):
    q = deque()
    q.append(i)
    start = len(visited)
    while q:
        pos = q.popleft()
        if pos in visited:
            continue
        visited.add(pos)
        for n_pos in relations[pos]:
            if n_pos in visited:
                continue
            q.appendleft(n_pos)
    end = len(visited)
    ans = max(ans, end - start)

print(ans)

Measured memory_bytes: 127132
open Hashtbl
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let yps = Array.init m @@ fun i -> Scanf.scanf " %d %d" @@ fun a b -> b, a, i
let g s = String.(make (6 - length s) '0' ^ s)
let f a b = g (string_of_int a) ^ g (string_of_int b)
let h, ns = create n, Array.make m ""
let _ = Array.sort (fun x y -> compare y x) yps; Array.iteri (fun _ (_, p, i) -> replace h p @@ try (i, p) :: find h p with _ -> [(i, p)]) yps;
  iter (fun _ xs -> List.iteri (fun j (i, p) -> ns.(i) <- f p (j + 1)) xs) h; Array.iter print_endline ns

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k - 1] == 'A')
        s[k - 1] = 'a';
    if (s[k - 1] == 'B')
        s[k - 1] = 'b';
    if (s[k - 1] == 'C')
        s[k - 1] = 'c';
    cout << s << endl;
}

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

int main(){
  int n,k,x,sum;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    int f=x-k;
    if(f<0){
      f=k-x;
    }
    sum+=min(x*2,f*2);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int H,W;
    cin>>H>>W;
    vector<vc> a(H,vc(W));
    rep(i,H) {
        rep(j,W) {
            cin>>a[i][j];
        }
    }
    rep(i,W+2) cout<<"#";
    cout<<endl;
    rep(i,H) {
        cout<<"#";
        rep(j,W) {
            cout<<a[i][j];
        }
        cout<<"#"<<endl;
    }
    rep(i,W+2) cout<<"#";
    cout<<endl;
}

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

int main (){
    int N, K, leng=0;
    cin >> N >> K;
    for (int i = 0; i < N; i++){
        int xi;
        cin >> xi;
        
        if (K - 2 * xi > 0){
            leng += 2 * xi;
        }
        else {
            if (K > xi){
                leng += 2 * (K - xi);
            }
            else {
                leng += 2 * (xi - K);
            }
        }
    }
    cout << leng << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

int main() {
  ld a, b, h, m, xa, ya, xb, yb, sa, sb;
  cin >> a >> b >> h >> m;
  ld pi = acos(-1);
  sb = 2 * pi * m / 60;
  sa = 2 * pi * (h / 12 + m / 12 / 60);
  xa = a * cos(sa);
  xb = b * cos(sb);
  ya = a * sin(sa);
  yb = b * sin(sb);
  ld ans = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));

  cout << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

const ll MOD = 1e9+7;

int main(){
  string s; cin >> s;

  if ((SZ(s) % 3) == 1) {
    s = string("00") + s;
  } else if ((SZ(s) % 3) == 2) {
    s = string("0") + s;
  }

  ll n = (int)(SZ(s) / 3);

//   DUMP(s);

  vector<vector<ll>> dp(n+1, vector<ll>(13,0));
  dp[0][0] = 1;

  REP(k, n) REP(m, 13) {
      string str = s.substr(k*3, 3);
      vector<ll> d1;
      vector<ll> d2;
      vector<ll> d3;
    //   DUMP(str);

      if (str[0] == '?') {
        REP(i, 10) {
            d1.push_back(i);
        }
      } else {
        d1.push_back(str[0] - '0');
      }

      if (str[1] == '?') {
        REP(i, 10) {
            d2.push_back(i);
        }
      } else {
        d2.push_back(str[1] - '0');
      }

      if (str[2] == '?') {
        REP(i, 10) {
            d3.push_back(i);
        }
      } else {
        d3.push_back(str[2] - '0');
      }

    //   cout << str << d1 << d2 << d3 << endl;

      REP(i1, d1.size()) REP(i2, d2.size()) REP(i3, d3.size()) {
          ll num = 100 * d1[i1] + 10 * d2[i2] + d3[i3];
          dp[k + 1][(13 + num - m) % 13] += dp[k][m];
      }

      REP(i, 13) {
          dp[k + 1][i] %= MOD;
      }
  }

  cout << dp[n][5] << endl;
}


Measured memory_bytes: 4732
import java.io.*; 
public class Main{
  public static void main(String[] args) throws java.io.IOException{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br= new BufferedReader(isr);
    String buf =br.readLine();
    String[] res = buf.split(" ",0);
    int[] x = new int[res.length];
    for(int i=0;i<res.length; i++){
      x[i] = Integer.parseInt(res[i]);
    }
    System.out.println(x[0]*x[1]+ " "+ 2*(x[0]+x[1]));
  }
}

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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    int H=in();
    int W=in();
    string s[H];
    REP(i,H){
        cin>>s[i];
    }
    REP(i,H){
        print(s[i]);
        print(s[i]);
    }
    return 0;

}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n;cin>>n;
unordered_map<string,int> h;
while(n--)
{
	string s;cin>>s;
	h[s]++;
}
int c=0;
for(auto x: h) c++;
cout<<c;


return 0;
}

Measured memory_bytes: 17732
#include<bits/stdc++.h> 
using namespace std ;
//priority_queue<int,vector<int>,greater<int> >x ;
int h[100008] , dp[100008] ;
int main(){
    int n , k ;
    cin >> n >> k ;
    for(int i=0 ; i<n ; i++){
        cin >> h[i] ;
    }
    if(k>=n){
        cout << abs(h[n-1]-h[0]) ;
        return 0 ;
    }
    dp[0]=0 ;
    dp[1]=abs(h[1]-h[0]) ;
    for(int i=2 ; i<n ; i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]) ;
        for(int j=i-1 ; j>=i-k ; j--){
            if(j<0){
                break ;
            }
            int g=dp[j]+abs(h[i]-h[j]) ;
            dp[i]=min(dp[i],g) ;
        }
    }
    cout << dp[n-1] ;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABeginner solver = new ABeginner();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABeginner {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();

            if (n >= 10) {
                out.println(r);
            } else {
                out.println(r + 100 * (10 - n));
            }
        }

    }
}



Measured memory_bytes: 21844
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    if v[0] <= v[2] && v[1] >= v[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int h, w;

int g[15][15];
int vs[210][210];


int main(void) {
  scanf("%d%d", &h, &w);
  REP(i, 10) REP(j, 10) {
    scanf("%d", &g[i][j]);
  }
  REP(k, 10) REP(i, 10) REP(j, 10) {
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }
  int res = 0;
  REP(i, h) {
    REP(j, w) {
      scanf("%d", &vs[i][j]);
      if(vs[i][j] != -1) {
        res += g[vs[i][j]][1];
      }
    }
  }
  printf("%d\n", res);
  
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  double avg = 0;
  for (int i = 0; i < N; i++) avg += a[i];
  avg = avg / N;
  double dif = 1000000000;
  int ans = -1;
  for (int i = 0; i < N; i++) if (abs(a[i] - avg) < dif) dif = abs(a[i] - avg), ans = i;
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while True:
    for i in range(len(A)):
        if A[i]%2 != 0:
            break
        elif A[i]%2 == 0:
            A[i] /= 2
    else:
        cnt += 1
        continue
    break
    
print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int onedan=sc.nextInt();
   int X=onedan%1000;
   int x=1000-X;
   if(x==1000) {
	   System.out.println(x-1000);
   }else {
	   System.out.println(x);
   }
  }
}

Measured memory_bytes: 35800
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
  constexpr i64 mod = 1000000007;
  int n, x, y, z;
  std::cin >> n >> x >> y >> z;
  const int m = x + y + z, max = std::max({ x, y, z });

  std::vector<i64> dp(1 << m);
  dp[1] = 1;
  for (int i = 0; i < n; i++) {
    std::vector<i64> next(1 << m);
    for (int bit = 1; bit < (1 << m); bit++) {
      for (int j = 1; j <= 10; j++) {
        if (j > max) {
          next[1] = (next[1] + dp[bit]) % mod;
        } else {
          int p = 1;
          bool flg = true;
          for (int k = 0; k < x; k++) {
            if ((bit & (1 << k)) && k + j <= x) {
              p |= 1 << (k + j);
            }
          }
          for (int k = x; k < x + y; k++) {
            if ((bit & (1 << k)) && k + j <= x + y) {
              p |= 1 << (k + j);
            }
          }
          for (int k = x + y; k < m; k++) {
            if ((bit & (1 << k))) {
              if (k + j < m) p |= 1 << (k + j);
              else if (k + j == m) flg = false;
            }
          }
          if (flg) next[p] = (next[p] + dp[bit]) % mod;
        }
      }
    }
    std::swap(dp, next);
  }

  i64 ret = 1;
  for (int i = 0; i < n; i++) ret = ret * 10 % mod;
  for (const i64 e : dp) ret = (ret + mod - e) % mod;

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	3010
#define	mod	998244353
using namespace std;
int n, x, ans;
int fac[MAXN], inv[MAXN];

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int mul(const int &x, const int &y){return 1ll * x * y % mod;}
int inc(const int &x, const int &y){return (x + y >= mod) ? (x + y - mod) : (x + y);}
int dec(const int &x, const int &y){return (x - y < 0) ? (x - y + mod) : (x - y);}
void update(int &x, const int &y){x = (x + y >= mod) ? (x + y - mod) : (x + y);}

int qpow(int a, int b){
	int ret = 1;
	while (b) {
		if (b & 1) ret = mul(ret, a);
		a = mul(a, a);
		b >>= 1;
	}
	return ret;
}

void init(int n){
	fac[0] = inv[0] = 1;
	for (int i = 1; i <= n; ++i)
		fac[i] = mul(fac[i - 1], i);
	inv[n] = qpow(fac[n], mod - 2);
	for (int i = n - 1; i >= 1; --i)
		inv[i] = mul(inv[i + 1], i + 1);
}

int C(int n, int m){
	return mul(fac[n], mul(inv[m], inv[n - m]));
}

int main(){
	read(n), read(x);
	init(n);
	ans = 1;
	for (int s = 1; s < x; ++s){
		for (int len = s / 2 + s % 2; len <= n && len <= s; ++len)
			update(ans, mul(C(len, s - len), C(n, len)));
	}
	for (int s = x + 1; s <= 2 * n; s += 2){
		int i = (s - (x - 1)) / 2;
		if (2 * i >= x - 1) {
			if (x & 1) {
				int len = s / 2;
				update(ans, C(n, len));
			}
		} else {
			int ss = x - 1 - 2 * i;
			for (int len = ss / 2 + ss % 2; len + 2 * i <= n && len <= ss; ++len)
				update(ans, mul(C(len, ss - len), C(n, len + 2 * i)));
		}
	}
	printf("%d\n", ans);
	return 0;
}

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


const int MOD = 1e+9 + 7;

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

    // 端は1回しかひっくり返せないので、端が W だったらアウト
    if(S[0] == 'W' or S[2*N-1] == 'W'){
        cout << 0 << endl;
        return 0;
    }

    // ひっくり返す順番は関係ないので、組み合わせに着目する
    // その際、左端として選ばれるか右端として選ばれるかだけが大事
    long long ans = 1;
    int num_L = 1, num_R = 0;
    vector<char> is_LR(2*N);
    is_LR[0] = 'L';
    for(int i = 1; i < 2*N; ++i){
        if(S[i-1] == S[i]) is_LR[i] = (is_LR[i-1] == 'R')? 'L': 'R'; 
        if(S[i-1] != S[i]) is_LR[i] = (is_LR[i-1] == 'R')? 'R': 'L'; 
        if(is_LR[i] == 'L') ++num_L;
        if(is_LR[i] == 'R'){
            ans = ans * (num_L - num_R) % MOD;
            ++num_R;
        }
    }
    for(int i = 1; i <= N; ++i) ans = (ans*i) % MOD;
    if(num_L == num_R) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N+1); REP(i, N+1) cin >> A[i];
    vi B(N); REP(i, N) cin >> B[i];
    ll ans = 0;
    REP(i, N)
    {
        ans += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        ans += min(A[i+1], B[i]);
        A[i+1] -= min(A[i+1], B[i]);
    }
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int k = Integer.parseInt(sa[0]);
		int n = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[2 * n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
			a[n + i] = k + a[i];
		}
		br.close();

		int ans = k;
		for (int i = 0; i < n; i++) {
			ans = Math.min(ans, a[n + i - 1] - a[i]);
		}
		System.out.println(ans);
	}
}


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


int n;

int memo[50];

int fibo(int n) {
	if(n==1 || n == 0) return 1;
	if(memo[n] != -1) return memo[n];
	return memo[n] = fibo(n-1) + fibo(n-2);
}

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

	for(int i=0;i<50;i++)memo[i] = -1;
	printf("%d\n",fibo(n));
	return 0;
}



Measured memory_bytes: 3212
uses math;
var s:array[0..2,0..100]of longint;
    i,j,n,x,a:longint;
begin
  readln(n);
  for i:=1 to 2 do
    for j:=1 to n do
    begin
      read(x);
      s[i,j]:=s[i,j-1]+x;
    end;
  for i:=1 to n do
    a:=max(a,s[1,i]+s[2,n]-s[2,i-1]);
  writeln(a);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    char g[101][101];
    for(int i = 0 ;i< n ; i++)
    {
    	for(int j  = 0 ; j<m ;j++)
    	{
    		cin>>g[i][j];
    	}
    }
    std::vector<int> v,v1;
    rep(n)
    {
    	int j = 0;
    	while(j<m && g[i][j]=='.') j++;
    	if(j==m)
    		v.push_back(i);
    }
    rep(m)
    {
    	int j  = 0;
    	while(j<n && g[j][i]=='.') j++;
    	if(j==n)
    		v1.push_back(i);
    }
    int p1=0,p2=0;
    for(int i = 0 ;i< n ; i++)
    {
    	bool b = 0;
    	p2=0;
		if(p1<v.size() && i==v[p1])
		{
			p1++;
			continue;
		}
    	for(int j  = 0 ; j<m ;j++)
    	{
    		if(p2<v1.size() && j==v1[p2])
    		{
    			p2++;
    			continue;
    			// break;
    		}
    		// b = 1;
    		cout<<g[i][j]<<"";
    	}
    	// if(b)
    		cout<<endl;
    }			
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int val(char ch){ return ch-'0';}

int sub(string maxs, string mins){
  for ( int i = 0; i < maxs.size(); i++ ){
    if ( maxs[i] != mins[i] ) {
      if ( i == maxs.size()-1 )
        return val(maxs[i]) - val(mins[i]);
      if ( i == maxs.size()-2 )
        return (10*val(maxs[i])+val(maxs[i+1])) - (10*val(mins[i])+val(mins[i+1]));
      return 10;
    }
  }
  return 0;
}

int checkEqual(string S){
  string mins, maxs;
  int ans = 8;
  for ( int k = 1; k < S.size(); k++ ){
    if ( S.size()%k != 0 ) continue;
    mins = maxs = S.substr(0, k);
    for ( int s = 0; s < S.size(); s += k ){
      maxs = max(maxs, S.substr(s, k));
      mins = min(mins, S.substr(s, k));
    }
    ans = min(ans, sub(maxs, mins));
  }
  return ans;
}

int check12(string S){                                                                                                    int maxv = 0;                                                                                                           int minv = 10;
  for( int p = 0; p < S.size(); p++){
    int v = val(S[p]);
    if ( S[p] == '1' && p+1 < S.size()) {
        v = 10 + val(S[p+1]);
        p++;
    }
    maxv = max(maxv, v);
    minv = min(minv, v);
  }
  return maxv - minv;
}

main(){
  string S;                                                                                                               cin >> S;
  cout << min(checkEqual(S), check12(S)) << endl;
}






Measured memory_bytes: 3476
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<n; i++)
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int P, Q, R;
	cin>>P>>Q>>R;
	if(P<Q) swap(P, Q);
	if(P<R) swap(P, R);
	if(Q<R) swap(Q, R);
	cout<<Q+R;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int d;
	scanf("%d",&d);
	if(d==25){
		printf("Christmas\n");
	}
	else if(d==24){
		printf("Christmas Eve\n");
	}
	else if(d==23){
		printf("Christmas Eve Eve\n");
	}
	else{
		printf("Christmas Eve Eve Eve\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    if ( a + b >= 10 ) cout << "error";
    else cout << a + b;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(){
  int x,a,b;
  cin >> x >> a >> b;
  cout << ((x-a)*(x-a)<(x-b)*(x-b)?'A':'B') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;

}


Measured memory_bytes: 256
from collections import defaultdict

S = list(input())
S = [int(i) for i in S]
D = defaultdict(int)
mod = 2019

N = len(S)
Mlis = [0]*N
Mlis[-1] = S[-1] % mod

for i in range(N-2, -1, -1):
  Mlis[i] = (Mlis[i+1] + pow(10, N-1-i, mod) * S[i]) % mod

for i in Mlis:
  D[i] += 1

ans = D[0] + sum([i*(i-1)//2 for i in D.values()])

print(ans)

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9
using namespace std;
typedef long long ll;

ll x,y;

int main(){
  cin >> x >> y;
  ll tmp = x;
  ll res = 0;
  while(tmp <= y){
    tmp *=2;
    res++;
  }
  std::cout << res << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int N;
    int a = 0, w = 0, t = 0, r = 0;
    cin >> N;
    string S[N];
    REP(i,N){
        cin >> S[i];
        if(S[i] == "AC"){
            a++;
        }else if(S[i] == "WA"){
            w++;
        }else if(S[i] == "TLE"){
            t++;
        }else{
            r++;
        }
    }
    cout << "AC x " << a << "\n";
    cout << "WA x " << w << "\n";
    cout << "TLE x " << t << "\n";
    cout << "RE x " << r << "\n";
    
    return 0;
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll h, w;
    cin >> h >> w;

    vector<string> v(h+10);
    REP(i, h) {
        cin >> v[i];
    }

    REP(i, h) {
        MSG(v[i])
        MSG(v[i])
    }

    return 0;
}



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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

long double dist(long double dx, long double dy) {
	return sqrt(dx*dx+dy*dy);
}

bool check(long double xc, long double yc, long double r, vector<long double> &x, vector<long double> &y, int N) {
	for (int i=0; i<N; i++) {
		long double dx=xc-x[i];
		long double dy=yc-y[i];
		if(dist(dx,dy)>r)
			return false;
	}
	return true;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<long double> x(N), y(N);
	for (int i=0; i<N; i++)
		cin>>x[i]>>y[i];
	long double ret=1e6;
	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			for (int k=0; k<N; k++) {
				if(i==j||j==k||k==i)
					continue;
				long double x1=x[i], x2=x[j], x3=x[k];
				long double y1=y[i], y2=y[j], y3=y[k];
				long double A=x1*(y2-y3)-y1*(x2-x3)+x2*y3-x3*y2;
				long double B=(x1*x1+y1*y1)*(y3-y2)+(x2*x2+y2*y2)*(y1-y3)+(x3*x3+y3*y3)*(y2-y1);
				long double C=(x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2);
				if(abs(A)<1e-6)
					continue;
				long double xc=-B/(2*A);
				long double yc=-C/(2*A);
				long double r=dist(xc-x1,yc-y1);
				if(check(xc,yc,r,x,y,N))
					ret=min(ret,r);
			}
		}
	}
	for (int i=0; i<N; i++) {
		for (int j=i+1; j<N; j++) {
			long double xc=(x[i]+x[j])/2;
			long double yc=(y[i]+y[j])/2;
			long double r=dist(xc-x[i],yc-y[i]);
			if(check(xc,yc,r,x,y,N))
				ret=min(ret,r);
		}
	}
	cout<<setprecision(20)<<fixed<<ret<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(string A) {
  ll ans = A.size() * (A.size() - 1) / 2;

  ll l['z' - 'a' + 1] = {};
  REP(i, A.size()) { l[A[i] - 'a']++; }
  REP(i, 'z' - 'a' + 1) { ans -= l[i] * (l[i] - 1) / 2; }

  cout << ans + 1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string A;
  cin >> A;
  solve(A);
  return 0;
}


Measured memory_bytes: 788
# C - Rally
def main():
    N, *X = map(int, open(0).read().split())
    left, right = min(X), max(X)
    ans = min(sum(map(lambda x: (x - p) ** 2, X)) for p in range(left, right + 1))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();

		if ( N >= 10 ) {
			System.out.println(R);
		} else {
			System.out.println(R + 100 * ( 10 - N ));
		}
	}
}


Measured memory_bytes: 23764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	dm := make(map[int]int)
	for i := 0; i < n; i++ {
		d := scanInt()
		dm[d]++
	}
	m := scanInt()
	for i := 0; i < m; i++ {
		t := scanInt()
		if dm[t] == 0 {
			fmt.Println("NO")
			return
		}
		dm[t]--
	}
	fmt.Println("YES")
}


Measured memory_bytes: 12800
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
	/*
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
	#endif
	*/
fast;
string s;cin>>s;
ll ans=0;
fr(i,0,s.size())
{
	ans+=(s[i]-'0');
}
if(ans%9) cout<<"No";
else cout<<"Yes";
return 0;
}

Measured memory_bytes: 3688
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = next().toList()
    println(if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) "Yes" else "No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int n, k;

double f(int x)
{
	double res = 1.0;
	while(x < k){
		x *= 2;
		res *= 0.5;
	}
	return 1.0/n * res;
}

signed main()
{
	cin >> n >> k;

	double ans = 0.0;
	/*
	if(n >= k){
		ans += (double)(n-k)/n;
		n = k-1;
	}
	*/

	rep(i, 1, n+1){
		ans += f(i);
	}

	printf("%.12f\n", ans);

	return 0;
}


Measured memory_bytes: 256
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
numc = 0
numf = 0

for i in range(0, N):
    for j in range(0,i):
        if A[j] > A[i]:
            numc += 1
        if A[i] > A[j]:
            numf += 1
numbers = numc*K*(K+1) + numf*K*(K-1)
 
ans = int(numbers//2 % (10**9 + 7))
print(ans)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**7)
#n,m=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if a[-1]<=0:
    x=a.pop()
    print(x-sum(a))
    for y in a:
        print(x,y)
        x=x-y
elif a[0]>=0:
    a=a[::-1]
    x=a.pop()
    print(-x+sum(a))
    while a:
        y=a.pop()
        if len(a)>0:
            print(x,y)
            x=x-y
        else:
            print(y,x)
            
else:
    for i in range(n):
        if a[i]>0:
            ap=a[i:]
            an=a[:i]
            break
    print(sum(ap)-sum(an))
    z=ap.pop()
    x=an.pop()
    for y in ap:
        print(x,y)
        x=x-y
    for y in an:
        print(z,y)
        z=z-y
    print(z,x)


Measured memory_bytes: 13964
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	string s,t;
	cin>>s;
	cin>>t;
	bool ans = false;
	rep(i,s.size()){
		bool memo = true;
		rep(j,s.size()){
			if(s[j] != t[(i+j)%(s.size())]){
				memo = false;
				break;
			}
		}
		if(memo){
			ans = true;
			break;
		}
	}
	cout<<(ans?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;

int bind(int a, int b){
  int x = 1;
  while(b >= x)x *= 10;
  return a * x + b;
}

int a[1080];

void solve(int n, int K){

  set<int> s;
  
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      for(int k = 0;k < n;k++){
	for(int l = 0;l < n;l++){
	  if(i == j || i == k || i == l || j == k || j == l || k == l)continue;
	  int ans = a[i];
	  if(K >= 2)ans = bind(a[j], ans);
	  if(K >= 3)ans = bind(a[k], ans);
	  if(K >= 4)ans = bind(a[l], ans);
	  s.insert(ans);
	}
      }
    }
  }

  cout << s.size() << endl;  
}

int main(){
  int n, k;
  while(true){
    cin >> n >> k;
    if(n == 0 && k == 0)return 0;
    solve(n, k);		       
  }
}

Measured memory_bytes: 3120
#include <stdio.h>
   
   
   int main(void) {
    int A,B;

    
    
     scanf("%d %d",&A,&B);

      int SUM = A + B;
      
     if( SUM > 23) {
                  printf("%d",SUM%24);
              } else {
                  printf("%d",SUM);
              }
   
   
   
   return 0;
   
   }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

bool vis[100005];
vll adj[100005];
ll dist[100005];
ll in[100005];
stack<ll> topo;
ll ans;

inline void dfs(ll x)
{
	vis[x]=1;

	for(auto i:adj[x])
		if(!vis[i])
			dfs(i);

	topo.push(x);
}

int main()
{
	start_routine();
	fastio;
	

    ll n,m;cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
    	ll x,y;cin>>x>>y;
    	adj[x].pb(y);
    	in[y]++;
    }

    for(ll i=1;i<=n;i++)
    	if(!in[i]) adj[0].pb(i);

    dfs(0);

	while(topo.size())
	{
		ll x=topo.top();
		topo.pop();

		for(auto i:adj[x])
			dist[i]=max(dist[i],1+dist[x]);
	}

    for(ll i=1;i<=n;i++)
    	ans=max(ans,dist[i]);

    cout<<ans-1;

	end_routine();
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int K,N;
  cin>>K>>N;
  
  vector<int> dis(N);
  for(int i=0; i<N; i++){
    cin>>dis.at(i);
  }
  vector<int> w(N);
  for(int i=0; i<N; i++){
    if (i==N-1) {
      w.at(i) = K+dis.at(0)-dis.at(i);
    }
    else {
      w.at(i) = dis.at(i+1) - dis.at(i);
    }
  }
  sort(w.begin(), w.end());
  int ans = K-w.at(N-1);
  cout<<ans<<"\n";
}

Measured memory_bytes: 4780
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		solver(A, B, C);
	}

	public static void solver(int A, int B, int C) {
		if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
			System.out.println(0);
		} else {
			long ab = (long)A * (long)B;
			long bc = (long)C * (long)B;
			long ca = (long)A * (long)C;
			long min = ab < bc ? ab : bc;
			if (ca < min) min = ca;
			System.out.println(min);
		}
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 7892
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll n;
string s;
vector<bool>v;
bool dx[4]={true,false,true,false},dy[4]={true,false,false,true};

void solve(){
	FOR(k,1,n+1){
		if(s[k]=='o'){
			v.pb(v[k-1]?v[k]:!v[k]);
		}else{
			v.pb(v[k-1]?!v[k]:v[k]);
		}
	}
}

bool judge(){
	if(s[0]=='o'){
		return (v[n-1]==v[0]?v[1]:!v[1])&&(v[n]==v[0]);
	}else{
		return (v[n-1]==v[0]?!v[1]:v[1])&&(v[n]==v[0]);
	}
	
}

int main(){
	cin>>n>>s;
	bool flag=false;
	rep(i,4){
		v.pb(dx[i]);v.pb(dy[i]);
		solve();
		if(judge()){
			flag=!flag;
			break;
		}
		v.clear();
	}
	if(flag){
		rep(i,n){
			cout<<(v[i]?"S":"W");
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long d,n,x;
int main()
{
    cin>>d>>n;
    if (d==0)
    {
        if (n==100)
            cout<<101;
        else
            cout<<n;
    }
    else if (d==1)
    {
        if (n==100)
            cout<<10100;
        else
            cout<<(100*n);
    }
    else
    {
        if (n==100)
            cout<<1010000;
        else
            cout<<(n*10000);
    }
    return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
dx, dy = abs(x2 - x1), abs(y2 - y1)

if x1 <= x2 and y1 <= y2:
    x3 = -dy + x2
    y3 = dx + y2
    x4 = -dy + x1
    y4 = dx + y1
elif x2 <= x1 and y1 <= y2:
    x3 = -dy + x2
    y3 = -dx + y2
    x4 = -dy + x1
    y4 = -dx + y1
elif x1 <= x2 and y2 <= y1:
    x3 = dy + x2
    y3 = dx + y2
    x4 = dy + x1
    y4 = dx + y1
elif x2 <= x1 and y2 <= y1:
    x3 = dy + x2
    y3 = -dx + y2
    x4 = dy + x1
    y4 = -dx + y1

print(x3, y3, x4, y4)


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

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

  int x[n], y[n];
  for (int i=0; i<n; i++) {
    cin>>x[i]>>y[i];
  }
  long long ans = 1e18 * 4;
  for (int i=0; i<n; i++) {
    long long x1 = x[i];
    for (int j=0; j<n; j++) {
      long long x2 = x[j];
      if (x2 <= x1) continue;
      for (int k=0; k<n; k++) {
        long long y1 = y[k];
        for (int l=0; l<n; l++) {
          long long y2 = y[l];
          if (y2 <= y1) continue;
          int cnt = 0;
          for (int m=0; m<n; m++) {
            if (x[m] >= x1 && x[m] <= x2 && y[m] >= y1 && y[m] <= y2) ++cnt;
          }
          if (cnt >= K) {
            ans = min(ans, (x2 - x1) * (y2 - y1));
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

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


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	map<int, int> m;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if(a[i]>=1&&a[i]<=399) m[0]++;
		else if(a[i]>=400&&a[i]<=799) m[1]++;
		else if(a[i]>=800&&a[i]<=1199) m[2]++;
		else if(a[i]>=1200&&a[i]<=1599) m[3]++;
		else if(a[i]>=1600&&a[i]<=1999) m[4]++;
		else if(a[i]>=2000&&a[i]<=2399) m[5]++;
		else if(a[i]>=2400&&a[i]<=2799) m[6]++;
		else if(a[i]>=2800&&a[i]<=3199) m[7]++;
		else m[8]++;
	}

	int cnt=0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if(itr->second > 0 && itr->first!=8) cnt++;
	}
	if(cnt==0) cout << 1 <<" ";
	else cout << cnt <<" ";
	cout << cnt+m[8] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool prime[1000000];
vector<int> p_list;

void set_prime(){
    for(int i = 2; i < 1000000; i++){
        prime[i] = true;
    }
    for(int i = 2; i < 1000000; i++){
        if(!prime[i]) continue;
        p_list.push_back(i);
        for(int j = i * 2; j < 1000000; j += i){
            prime[j] = false;
        }
    }
}

int main(){
    long long n, p, ans = 1;
    cin >> n >> p;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    set_prime();
    for(auto&& i : p_list){
        int c = 0;
        while(p % i == 0 && p > 1){
            p /= i;
            c++;
        }
        for(int j = 0; j < (c / n); j++){
            ans *= i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1916
n=int(input())
points=list()
for i in range(n):
    points.append(list(map(int, input().split())))

t,x,y=(0,0,0)
for point in points:
    t_move, x_move, y_move=(point[0] - t ,point[1] - x, point[2] - y)
    t, x,y=(point[0], point[1], point[2])
    if t<abs(x_move + y_move)\
            or(t_move%2==0 and (x_move+y_move)%2!=0)\
            or(t_move%2!=0 and (x_move+y_move)%2==0):
        break
else:
    print("Yes")
    exit(0)
print("No")


Measured memory_bytes: 27380
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  int a,ans=0;
  map<int,int> d;
  vector<int> v,c;
  int da[1000005]={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    d[a]++;
    if(d[a]==1) v.push_back(a);
  }
  for(int i=0;i<v.size();i++){
    for(int j=v[i];j<=1000000;j+=v[i]){
      da[j]+=d[v[i]];
    }
  }
  sort(v.begin(),v.end());
  for(int i=1;i<=v[v.size()-1];i++){
    if(da[i]==1){
      if(d[i]!=0) c.push_back(i);
    }
  }
  cout<<c.size()<<"\n";
}

Measured memory_bytes: 51536
S = gets.chomp
arr = []
curr = 0
S.scan(/(<+)|(>+)/){
  size = $&.size
  if $1
    size.times{|i|
      arr << i
    }
    curr = size
  else
    arr << [curr, size].max
    (size-1).downto(1){|i|
      arr << i
    }
    curr = 0
  end
}
case S[-1]
when ?<
  arr << curr
when ?>
  arr << 0
end

p arr.inject:+

Measured memory_bytes: 28864
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
  ll h,a; cin >> h >> a;
  if(h%a == 0) cout << h/a << endl;
  else cout << h/a + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int ret;
	char str[4];
	cin >> str;

	ret = 0;
	if (str[0] == '1')
		ret++;
	if (str[1] == '1')
		ret++;
	if (str[2] == '1')
		ret++;

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long N; cin >> N;
  vector<long long> A(N);
  long long mx = 0;
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    if (mx > A[i]) {
      res += mx - A[i];
    } else {
      mx = A[i];
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4832
N = int(input())
l = [[0] * 10 for _ in range(10)]
ans = 0

for i in range(1, N+1):
    s = int(str(i)[0])
    t = int(str(i)[-1])
    l[s][t] += 1

for i in range(1, 10):
    for j in range(1, 10):
        ans += l[i][j] * l[j][i]
print(ans)

Measured memory_bytes: 3064