akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
 
    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];
 
    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 6800
n = int(input())
A = [int(i) for i in input().split()]

if n == 1:
    cnt = 1
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0] > A[1]:
        flag = -1
    else:
        flag = 0
    
    cnt = 1
    x = A[1]
    for i in range(2, n):
        if flag == 1:
            if x <= A[i]:
                pass
            else:
                cnt += 1
                flag = 0
                
        elif flag == -1:
            if x < A[i]:
                cnt += 1
                flag = 0
            else:
                pass
            
        else:
            if x < A[i]:
                flag = 1
            elif x > A[i]:
                flag = -1
            else:
                flag = 0
        #print('x', x, 'A[i]', A[i], 'flag', flag, 'cnt', cnt)
        x = A[i]
    
print(cnt)

Measured memory_bytes: 14428
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll a;
    string b;
    cin >> a >> b;
    ll c = 100*(b[0]-'0')+10*(b[2]-'0')+b[3]-'0';
    a *= c;
    cout << a / 100<< endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] input = new int[n];
        int counter = 0  ;
        
        for(int i = 0;i<n;i++)
        {
            input[i] = sc.nextInt();
        }
        
        for(int i = 0;i<n;i++)
        {
            if(input[i] == counter+1)
            {
                counter ++ ;
            }
        }
        
        if(counter != 0)
        {
            System.out.println(n-counter);
        }
        else
        {
            System.out.println((-1));
        }
    }
}


