akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {
	os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T,class U> ostream& operator<<(ostream &os, const tuple<S,T,U> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class S, class T,class U,class V> ostream& operator<<(ostream &os, const tuple<S,T,U,V> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<","<<get<3>(t)<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
#else
#define out
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll a,b,c,t;
	cin>>a>>b>>c>>t;
	cout<<(t%2==0?a-b:b-a)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i;

    scanf("%d", &n);

    long a[n], cm=0, cz=0, max=0, min=1000000000, sum=0, ans=0;

    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }


    for(i=0; i<n; i++) {
        if(a[i]<0) {
            cm += 1;
            sum += -1*a[i];
            if(min >-1*a[i]) {
                min = -1*a[i];
            }
        } else if (a[i]==0) {
            cz += 1;
        } else {
            sum += a[i];
            if(min >a[i]) {
                min = a[i];
            }
        }
    }


    if (cz>0 || (cm%2)==0) {
        ans = sum;
    } else if ((cm%2)==1) {
        ans = sum - min*2;
    }

    printf("%ld \n", ans);
}

Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){
	
	ll h, w; cin >> h >> w;
	
	ll dsmin = 1e18;
	
	if(h % 3 == 0 ){
		dsmin = 0;
	}
	else{
		dsmin = min(dsmin, w);
	}
	
	if(w % 3 == 0){
		dsmin = 0;
	}
	else{
		dsmin = min(dsmin, h);
	}
	
	for(int i=1; i<h; i++){
		ll s1 = i*w;
		ll s2 = (h-i)*(w/2);
		ll s3 = (h-i)*(w - w/2);
		/*
		if(s1 < 0 || s2 < 0 || s3 < 0){
		cout << i << " " << s1 << " " << s2 << " " << s3 << endl;
		}
		*/
		
		ll smax = max(s1, max(s2, s3));
		ll smin = min(s1, min(s2, s3));
		
		dsmin = min(dsmin, smax-smin);
	}
	
	for(int i=1; i<w; i++){
		ll s1 = i*h;
		ll s2 = (w-i)*(h/2);
		ll s3 = (w-i)*(h - h/2);
		
		ll smax = max(s1, max(s2, s3));
		ll smin = min(s1, min(s2, s3));
		
		dsmin = min(dsmin, smax-smin);
	}
	
	cout << dsmin;
	
	return 0;
}

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

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

int main(void){
    int n;
    long long s,t;
    cin>>n>>s;
    for(int i=1;i<n;i++){
        cin>>t;
        s=s/gcd(s,t);
        s*=t;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }


const V dx = {1, 0, -1, 0};
const V dy = {0, 1, 0, -1};


int main() {
  int n; cin >> n;
  V p(n*n); cin >> p;

  VVbo vac(n, Vbo(n));
  VV d(n, V(n));
  rep(i, n) rep(j, n) d[i][j] = min({i, n-i-1, j, n-j-1});

  ll ans = 0;

  for (auto e : p) {
    --e;
    int si = e/n;
    int sj = e%n;
    queue<P> que;
    que.emplace(si, sj);
    ans += d[si][sj];
    vac[si][sj] = true;

    while (!que.empty()) {
      auto [i, j]  = que.front(); que.pop();
      rep(dir, sz(dx)) {
        int ii = i + dx[dir];
        int jj = j + dy[dir];
        if (ii < 0 || ii >= n || jj < 0 || jj >= n) continue;
        int dd = d[i][j] + 1 - vac[i][j];
        if (chmin(d[ii][jj], dd)) {
          que.emplace(ii, jj);
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 5248
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_right

a,b,q = li()
s = [ni() for _ in range(a)]
t = [ni() for _ in range(b)]
query = [ni() for _ in range(q)]

for qi in query:
    shrine_right = float('inf')
    temple_right = float('inf')
    
    shrine_right_idx = bisect_right(s, qi)
    temple_right_idx = bisect_right(t, qi)
    
    if shrine_right_idx < a:
        shrine_right = s[shrine_right_idx]
        
    if temple_right_idx < b:
        temple_right = t[temple_right_idx]
    
    shrine_left = float('inf')
    temple_left = float('inf')
    
    if shrine_right_idx > 0:
        shrine_left = s[shrine_right_idx - 1]
        
    if temple_right_idx > 0:
        temple_left = t[temple_right_idx - 1] 
        
    cand = []
    
    # 前前
    cand.append(max(abs(qi - shrine_left), abs(qi - temple_left)))
    
    # 前後
    cand.append(abs(temple_right-shrine_left) + min(abs(qi - shrine_left), abs(qi - temple_right)))
    
    # 後前
    cand.append(abs(shrine_right-temple_left) + min(abs(qi - temple_left), abs(qi - shrine_right)))
    
    # 後後
    cand.append(max(abs(qi - shrine_right), abs(qi - temple_right)))
        
    print(min(cand))

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

int main(){

	double a, sum;

	while(cin >> a){
		sum = a;
		for(int i=2; i<=10; i++){
			if(i % 2 == 0) a *= 2;
			else a /= 3;
			sum += a;
		}
		
		printf("%.8lf\n", sum);
	}

	return 0;

}

Measured memory_bytes: 1236
//package BeginnerContest142;

import java.util.*;
import java.io.*;

public class Main {
    static long MODULO = (long)1e9+7;

    public static long gcd(long n, long m){
        if(m == 0) return n;
        return gcd(m, n % m);
    }


    public static HashSet<Long> factors(long n){ // returns a list of the prime factors of the number n
        HashSet<Long> fact = new HashSet<>();
        fact.add(1L);
        for(long i = 2; i*i <= n; i++){
            while(n % i == 0){
                fact.add(i);
                n/=i;
            }
        }
        if(n > 1)
            fact.add(n);
        return fact;
    }
    // can also use sieve of eratosthenes for precomputing prime

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        long a = sc.nextLong();
        long b = sc.nextLong();
        pw.println(factors(gcd(a,b)).size());
        //pw.println(factors(gcd(a,b)));
        pw.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    vector<vector<char>> v(3,vector<char>(3));
    rep(i,3){
        rep(j,3) cin>>v[i][j];
    }
    rep(i,3)
    cout<<v[i][i];
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        
        String ans = A.charAt(0) +"" +B.charAt(0)+"" + C.charAt(0);
        
        System.out.println(ans.toUpperCase());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
using namespace std;

int N, A, B;

int enough(int T, vector<int> H) {
    int t = T;
    for (auto& h : H) {
        h -= B * T;
        if (h <= 0) continue;
        t -= (h + A - 1) / A;
    }

    return t >= 0;
}
signed main() {
    cin >> N >> A >> B;
    A -= B;

    vector<int> h(N);
    for (auto& x : h) cin >> x;

    int ok = *max_element(h.begin(), h.end());
    int ng = -1;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (enough(mid, h)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int v[]=new int[N];
		for(int i=0;i<N;i++) {
			v[i]=sc.nextInt();
		}
		Arrays.sort(v);
		double tmp=0;
		for(int i=0;i<N;i++) {
			if(i==0) {
				tmp=v[i];
			}else {
				tmp=(double)(tmp+v[i])/2;
			} 
		}
		System.out.println(tmp);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(){
	int x[10000],y[10000];
	int i = 0, j;

	int c;

	x[0] = 1; y[0] = 1;

	while(1){
		scanf("%d",&x[i]);
		scanf("%d",&y[i]);
		//printf("input = %d %d\n",x[i],y[i]);
		if(x[i] == 0 && y[i] == 0) break;

		if(x[i] > y[i]){
			c = x[i];
			x[i] = y[i];
			y[i] = c; 
		}

		i++;
	}

	for(j = 0;j < i;j++){
		printf("%d %d\n",x[j],y[j]);
	}

	return 0;
}

Measured memory_bytes: 1736
n,a,b = map(int, input().split())

nCnt = 0
nTtl = 0

while nCnt < n:
  nCnt = nCnt + 1
  sn = str(nCnt)
  sList = list(map(int,sn))
  if a <= sum(sList) <= b:
      nTtl = nTtl + nCnt

print(nTtl)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define init_random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define sd(n) scanf("%lld", &n)
#define pd(n) printf("%lld\n", n)
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-9
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int N = (int) 1e5 + 100;
int fac[N + 1], invfac[N + 1];
const int M = MOD;

int modexp (int a, int b) {
	if (b == 0) return 1;
	int ans = modexp(a, b/2);
	ans = (ans * ans) % M;
	if (b % 2) ans = (ans * a) % M;
	return ans;
}

inline int inv (int a) {
	return modexp(a, M - 2);
}

void prec () {
	fac[0] = 1;
	for (int i = 1; i <= N; i++) fac[i] = (fac[i - 1] * i) % M;
	invfac[N] = inv(fac[N]);
	for (int i = N - 1; i >= 0; i--) invfac[i] = (invfac[i + 1] * (i + 1)) % M;	
}

int c (int n, int r) {
	int ans = fac[n];
	ans *= invfac[n - r], ans %= M;
	ans *= invfac[r], ans %= M;
	return ans;
}
const int inf = (int) 1e15;

signed main()
{
  start_routine;
  #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  #endif
  prec();

  int dist[10][10];
  int n, m; cin >> n >> m;
  for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> dist[i][j];

  for (int k = 0; k < 10; k++)
  	for (int i = 0; i < 10; i++) 
  		for (int j = 0; j < 10; j++)
  			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  int ans = 0;
  for (int i = 0; i < n; i++) {
  	for (int j = 0; j < m; j++) {	
  		int a; cin >> a;
  		if (a == -1) continue;
  		ans += dist[a][1];
  	}
  }
  cout << ans;
  end_routine;
}

Measured memory_bytes: 1792
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	S := ReadString()

	nums := make([]int, 0)
	prev := byte('1')
	cnt := 0
	for i := 0; i < N; i++ {
		if S[i] != prev {
			nums = append(nums, cnt)
			prev = S[i]
			cnt = 1
		} else {
			cnt++
		}
	}
	nums = append(nums, cnt)
	if prev == '0' {
		nums = append(nums, 0)
	}

	ans := 0
	sum := 0
	size := 2*K + 1
	var l, r int
	for i := 0; i < len(nums); i += 2 {
		nextL := i
		nextR := Min(i+size, len(nums))
		for nextL > l {
			sum -= nums[l]
			l++
		}
		for nextR > r {
			sum += nums[r]
			r++
		}
		if sum > ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6284
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int N,M,i,j=0,p,q;
    cin>>N;
    string a[100],b[100];
    string s;
    for(i=0;i<N;i++){
        cin>>a[i];
    }
    cin>>M;
    for(i=0;i<M;i++){
        cin>>b[i];
    }
    for(i=0;i<N;i++){
        q=0;
        for(p=i;p<N;p++)
            if(a[p]==a[i])
                q++;
        for(p=0;p<M;p++)
            if(b[p]==a[i])
                q--;
    if(q>j)
        j=q;
    }
    if(j<0)
        cout<<"0"<<endl;
    else
        cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000005
#define N 300
using namespace std;
string s,t,temp;
int scnt[N],tcnt[N],ans[M],B[M],E[M];

int main(){
  while(1){
    getline(cin,temp);
    if(temp=="")break;
    s="";
    s+=temp;
    while(1){
      getline(cin,temp);
      s+=temp;
      if(temp=="")break;
    }
    getline(cin,temp);
    t=temp;
    getline(cin,temp);
    int flag=0;
    memset(tcnt,0,sizeof(tcnt));
    for(int i=0;i<(int)t.size();i++)
      tcnt[(int)t[i]]++;
    int cnt=0,idx=0;
    memset(scnt,0,sizeof(scnt));
    memset(ans,0,sizeof(ans));  
    for(int i=0;i<(int)s.size();i++){
      if(scnt[(int)s[i]]<tcnt[(int)s[i]])cnt++;
      scnt[(int)s[i]]++;
      if(cnt==t.size()){
	flag=1;
	if(!ans[i-idx+1]){
	  B[i-idx+1]=idx;
	  E[i-idx+1]=i;
	  ans[i-idx+1]++;
	}else ans[i-idx+1]++;
	while(1){
	  if(scnt[(int)s[idx]]==tcnt[(int)s[idx]]){
	    scnt[(int)s[idx]]--;
	    idx++;
	    cnt--;
	    break;
	  }
	  scnt[(int)s[idx]]--;
	  idx++;
	  if(cnt==t.size()){
	    if(!ans[i-idx+1]){
	      B[i-idx+1]=idx;
	      E[i-idx+1]=i;
	      ans[i-idx+1]++;
	    }else ans[i-idx+1]++;
	  }
	}
      }
    }
    if(!flag)cout<<0<<endl<<endl;
    for(int i=0;i<M;i++)
      if(ans[i]){
	cout<<ans[i]<<endl<<endl;
	string str=s.substr(B[i],E[i]-B[i]+1);
	for(int j=0;j<str.size();j++){
	  cout<<str[j];
	  if(!((j+1)%72))cout<<endl;
	}
	if(str.size()%72)cout<<endl;
	cout<<endl;
	break;
      }
  }
  return 0;
}

Measured memory_bytes: 7508
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>

using namespace std;

bool isKaibun(string input) {
    int size = input.size();

    for(int i = 0; i < (size / 2); i++){
        if(input[i] != input[size - i - 1]) {
            return false;
        }
    }
    return true;
}

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

    int size = s.size();

    // cout << s.substr(0, (size - 1) / 2) << endl;
    // cout << s.substr((size + 3) / 2 - 1, size - (size + 3) / 2 + 1) << endl;

    // cout << isKaibun(s) << endl;
    // cout << isKaibun(s.substr(0, (size - 1) / 2)) << endl;
    // cout << isKaibun(s.substr((size + 3) / 2 - 1, size - (size + 3) / 2 + 1)) << endl;

    if (isKaibun(s) &&
        isKaibun(s.substr(0, (size - 1) / 2)) &&
        isKaibun(s.substr((size + 3) / 2 - 1, size - (size + 3) / 2 + 1))) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))

#高さが0でない情報を探す
for i in range(n):
    if xyh[i][2] != 0:
        x_ex, y_ex, h_ex = xyh[i]
        break

for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = abs(x_ex - cx) + abs(y_ex - cy) + h_ex #高さHを求める

        #先程出した高さHが他の例にも当てはまるか確認
        flag = 0
        for i in range(n):
            x_i, y_i, h_i = xyh[i]
            if h_i == max(h - abs(x_i - cx) - abs(y_i - cy), 0):
                flag += 1
            else:
                break

        if flag == n:
            print(cx, cy, h)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner kb=new Scanner(System.in);
		int n=kb.nextInt();
		long a[]=new long[20000];
		long nowMax=0,nowMin=0;
		long sum=0;
		for(int i=0;i<n;i++){
			if(kb.hasNextLong()){
				a[i]=kb.nextLong();
			}else{
				break;
			}

		}
		nowMax=a[0];
		nowMin=a[0];
		for(int i=0;i<n;i++){
			if(nowMax<a[i]){
				nowMax=a[i];
			}if(nowMin>a[i]){
				nowMin=a[i];
			}

			sum+=a[i];
		}

		System.out.printf("%d %d %d\n",nowMin,nowMax,sum);
	}

}

Measured memory_bytes: 43096
l = input().split()
s = []
for v in l:
    if v in ["+", "-", "*"]:
        b = s.pop(-1)
        a = s.pop(-1)
        t = eval(a+v+b)
        s.append(str(t))
    else:
        s.append(v)

print(s.pop(0))



Measured memory_bytes: 5564
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/






const lli gosencho = 5e15;



int main()
{
  IOS; /* making cin faster */
  string S;
  lli K;

  CIN2(S,K);
  
  int num = 1;
  int id = -1;
  

  REP( i , SIZ(S) )
    {
      if( S[i] != '1' )
	{
	  id = i;
	  num = ctoi(S[i]);
	  break;
	  
	}
    }

  if( num == 1 or K < id + 1  )
    {
      PRINTD(1);
    }
  else
    {
      PRINTD(num);
      
    }
  

  

}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    ll m = 1ll << 50;
    cin >> N;
    for (int i = 1; i < N; ++i) {
        ll A = i;
        ll B = N-i;
        ll count = 0;
        while (A != 0){
            count += A%10;
            A/=10;
        }
        while(B!=0){
            count += B%10;
            B/=10;
        }
        m = min(m,count);

    }
    cout << m << endl;
}


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

int main(){
    int k,p,n;
    
    cin >> n;
    
    rep(i,0,n){
        cin >> k >> p;
        if(k % p == 0){
            cout << p << endl;
        }
        else{
            cout << k % p << endl;
        }
    }
    return 0;
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

int L;

inline void input()
{
	L = read<int>();
}

struct edge
{
	int u, v, w;

	edge() { }
	edge(int _u, int _v, int _w): u(_u), v(_v), w(_w) { }
};

inline void solve()
{
	const int MAXN = 20;

	int N = 0;
	static vector<edge> E;
	static int prefix[MAXN + 5];
	E.clear(), prefix[1] = 0;

	for(N = 2; N <= 20 && prefix[N - 1] + (1 << (N - 2)) < L; ++N)
	{
		prefix[N] = prefix[N - 1] + (1 << (N - 2));
		E.emplace_back(N - 1, N, 1 << (N - 2));
		E.emplace_back(N - 1, N, 0);
	}
	--N;

	int cnt = L - (1 << (N - 1)), cur = prefix[N];
	for(int i = N; i; --i)
		while(cnt >= (1 << (i - 1)) && cur + prefix[i] < L)
		{
			cnt -= 1 << (i - 1);
			E.emplace_back(i, N, cur + 1), cur += 1 << (i - 1);
		}

	printf("%d %d\n", N, SZ(E));
	for(auto it : E) printf("%d %d %d\n", it.u, it.v, it.w);
}

int main()
{
	input();
	solve();

	return 0;
}



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

int main()
{
  string s;
  cin>>s;
  set<char> st;
  for(int i=0;i<s.size();i++){
    st.insert(s[i]);
  }
  if(st.size()==3){
    cout<<"Yes";
  }
  else cout<<"No";
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//実行部
void Main()
{
  str s; cin >> s;
  str ans = "CODEFESTIVAL2016";
  ll flag = 0;
  for(ll i = 0;i < ans.size();i++)
  {
    if(s[i] != ans[i]) flag++;
  }
  fin(flag)
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
top = gets
middle = gets
bottom = gets

bingo = (0..2).reduce(Array.new()){|arr, i| arr.push(top.split(" ")[i].to_i)}
bingo = (0..2).reduce(bingo){|arr, i| arr.push(middle.split(" ")[i].to_i)}
bingo = (0..2).reduce(bingo){|arr, i| arr.push(bottom.split(" ")[i].to_i)}

N = gets
N.to_i.times{
  b = gets
  index = bingo.index(b.to_i)
  if(index != nil)then
    bingo[index] = false
  end
}

ret = false
ret = (0..2).inject(ret){|sum, j|
  if sum then 
    puts "Yes"
    exit
  end
  sum = sum||(!bingo[j*3]&&!bingo[j*3+1]&&!bingo[j*3+2])}

if !ret then
ret = (0..2).inject(ret){|sum, k|
  if sum then 
    puts "Yes"
    exit
  end
  sum = sum||(!bingo[k]&&!bingo[k+3]&&!bingo[k+6])}
end

if !ret then
  ret = (!bingo[0]&&!bingo[4]&&!bingo[8])||(!bingo[2]&&!bingo[4]&&!bingo[6])
end

puts ret ? "Yes" : "No"
exit


Measured memory_bytes: 1788
<?php
fscanf(STDIN, "%d %d", $M, $D);
$ans = 0;
for ($m = 1; $m <= $M; $m++) {
    for ($d = 1; $d <= $D; $d++) {
        $d1 = $d % 10;
        $d10 = intdiv($d, 10);
        if ($d1 >= 2 && $d10 >= 2 && $d1 * $d10 === $m) {
            //printf("%d %d %d\n", $m, $d10, $d1);
            $ans++;
        }
    }
}
echo $ans;


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;
    
    vector<i64> t(N),v(N);
    rep(i,0,N) cin >> t[i];
    rep(i,0,N) cin >> v[i];

    i64 sum=0;
    vector<i64> lim(20001,inf);
    rep(i,0,N){
        rep(j,sum,sum+t[i]) lim[j]=min(lim[j],v[i]);
        sum+=t[i];
    }

    static long double dp[20001][101];
    fill_n((long double*)dp,20001*101,-inf64);
    dp[0][0]=0;
    rep(i,0,sum){
        rep(j,0,101) if(dp[i][j]!=-inf64) rep(k,j-1,j+2){
            if(k<0 or k>min(lim[i],lim[i+1])) continue;
            dp[i+1][k]=max(dp[i+1][k],dp[i][j]+j+(long double)(k-j)/2);
            if(j==k and j<lim[i]) dp[i+1][k]=max(dp[i+1][k],dp[i][j]+j+0.25);
        }
    }

    cout << dp[sum][0] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 32000
#include<cstdio>
using namespace std;
int f[10][10];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++){
            scanf("%d",&f[i][j]);
        }
    for(int k=0;k<=9;k++)
        for(int i=0;i<=9;i++)
            for(int j=0;j<=9;j++)
                if(f[i][j]>f[i][k]+f[k][j])
                    f[i][j]=f[i][k]+f[k][j];

//    for(int i=0;i<=9;i++){
//        for(int j=0;j<=9;j++)
//            printf("%d ",f[i][j]);
//        printf("\n");
//    }
    int x;
    int s=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            scanf("%d",&x);
            if(x!=-1)
            s=s+f[x][1];
        }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int n, m; cin >> n >> m;

	map<int, int>mp;

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			mp[a]++;
		}
	}

	int ans = 0;
	rep(i, 31) {
		if (mp[i] == n) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y,Z;
  cin>>X>>Y>>Z;
  int num;
  num=X;
  X=Y;
  Y=num;
  num=X;
  X=Z;
  Z=num;
  cout<<X<<" ";
  cout<<Y<<" ";
  cout<<Z<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int n,a,b; 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>a>>b;
    int x;
    int flag=0;
    rep(i,a,b+1){
    	if(i%n==0){
    		flag=1;
    		x=i;
    		break;
		}
	}
	if(flag){
		cout<<"OK";
	}
	else
	cout<<"NG";
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
#define MOD 998244353
#define MAX 200005
#define MAX_DISTANCE 501
#define PRECISION 0.00000000001
#define INF 4000000000000000000
int boss[MAX];
int main()
{
    int n,m,i;
    scanf("%d",&n);
    int inp;
    for(i=1;i<n;i++)
    {
        scanf("%d",&inp);
        boss[inp]++;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",boss[i]);
    }
    return 0;
}


Measured memory_bytes: 2468
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k xs

solve :: Int -> Int -> U.Vector Int -> Int
solve n k xs = go 0 ss 50
  where
    ss :: U.Vector Int
    !ss = U.concat [U.scanl1' (+) $ U.drop i xs | i<-[0..n-1]]

    go !res !acc i
        | i < 0 = res
        | U.length acc' >= k = go (setBit res i) acc' (i - 1)
        | otherwise = go res acc (i-1)
      where
        acc' = U.filter (flip testBit i) acc



Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=1;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  ll t=a[0];
  for(int i=1;i<n;i++){
    if(t*2>=a[i]){
      c++;
    }else{
      c=1;
    }
    t+=a[i];
  }
  cout<<c;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

/* #define MULTI_INPUT 0 */

int n, m;
vector<vector<int>> edges (100005);
int been[100005];

void dfs(int node)
{
    if (been[node]) {
        return;
    }
    been[node] = true;
    for (int ngh : edges[node]) {
        dfs(ngh);
    }
}

void solve()
{
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int npart = 0;
    for (int i = 1; i <= n; ++i) {
        if (!been[i]) {
            ++npart;
            dfs(i);
        }
    }
    cout << npart - 1 << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef MULTI_INPUT
    int T;
    cin >> T;
    for (int t = 0; t < T; ++t) {
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 9680
from bisect import bisect_left, bisect_right
br, bl = bisect_right, bisect_left
n = input()
a = sorted([int(x) for x in raw_input().split()])
b = sorted([int(x) for x in raw_input().split()])
c = sorted([int(x) for x in raw_input().split()])
ans = 0
for bi in b:
	ans += (bl(a, bi) * (n - br(c, bi)))
print ans

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, ex, ey;
const int N(111);
short sumr[N][N], sumc[N][N];
char st[N][N], b[N][N];
short dp[N][N][N][N];
int main() {
    scanf("%d%d", &n, &m);
    for(int i(0); i < n; i++) {
        scanf("%s", st[i]);
        for(int j(0); j < m; j++) {
            if(st[i][j] == 'E') {
                ex = i; ey = j;
            }
        }
    }
    int ans(0);
    for(int i(0); i < n; i++) {
        for(int j(0); j < m; j++) {
            sumr[i][j] = j == 0 ? st[i][j] == 'o' : sumr[i][j - 1] + (st[i][j] == 'o');
            sumc[i][j] = i == 0 ? st[i][j] == 'o' : sumc[i - 1][j] + (st[i][j] == 'o');
        }
    }
    dp[0][0][0][0] = 0;
    for(int l(0); l <= m; l++) {
        for(int r(0); r + l <= m; r++) {
            for(int u(0); u <= n; u++) {
                for(int d(0); u + d <= n; d++) {
                    if(l + r < m) {
                        int a(max(d, ex - u)), b(min(n - 1 - u, ex + d));
                        short delta(ey + r + 1 <= m - 1 - l ? sumc[b][ey + r + 1] - (a == 0 ? 0 : sumc[a - 1][ey + r + 1]) : 0);
                        dp[l][r + 1][u][d] = max((int)dp[l][r + 1][u][d], dp[l][r][u][d] + delta);
                        delta = ey - l - 1 >= r ? sumc[b][ey - l - 1] - (a == 0 ? 0 : sumc[a - 1][ey - l - 1]) : 0;
                        dp[l + 1][r][u][d] = max((int)dp[l + 1][r][u][d], dp[l][r][u][d] + delta);
                    }
                    if(u + d < n) {
                        int a(max(r, ey - l)), b(min(m - 1 - l, ey + r));
                        short delta(ex + d + 1 <= n - 1 - u ? sumr[ex + d + 1][b] - (a == 0 ? 0 : sumr[ex + d + 1][a - 1]) : 0);
                        dp[l][r][u][d + 1] = max((int)dp[l][r][u][d + 1], dp[l][r][u][d] + delta);
                        delta = ex - u - 1 >= d ? sumr[ex - u - 1][b] - (a == 0 ? 0 : sumr[ex - u - 1][a - 1]) : 0;
                        dp[l][r][u + 1][d] = max((int)dp[l][r][u + 1][d], dp[l][r][u][d] + delta);
                    }
                }
            }
        }
    }
    for(int l(0); l <= m; l++) {
        for(int u(0); u <= n; u++) {
            ans = max(ans, (int)dp[l][m - l][u][n - u]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 124416
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}
ll dp[110][310][110];
int main(){
  ll n,W;cin>>n>>W;
  vl w(n),v(n);
  rep(i,n)cin>>w[i]>>v[i];
  ll first=w[0];
  rep(i,n)w[i]-=first;
  dp[0][0][1]=v[0];
  ll ans=0;
  for(ll i=1;i<n;i++){
    for(ll j=0;j<=n;j++){
      for(ll k=0;k<=n;k++){
        dp[i][j][k]=dp[i-1][j][k];
        if(j>=w[i]&&k>=1)dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-w[i]][k-1]+v[i]);
        if(i==n-1&&k*first+j<=W)ans=max(ans,dp[i][j][k]);
      }
    }
  }
  cout<<ans<<endl;
}
  
  
  

Measured memory_bytes: 25472
using System;

namespace AtCoder190804_A
{
    class Program
    {
        static void Main()
        {
            String s = Console.ReadLine();
            String[] inputs = s.Split();
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            int c = int.Parse(inputs[2]);

            int res = Math.Max(0, c - (a - b));

            Console.WriteLine($"{res}");
        }
    }
}


Measured memory_bytes: 13268
from math import tan, pi, cos, sqrt

a, b, x = map(int, input().split())
v = a*a*b
lft, rgt = 0, 180
for _ in range(100000):
    theta = (lft+rgt)/2
    height = a*tan(theta/180*pi)
    if height <= b:
        amnt = v - a*a*height/2
    else:
        c = (height - b)/tan(theta/180*pi)
        amnt = v - a*a*b/2 - a*b*c/2
    if x > amnt:
        rgt = theta
    else:
        lft = theta
print(theta)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    pair <int ,int> a[100001];
    for(int i=1;i<=n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++){
        cout<<a[i].second<<' ';
    }  
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  char a, b;
  cin >> a >> b;
  if (a == b) {
  	cout << "=" << '\n';
  } else if (a > b) {
  	cout << ">" << '\n';
  } else {
  	cout << "<" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
N = input()
l = list(map(int,list(input().split())))
cost_min = (200**2)*100
cost = 0
for i in range(-100,101):
    for j in l:
        cost += (j - i)**2
        
    if cost < cost_min:
        cost_min = cost
    cost = 0
print(cost_min)


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

using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int q ;
    cin >> q;
    vector<int> ans(q);
    vector<int> a(1e5+10,1);
    vector<int> c(1e5+10,0);
    a[0] = 0;
    a[1] = 0;
    for(int i= 2; i<1e5+1; ++i){
        if(a[i]==1){
            for(int j=2*i; j<1e5+1; j+=i) a[j] = 0;
        }
    }
    for(int i= 1; i<1e5+1; ++i){
        if(a[i]==1 && a[(i+1)/2]==1) c[i] +=1;
        c[i] += c[i-1];
    }

    rep(p,q){
        int l,r;
        cin >> l >> r;
        ans[p] = c[r]-c[l-1];
    }

    rep(i,q) cout << ans[i] << endl;
}

Measured memory_bytes: 1792