Measured memory_bytes: 72712
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
int n,a,b,c,d;ll l,r;
int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d),b-=a;
	fp(i,0,n-1){
		l=1ll*i*c-1ll*(n-1-i)*d;
		r=1ll*i*d-1ll*(n-1-i)*c;
		if(b>=l&&b<=r)return puts("YES"),0;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>

int l,a[1000001];
char s[1000001];

int main() {
    std::scanf("%s",s + 1);
    l = strlen(s + 1);
    for(int i = 1;i <= l;i++) a[i] = s[i] - '0';

    int sum = 0,x = 0;
    for(int i = l;i > 1;i--) {
        if(a[i] == 5 && !x) x = 1, sum += 5;
        else if(a[i] >= 6 || a[i] == 5 && x) {
            if(x) a[i]++;
            a[i - 1]++, sum += 10 - a[i];
            x = 0;
        } else sum += a[i], x = 0;
    }
    if(a[1] == 5 && !x) x = 1, sum += 5;
    else if(a[1] >= 6 || a[1] == 5 && x) {
        if(x) a[1]++;
        sum += 11 - a[1];
    } else sum += a[1];
    std::printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 5120
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn prime_factor(n: u64) -> HashMap<u64, u64> {
    let mut res = HashMap::new();
    let mut n_ = n.clone();

    for i in 2..n + 1 {
        if i * i > n_ {
            break;
        }
        while (n_ % i == 0) {
            *res.entry(i).or_insert(0) += 1;
            n_ /= i;
        }
    }
    if (n_ != 1u64) {
        res.insert(n_, 1);
    }
    res
}

fn main() {
    input! {
        n: u64, p: u64,
    }

	let dict = prime_factor(p);
    
    let mut ans = 1;
    for (k, v) in dict {
    	if v >= n {
        	ans *= k.pow((v / n) as u32);
        }
    }
    println!("{}", ans);
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // 偏りの最小値
  // 赤の方が偏りが大きい時に正、青の方を負としたら、数直線場で偏りが示せる
  // それぞれのますの「差分」を考えて、その差分を偏りに足すか引くかを判定
  // ますあたりの最大の差分は80なので、全体の最大の偏りの絶対値は80*(80+80-1) < 12800
  // なのでbitset<26000>のdp[H][W]を用意して、段階ごとにとりうるであろう値を記録していく
  int H,W;cin>>H>>W;
  vector<vector<int>> G(H,vector<int>(W));
  REP(h,H)REP(w,W) cin>>G[h][w];
  REP(h,H)REP(w,W) {
    int b;cin>>b;
    G[h][w] = abs(G[h][w]-b);
  }
  // REP(h,H) {
  //   DUMP(G[h]);
  // }

  // 13000 = ゼロ点として、数直線に見立てて計算
  typedef bitset<26000> mybs;
  vector<vector<mybs>> dp(H,vector<mybs>(W));
  // 点(0,0)
  mybs fbs = mybs(0);fbs.set(13000);
  dp[0][0] = (fbs>>G[0][0]) | (fbs<<G[0][0]);

  FOR(h,1,H) {
    dp[h][0] = (dp[h-1][0]<<G[h][0]) | (dp[h-1][0]>>G[h][0]);
  }
  FOR(w,1,W) {
    dp[0][w] = (dp[0][w-1]<<G[0][w]) | (dp[0][w-1]>>G[0][w]);
  }

  FOR(h,1,H)FOR(w,1,W) {
    mybs bs1 = (dp[h-1][w]<<G[h][w]) | (dp[h-1][w]>>G[h][w]);
    mybs bs2 = (dp[h][w-1]<<G[h][w]) | (dp[h][w-1]>>G[h][w]);
    dp[h][w] = bs1 | bs2;
  }

  // dp[H-1][W-1]のbitsetの0点から近いものを探す
  mybs bs = dp[H-1][W-1];
  REP(i,12800) {
    if (bs[13000-i]==1 || bs[13000+i]==1) {
      OUT(i);
      break;
    }
  }

  return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    long long int x[100000];

    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    long long  int res=1e9;

    for(int i=0;i+k<=n;i++){
        res = min(res,abs(x[i])+abs(x[i+k-1]-x[i]));
        res = min(res,abs(x[i+k-1])+abs(x[i]-x[i+k-1]));
    }
    p(res)
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll m,n;
    double t;
    cin>>m;
    if(m%2!=0)
    {
        n = m/2;
        n += 1;
        t = n*1.0/m;
        cout<<fixed<<setprecision(10)<<t<<endl;
    }
    else
    {
        n = m/2;
        t = n*1.0/m;
        cout<<fixed<<setprecision(10)<<t<<endl;
    }

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[55][55];
int row,col;
int q[55*55*2],op,cl;
int d[55][55];
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};
int main(){
	scanf("%d%d",&row,&col);
	int all = 0;
	for(int i=0; i<row; i++){
		scanf("%s",s[i]);
		for(int j=0; j<col; j++)
			if(s[i][j] == '.')
				all ++;
	}
	memset(d,-1,sizeof(d));
	q[op++] = 0;
	q[op++] = 0;
	d[0][0] = 0;
	while(cl<op){
		int x = q[cl++];
		int y = q[cl++];
		for(int k=0; k<4; k++){
			int xx = x+dx[k],yy=y+dy[k];
			if(xx>=0 && xx<row && yy>=0 && yy<col && s[xx][yy] != '#' && d[xx][yy] == -1){
				d[xx][yy] = d[x][y] + 1;
				q[op++] = xx;
				q[op++] = yy;
			}
		}
	}
	if(d[row-1][col-1] == -1)puts("-1");else
	printf("%d\n",all-d[row-1][col-1]-1);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,i;
    scanf("%d",&n);
    char s[n+1],t[n],t1[n];
    scanf("%s",s);
    int j=0;
    if(n%2){
        printf("No\n");
    }
    else{
    for(i=0;i<n;i++){
        if(i<n/2){
            t[i]=s[i];
        }
        else{
            t1[j]=s[i];
            j++;
        }
    }
    for(i=0;i<n/2;i++){
        if(t[i]!=t1[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    // sort(A.begin(), A.end(), greater<int>());

    long long total = accumulate(A.begin(),  A.end(), 0LL);
    auto L = (total + 4 * m - 1) / (4 * m);

    int cnt = 0;
    for (auto x : A) {
        if (x >= L) {
            ++cnt;
        }
    }

    if (cnt >= m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=55,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

int n,m,ans,st,ed;
char s[N][N];

int id(int x,int y) {return (x-1)*m+y;} 

struct edge{int y,next,c,d; } a[N*N*8]; int len=1,last[N*N];
void ins(int x,int y,int c,int d) {a[++len]=(edge){y,last[x],c,d}; last[x]=len;}
void add(int x,int y,int c,int d) {ins(x,y,c,d); ins(y,x,0,-d);}

int d[N*N],q[N*N],l,r,pre[N*N];
bool vis[N*N];

void EK() {
	while(233) {
		memset(d,-63,sizeof(d)); 
		l=1; r=2; q[l]=st; pre[ed]=0; d[st]=0; vis[st]=1;
		while(l!=r) {
			int x=q[l++]; if(l==N*N) l=1; vis[x]=0;
			for(int k=last[x],y;k;k=a[k].next) {
				y=a[k].y;
				if(a[k].c&&d[x]+a[k].d>d[y]) {
					d[y]=d[x]+a[k].d;
					pre[y]=k^1;
					if(!vis[y]) {
						q[r++]=y;
						if(r==N*N) r=1;
					}
				}
			}
		}
		if(!pre[ed]) return ;
		ans += d[ed]; int x=ed,k;
		while(x^st) {
			k=pre[x];
			a[k].c++;
			a[k^1].c--;
			x=a[k].y;
		}
	}
}

void solve() {
	qr(n); qr(m); st=n*m+1; ed=st+1;
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) {
			if(s[i][j]!='#') {
				if(i<n&&s[i+1][j]!='#') add(id(i,j),id(i+1,j),inf,1);
				if(j<m&&s[i][j+1]!='#') add(id(i,j),id(i,j+1),inf,1);
				add(id(i,j),ed,1,0);
				if(s[i][j]=='o') add(st,id(i,j),1,0);
			}
		}
	EK(); pr2(ans);
}

int main() {
	solve();
}



Measured memory_bytes: 3984
#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.at(i);
    a.at(i)--;
  }

  int ans=0;
  for(int i=0;i<N;i++){
    if(a.at(a.at(i))==i) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 640
from bisect import bisect_left

def main():
    N = int(input())
    L = list(map(int, input().split()))
    
    L.sort()
    ans = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            k = bisect_left(L[j+1:], a + L[j])
            ans += k

    print(ans)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 51360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals ("H") && b.equals ("H")){
			System.out.print("H");
		}
		else if(a.equals ("H") && b.equals ("D")){
			System.out.print("D");
		}
		else if(a.equals ("D") && b.equals ("H")){
			System.out.print("D");
		}
		else{
			System.out.print("H");
		}
		
	}

}


Measured memory_bytes: 21844
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;
int arr[55];

int main() {
    //freope    n("in.txt", "rt", stdin);
    int n;
    scanf("%d", &n);
    double ans = 0, x;
    for (int i = 0; i < n; ++i) {
        scanf("%d", arr + i);
    }
    sort(arr, arr + n);
   // reverse(arr, arr + n);
    ans = arr[0];
    for (int i = 1; i < n; ++i) {
        ans = (ans + arr[i]) / 2.0;
    }
    printf("%.5lf", ans);

}

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

const int maxn=2e5+7;
int p[maxn],n,k,sum[maxn];
double ans;

bool cmp(int a,int b)
{
	return a>b;
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&p[i]);
		sum[i]=sum[i-1]+p[i]+1;
	}
	for(int i=1;i<=n-k+1;++i) {
		ans=max(ans,double(sum[i+k-1]-sum[i-1]));
	}
	printf("%.7lf",ans/2);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	int N, C;
	int sum = 0;
	int cake;
	cin >> N >> C;
	for(int i = 0; i < C; i++){
		int a;
		cin >> a;
		sum += a;
	}
	cake = sum / (N+1);
	if(sum%(N+1) != 0){
		cake += 1;
	}
	cout << cake << "\n";
}


Measured memory_bytes: 3104
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int n;
	scanf("%d", &n);
	vector<int> t(n);
	rep(i, n)scanf("%d", &t[i]);
	int m;
	scanf("%d", &m);
	int p, x;
	ll ans = 0;
	rep(i, m) {
		scanf("%d%d", &p, &x);
		ans = 0;
		rep(j, n) {
			if (j == p - 1) {
				ans += x;
			}
			else {
				ans += t[j];
			}
		}
		printf("%lld\n", ans);
	}

	Please AC;
}


Measured memory_bytes: 384
import java.util.LinkedList;
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            LinkedList<Integer> a1 = new LinkedList<>();
            LinkedList<Integer> a2 = new LinkedList<>();
            LinkedList<Integer> a4 = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                if ( a % 4 == 0 ) {
                    a4.add(a);
                } else if ( a % 2 == 0 ) {
                    a2.add(a);
                } else {
                    a1.add(a);
                }
            }

            if ( a1.size() > a4.size() + 1 || a1.size() == 1 && a4.isEmpty() ) {
                System.out.println("No");
                continue;
            }

            boolean a1RemFlg = (a1.size() == a4.size() + 1);

            if ( a1RemFlg && !a2.isEmpty() ) {
                System.out.println("No");
                continue;
            }
            if ( !a1RemFlg ) {

            }

            if ( a2.size() % 2 != 0 && a4.isEmpty() ) {
                System.out.println("No");
                continue;
            }

            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 63848
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;

int N, M, ans=0;
vector<int> v[10];
int dfs(int n, int d, bool visited[10]){
//	cout << n << " " << d << " " << endl;
	if( d == N ) return 1;
	int ret = 0;
	visited[n] = true;
	for(auto t: v[n]) if( !visited[t] ){
		ret += dfs(t, d+1, visited);
	}
	visited[n] = false;
	return ret;
}

int main(){
	//ios_base::sync_with_stdio(0);
	int a[100], b[100];

	cin >> N >> M;
	rep(i,M){
		cin >> a[i] >> b[i];
		v[ a[i] ].push_back( b[i] );
		v[ b[i] ].push_back( a[i] );
	}

	bool visited[10]={};
	ans = dfs(1, 1, visited);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    int x;
    scanf("%d",&x);
    for(int i=-1000; i<1000; i++){
        for(int j=-1000; j<1000; j++){
            if(pow(i,5)-pow(j,5)==x){
                printf("%d %d\n",i,j);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <algorithm>

using namespace std;

struct Point{
	int x, y;
};

const Point DIR[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
//ななめ移動ができる

int w,h;
int map[50][50];//1:陸 0:海
bool visited[50][50];

bool inField(Point pos){
	return 0<=pos.x && pos.x<w && 0<=pos.y && pos.y<h;
}

//同じ島のvisitedを埋める
void dfs(Point pos){
	visited[pos.y][pos.x] = true;
	for(int i=0;i<8;i++){
		Point next={pos.x + DIR[i].x, pos.y + DIR[i].y};
		if(inField(next)==true){
			if(visited[next.y][next.x] == false && map[next.y][next.x] == 1){
				//未訪問かつ、陸
				dfs(next);
			}
		}
	}
}

int main(){
	while(true){
		cin >> w >> h;
		if(w==0){
			break;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> map[i][j];
				visited[i][j] = false;
			}
		}
		int cnt = 0;//島の数
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(visited[i][j] == false && map[i][j] == 1){
					Point pos = {j,i};
					dfs(pos);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num*10 + ( s[i]^48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}


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

    // int i = stoi("10");
    // cout << i << ' ' << i + 10<< endl;
    LIN(n)
    Read_VL(a,n);
    bool cond = false;
    ll ma = 0, mi = 100000000000000;

    REP( i, 0, n ){
      ma = fmax( ma, a[i] );
      mi = fmin( mi, a[i] );
    }

    if( ma == mi ){

      if( a[0] == n - 1 || 2 * a[0] <= n ){
        cond = true;
      }

    }else if( ma - mi == 1 ){

      ll alone = 0, not_so = 0;
      REP( i, 0, n ){
        if( a[i] == mi ){
          alone++;
        }
        else if( a[i] == ma ){
          not_so++;
        }
      }

      if( alone < ma && 2 * ( ma - alone ) <= not_so ){
        cond = true;
      }
    }

    Yn( cond );
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - ss
            var s = Console.ReadLine();

            while (s.Length > 0)
            {
                s = s.Substring(0, s.Length - 2);
                int n = s.Length / 2;

                string left = s.Substring(0, n);
                string right = s.Substring(n, n);

                if (left == right)
                {
                    break;
                }
            }

            Console.WriteLine(s.Length);
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define INF (int)(1e9+1)
#define MOD (int)(1e9+7)
#define INF64 (long long int)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  int ans;
  string S;
  cin >> S;
  int len = S.length();

  long long dp[len+1][13];
  rep(i,0,len+1) {
    rep(j,0,13) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for(int i=0;i<len;i++) {
    int c;
    if(S[i] == '?' ) {
      c = -1;
    }else {
      c=S[i]-'0';
    }
    for(int j=0;j<10;j++) {
      if (c!=-1 && c!=j) {
        //do nothing
      } else {
        for(int ki=0;ki<13;ki++) {
          dp[i+1][(ki*10+j)%13] += dp[i][ki];
        }
      }
    }
    for(int j=0;j<13;j++) {
      dp[i+1][j] %= MOD;
    }
  }

  ans = dp[len][5] % MOD;
  put(ans);

  return 0;
}


Measured memory_bytes: 10624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        // 사전순 빠른게 승 3점
        // 무승부 1점
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] data;
        int rep, a = 0, b = 0;
        try {
            rep = Integer.parseInt(br.readLine());
            while (rep-- > 0) {
                data = br.readLine().split(" ");
                if (data[0].compareTo(data[1]) == 0) {
                    a++;
                    b++;
                } else if (data[0].compareTo(data[1]) >= 1)
                    a += 3;
                else
                    b += 3;
            }
            System.out.printf("%d %d\n", a, b);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}


Measured memory_bytes: 26072
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll h,w;
int main(){
	ios::sync_with_stdio(0);
	cin>>h>>w;
	if(h==1||w==1){
		cout<<1;
		re 0;
	}
	ll ans=(h+1ll)/2ll;
	ans*=(w+1ll)/2ll;
	ll ans1=h/2ll;
	ans1*=w/2ll;
	cout<<ans+ans1;
	re 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
int  main(){
string s;
cin >> s;
int ans = 0;
for(int i=0;i<s.size();i++){
    if(ans==0&&s.at(i)=='C')ans++;
    if(ans==1&&s.at(i)=='F')ans++;
}
if(ans==2)cout <<"Yes"<<endl;
else cout <<"No"<<endl;
}
 


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    private static int mod = (int) 10e8 + 7;

    public static void main(String[] args) {
        String s = sc.next();
        int count = 1;
        char cb = s.charAt(0);
        String sb;
        for (int i = 1; i < s.length(); i++) {
            if (cb != s.charAt(i)) {
                count++;
                cb = s.charAt(i);
            } else {
                if (i == s.length()-1) {
                    continue;
                } else {
                    i++;
                    count++;
                    cb = 'Z';
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 26436
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef long long ll;

ll a[111], what, last, digit;

void generate(ll lev)
{
	ll i;

	if (lev > digit)
	{
		ll num = 0;
		for (i = 1; i <= digit; i++)
			num += a[i] * (ll)pow(10.0, (double)digit - i);

		last = num;
		--what;

		if (what == 0)
		{
			printf("%lld", last);
			exit(0);
		}
	}
	else if (lev == 1)
	{
		for (i = 1; i <= 9; i++)
		{
			a[lev] = i;
			generate(lev + 1);
		}
	}
	else
	{
		if (a[lev - 1] > 0)
		{
			a[lev] = a[lev - 1] - 1;
			generate(lev + 1);
		}
		a[lev] = a[lev - 1];
		generate(lev + 1);
		if (a[lev - 1] < 9)
		{
			a[lev] = a[lev - 1] + 1;
			generate(lev + 1);
		}
	}
}

int main(void)
{
	ll k;

	scanf("%lld", &k);
	what = k;

	while (1)
	{
		++digit;
		generate(1);
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);
                                  String a[] = new String[1000000];
                                  int n = ob.nextInt();
                               //   a[0]="AC";
                                //  if(a[0]=="AC"){System.out.println("i");}
                                       int c1=0,c2=0,c3=0,c4=0;
                                  for (int i = 0; i < n; i++) {
                                                   a[i] = ob.next();
                                                    if("AC".equals(a[i])){c1++;}
                                                   if("WA".equals(a[i])){c2++;}
                                                   if("TLE".equals(a[i])){c3++;}
                                                   if("RE".equals(a[i])){c4++;}
                                  }
                                  //for(int i=0;i<n;i++){System.out.println(a[i]);}
                             
                                  System.out.println("AC x "+c1);
                                  System.out.println("WA x "+c2);
                                  System.out.println("TLE x "+c3);
                                  System.out.println("RE x "+c4);
                 }

}


Measured memory_bytes: 58724
#include <iostream>

using namespace std;

#define N 105
#define K 100'005

int main() {
  int32_t n, k;
  cin >> n >> k;

  auto a = new int32_t[N];
  for (int32_t i = 0; i < n; ++i) {
    cin >> a[i];
  }

  auto dp = new bool[K];
  for (int32_t i = 0; i <= k; ++i) {
    dp[i] = false;
    for (int32_t j = 0; j < n; ++j) {
      if (a[j] > i) {
        break;
      }
      if (!dp[i-a[j]]) {
        dp[i] = true;
        break;
      }
    }
  }

  if (dp[k]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}


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

long long compute_xor(const long long n) { 
  switch(n & 3) { 
    case 0: return n;  // if n is multiple of 4 
    case 1: return 1;  // If n % 4 gives remainder 1 
    case 2: return n + 1; // If n % 4 gives remainder 2  
    case 3: return 0;  // If n % 4 gives remainder 3 
  } 
} 

int main() { 
  long long a, b;
  cin >> a >> b;
  cout << (compute_xor(b) ^ compute_xor(a - 1)) << '\n';
  return 0; 
} 


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;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  int c = n;
  c--;
  while(c >= 1){
    for(int i = 1; i * i <= c; i++){
       if(c % i == 0){
         if(i*i == c){
           ans = ans + 1;
//           cout << "a: " << i << ", b: " <<  c/i <<  ", c: " << c << endl;
         } else {
           ans = ans + 2;
//           cout << "a: " << i << ", b: " << c / i <<  ", c: " << c << endl;
//           cout << "a: " << c/i << ", b: " <<  i <<  ", c: " << c << endl;
         }
       }
    }
    c--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  std::vector<long long int> v(n+1);
  v[0]=-1;
  for(int i=1;i<=n;i++)
   {
     cin>>v[i];
   }
   int x=n/2,c=0,a=0;
   for(int i=1;i<=n;i++)
     {
       if(v[i] % 4 == 0 )
       a++;
       else if(v[i]%2==0)
       c++;
     }
     a+=c/2;
     if(a>=x)
     cout<<"Yes";
     else
     cout<<"No";
}


Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int t = Integer.parseInt(sc.next());
    int numOfGeneration = t / a;
    pw.println(b * numOfGeneration);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

string S[1001];
int T[1001];

int main() {
	int N;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> S[i];
		cin >> T[i];
	}
	string X;
	cin >> X;
	int a;
	for (int i = 0;i < N;i++) {
		if (S[i] == X) {
			a = i;
			break;
		}
	}
	a++;
	ll ans = 0;
	for (int i = a;i < N;i++) {
		ans += T[i];
	}
	cout << ans << endl;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 2;
int v[T];
int l[T];
int r[T];

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        l[i] = v[i];
        if(i > 1) l[i] = __gcd(l[i],l[i-1]);
    }

    for(int i = n; i >= 1; i--) {
        r[i] = v[i];
        if(i < n) r[i] = __gcd(r[i],r[i+1]);
    }

    for(int i = 1; i <= n; i++)
        ans = max(ans, __gcd(i-1 >= 1? l[i-1] : r[i+1], i+1 <= n? r[i+1] : l[i-1]));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
n = int(input())
x = list(map(int, input().split()))

x_min = min(x)
x_max = max(x)
ans = 0

for i in range(x_min + 1, x_max + 1):
    tmp = 0
    for k in x:
        tmp = tmp + (k - i) ** 2
    
    if ans == 0:
        ans = tmp
    elif ans > tmp:
        ans = tmp
        
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
 
using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
void solve() {
	ll n; cin>>n;
	ll s=0;
	vll hash(100001,0);
	vll a(n); lp(i,0,n) {cin>>a[i];s+=a[i];hash[a[i]]++;}
	ll q; cin>>q;
	while(q--) {
		ll b,c; cin>>b>>c;
			s -= hash[b]*b;
			s += hash[b]*c;
			hash[c] += hash[b];
			hash[b] = 0;
		cout<<s<<endl;
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 4720
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
void read(int &x){
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e5+10;bool vis[maxn];
int n,a,b,len,sum[maxn],pre[maxn*10],nxt[maxn*10],h[maxn],cnt;
long long ans;
struct oo{int x,y,id;}s[maxn];
void add(int x,int y){
	pre[++cnt]=y,nxt[cnt]=h[x],h[x]=cnt;
	pre[++cnt]=x,nxt[cnt]=h[y],h[y]=cnt;
}
bool cmp(oo a,oo b){return a.x==b.x?(a.y<b.y):a.x<b.x;}
void solve(int dis){
	sort(s+1,s+n+1,cmp);
	int l=1,r=0,pos=1;
	for(rg int i=1;i<=n;i++){
		//	printf("x y::%d %d\n",s[i].x,s[i].y);
		while(l<n&&(s[l].x<s[i].x-len||(s[l].x==s[i].x-len&&s[l].y<s[i].y-dis)))l++;
		while(r<n&&(s[r+1].x<s[i].x-len||(s[r+1].x==s[i].x-len&&s[r+1].y<=s[i].y+dis)))r++;
		sum[s[i].id]+=r-l+1;pos=max(pos,l);//printf("l r::%d %d\n",l,r);
	    while(pos<=r)add(s[i].id,s[pos].id),pos++;
		pos--;
	}
}
void dfs(int x){
    vis[x]=1;ans+=sum[x];
	for(rg int i=h[x];i;i=nxt[i])
		if(!vis[pre[i]])dfs(pre[i]);
}
int main(){
	read(n),read(a),read(b);
	for(rg int i=1,x,y;i<=n;i++){
		read(x),read(y),s[i].id=i;
		s[i].x=x+y,s[i].y=x-y;
	}
	len=max(abs(s[a].x-s[b].x),abs(s[a].y-s[b].y));
	solve(len);
	for(rg int i=1;i<=n;i++)swap(s[i].x,s[i].y);
	solve(len-1),dfs(a);
	printf("%lld\n",ans);
}


Measured memory_bytes: 10624
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    deque<int> b;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        if (i % 2 == 0) b.push_back(a);
        else b.push_front(a);
    }
    if (n % 2 == 1) reverse(b.begin(), b.end());
    for (auto i : b) cout << i << " ";
    cout << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, 0, n) {
        cin >> l[i];
    }
    sort(all(l));
    ll ans = 0;
    rep(i, 0, n - 2) {
        rep(j, i + 1, n - 1) {
            int sum = l[i] + l[j];
            int tmp1 = lower_bound(all(l), sum) - l.begin();
            ans += max(0, tmp1 - j - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    ll res = 0;
    rep(i, N - 1) {
        if(A[i] < 0) {
            A[i] *= -1;
            A[i + 1] *= -1;
        }
    }
    if(A[N - 1] < 0) {
        int mi = INF;
        rep(i, N) {
            mi = min(abs(A[i]), mi);
            res += abs(A[i]);
        }
        cout << res - 2 * mi << endl;
    } else {
        rep(i, N) res += A[i];
        cout << res << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n;
	string str;
	set<string> s;
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> str;
		//cout << "str = " << str << endl;
		s.insert(str);
	}
	
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n;cin>>n;map<string,ll> m;ll p=0;vector<string> s(n),d(0);
  rep(i,n){
    cin>>s[i];
    m[s[i]]++;
    if(m[s[i]]>p){p=m[s[i]];}
          }
  //caricurate
  rep(i,n){
  if(m[s[i]]==p){d.pb(s[i]);m[s[i]]=0;}
  }
  vsort(d);
  rep(i,d.size()){cout<<d[i]<<endl;}
  //output
}


Measured memory_bytes: 27120