akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

condition = ('ooo', 'xxx')
for line in stdin:
    if line[0:3] in condition:
        win = line[0]
    elif line[3:6] in condition:
        win = line[3]
    elif line[6:9] in condition:
        win = line[6]
    elif line[0:9:3] in condition:
        win = line[0]
    elif line[1:9:3] in condition:
        win = line[1]
    elif line[2:9:3] in condition:
        win = line[2]
    elif line[0:9:4] in condition:
        win = line[0]
    elif line[2:7:2] in condition:
        win = line[2]
    else:
        win = 'd'
    print(win)

Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
    cin>>s;
    string t="";
    for(int i=s.size()-1;i>0;i--)
    {
    	t+=s[i];
	}
	int cnt=0;
	for(int i=0;i<s.size()/2;i++)
	{
		if(s[i]!=t[i])
		{
			cnt++;
		}
	}
	cout<<cnt;
	return 0;	
}

Measured memory_bytes: 256
console.log((args=>{
  let [A,B,C] = args.trim().split` `.map(v=>v|0);
  let a = 0;
  for ( let i = 0; i < B; i++ ) {
    a += A % B;
    a %= B;
    if ( a === C ) return 'YES';
  }
  return 'NO';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29556
import java.util.*;

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

    int sumDiv2 = 0;
    for(int i = 0 ; i < N ; i ++){
      int a = sc.nextInt();
      while( a % 2 == 0 ){
        sumDiv2 ++ ;
        a = a / 2;
      }
    }
    System.out.println(sumDiv2);
  }
}


Measured memory_bytes: 34240
import math
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

NumP = 0
NumQ = 0

for i in range(0,N):
    NumP += (P[i]-1) * math.factorial(N-1-i)
    NumQ += (Q[i]-1) * math.factorial(N-1-i)
    for j in range(i+1,N):
        if P[j] > P[i]:
            P[j] -= 1
        if Q[j] > Q[i]:
            Q[j] -= 1
NumP += 1
NumQ += 1

if NumP > NumQ:
    print(NumP-NumQ)
else:
    print(NumQ-NumP)
        

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m,t=1000000000;
  while(cin >> n >> m && n) {
    vector<P> v[n];
    rep(i,m) {
      ll x,y,d,c;
      cin >> x >> y >> d >> c;
      x--,y--;
      v[x].pb(P(y,d*t+c));
      v[y].pb(P(x,d*t+c));
    }
    ll d[n],e[n];
    fill(d,d+n,MAXL);
    fill(e,e+n,MAXL);
    d[0]=0;
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,0));
    while(!que.empty()) {
      P p=que.top();que.pop();
      ll x=p.S,c=p.F;
      if(d[x]<c) continue;
      rep(i,v[x].size()) {
        P q=v[x][i];
        ll y=q.F,cc=q.S;
        if(d[y]>d[x]+cc/t) {
          d[y]=d[x]+cc/t;
          e[y]=cc%t;
          que.push(P(d[y],y));
        } else if(d[y]==d[x]+cc/t) e[y]=min(e[y],cc%t);
      }
    }
    ll ans=0;
    REP(i,1,n) ans+=e[i];
    pr(ans);
  }
}

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


Measured memory_bytes: 4612
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  bool ok = true;
  for (ll i = 0; i < N; ++i) {
    if (i == N - 1) {
      if (A.at(i) > i) {
        ok = false;
      }
      continue;
    }
    if (A.at(i + 1) - 1 <= A.at(i) && A.at(i) <= i) {
      continue;
    }
    ok = false;
    break;
  }
  if (!ok) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = 0;
  A.push_back(1);
  for (ll i = 0; i < N; ++i) {
    if (A.at(i) >= A.at(i + 1)) {
      ans += A.at(i);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 4864
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[3][3];
int main(){
    for(int i=0;i<3;i++) for(int j=0;j<3;j++) scanf("%d",&a[i][j]);
    for(int i=0;i<2;i++){
        int t=a[i][0]-a[i+1][0];
        for(int j=1;j<3;j++) if(a[i][j]-a[i+1][j]!=t){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
a, b, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

min_cost = min(a) + min(b)
for i in range(m):
    x, y, c = map(int, input().split())
    min_cost = min(a[x-1] +b[y-1] -c, min_cost)
print(min_cost)



Measured memory_bytes: 70764
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const ll max_co = 3234600000;
vl ans;
int mod =1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vi st(n+2,0);
    bool f[n+2];
    rep(i,n+3){
        f[i]=false;
    }
    rep(i,m){
        int a;
        cin>>a;
        f[a]=true;
    }
    st[0]=1;
    int now;
    rep(i,n){
        now=i+1;
        rep(j,2){
            if(f[now])st[now]=0;
            else{
                st[now]+=st[i];
                st[now]%=mod;
                }
            now++;
            
        }
    }
   
    cout<<st[n]<<endl;

    
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
#define int long long
int n,m,v,p,pos,tmp;
int a[N],sum[N],t[N];

bool cmp(int x,int y)
{
	return x>y;
}

bool check(int x)
{
	//cout<<a[x]<<" "<<k<<" "<<tt<<endl;
	if(x<=p) return 1;
	int rest=v-(p-1)-(n-x+1);
	if(rest<0) rest=0;
	int choose=n-(p-1)-(n-x+1);
	int Sum=0;
	for(int i=1;i<=choose;i++) t[i]=a[i+p-1]-a[x],Sum+=t[i];
	//cout<<rest<<endl; for(int i=1;i<=choose;i++) cout<<t[i]<<" "; cout<<endl; cout<<endl;
	if(a[x]+m<a[p]) return 0;
	return Sum<=m*(choose-rest);
}

signed main() 
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	int now=1;
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
	}
	int l=p,r=n,mid,best;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid)) l=mid+1,best=mid;
		else r=mid-1;
	}
	cout<<best<<endl;
	return 0;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(void){
    int K, a, b, c;
    int64_t sum = 0;
    cin >> K;
    for (int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int k = 1; k <= K; k++){
                a = i;
                b = j;
                c = k;
                a = gcd(a, b);
                a = gcd(a, c);
                sum += a;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3596
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 5e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N];

void solve() { 
  cin >> n;
  ll up = 0, dw = 0;
  for (int i = 1;i <= n;i++) {
    cin >> a[i];
    up += a[i];
    dw += i;
  }
  if (up % dw) {
    cout << "NO\n";
    return;
  }
  up /= dw;
  for (int i = 1;i <= n;i++) {
    int j = (i == 1 ? n : i - 1);
    int now = a[i] - a[j];
    if ((up - now) % n || up < now) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

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

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nm = readn::<usize>(" ");
    let n = nm[0];
    let m = nm[1];
    let mut visited = vec![0; n];
    let mut edge = vec![Vec::new(); n];

    for _ in 0..m {
        let ab = readn::<usize>(" ");
        edge[ab[0] - 1].push(ab[1] - 1);
        edge[ab[1] - 1].push(ab[0] - 1);
    }

    println!("{}", dfs(0, 0, n, &mut visited, &edge));
}

fn dfs(node: usize, num: usize, n: usize, visited: &mut Vec<usize>, edge: &Vec<Vec<usize>>) -> usize {
    if num + 1 == n {
        return 1;
    }

    let mut v = (*visited).clone();
    let mut path = 0;
    v[node] = 1;

    for &b in (*edge[node]).iter() {
        if visited[b] == 0 {
            path += dfs(b, num + 1, n, &mut v, edge);
        }
    }

    path
}

Measured memory_bytes: 4352
temp = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
index = int(input())
print(temp[index - 1])


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

const int MAX = 3e3 + 5;
const int MOD = 998244353;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int add (int a, int b) {
	return (a + b < MOD) ? (a + b) : (a + b - MOD);
}

int mul (int a, int b) {
	return int(a * 1LL * b % MOD);
}

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

int n, s;
int a[MAX];
int dp[MAX][MAX];

int solve (int i, int sum) {
	if (sum == 0) {
		return expo(2, n - i);
	}
	if (i == n) {
		return 0;
	}
	int &ret = dp[i][sum];
	if (ret != -1) {
		return ret;
	}
	ret = 0;
	ret = add(ret, mul(2, solve(i + 1, sum)));
	if (a[i] <= sum) {
		ret = add(ret, solve(i + 1, sum - a[i]));
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << solve(0, s) << '\n';
	return 0;
}


Measured memory_bytes: 39068
import java.util.Scanner;

public class Main {
	public static int linearSearch(int[] sArray, int[] qArray) {
		int matches = 0;
		for (int i=0; i < qArray.length; i++) {
			int qry = qArray[i];
			for (int j = 0; j < sArray.length; j++) {
				if (sArray[j] == qry) {
					matches++;
					break;
				} } }
		return matches;
	}
	public static void main(String[] args) {
		Scanner scnr = new Scanner(System.in);
		
		int srchSize = scnr.nextInt();
		int[] srchArray = new int[srchSize];
		for (int i=0; i<srchSize; i++) {
			srchArray[i] = scnr.nextInt();
		}
		
		int qrySize = scnr.nextInt();
		int[] qryArray = new int[qrySize];
		for (int i=0; i<qrySize; i++) {
			qryArray[i] = scnr.nextInt();
		}
		
		System.out.println(linearSearch(srchArray, qryArray));		
	}

}



Measured memory_bytes: 39856
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll h, W;
string S[100] = {};

ll v, s, t, w;

const int INF = 7 + (1e+9);
typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 g:隣接リスト,s:始点,dist:各頂点までの距離が入る,prev:最短路木の親頂点が入る
//戻値 なし
void shortestPath(const Graph& g, int s, vector<Weight>& dist, vector<int>& prev) {
	int n = g.size();
	dist.assign(n, INF); dist[s] = 0;
	prev.assign(n, -1);
	priority_queue<Edge> Q;
	Q.push(Edge(-2, s, 0));
	while (!Q.empty()) {
		Edge e = Q.top(); Q.pop();
		if (prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		for (auto f = g[e.dst].begin(); f != g[e.dst].end(); f++) {
			if (dist[f->dst] > e.weight + f->weight) {
				dist[f->dst] = e.weight + f->weight;
				Q.push(Edge(f->src, f->dst, e.weight + f->weight));
			}
		}
	}
}

//引数 prev:最短路木の親頂点集合,t:終点
//戻値 path:sからtへの最短経路
vector<int> buildPath(const vector<int>& prev, int t) {
	vector<int> path;
	for (int u = t; u >= 0; u = prev[u])
		path.push_back(u);
	reverse(path.begin(), path.end());
	return path;
}

int main() {
	cin >> h >> W;
	rep(i, h)cin >> S[i];
	Graph g(h * W);
	rep(i, h) {
		rep(j, W) {
			if (j < W - 1) {
				if (S[i][j] != S[i][j + 1]) {
					g[i * W + j].push_back(Edge(i * W + j, i * W + j + 1, 1));
				}
				else {
					g[i * W + j].push_back(Edge(i * W + j, i * W + j + 1, 0));
				}
			}
			if (i < h - 1) {
				if (S[i][j] != S[i + 1][j]) {
					g[i * W + j].push_back(Edge(i * W + j, (i + 1) * W + j, 1));
				}
				else {
					g[i * W + j].push_back(Edge(i * W + j, (i + 1) * W + j, 0));
				}
			}
		}
	}
	vector<Weight> dist;
	vector<int> prev;
	shortestPath(g, 0, dist, prev);
	if (S[0][0] == '#' && S[h - 1][W - 1] == '#') {
		cout << (dist[h * W - 1] + 1) / 2 + 1 << endl;
	}
	else {
		cout << (dist[h * W - 1] + 1) / 2 << endl;
	}
	return 0;
}

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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    vi v(n);
    int x = 0;
    for(auto &z : v)
        cin >> z, x ^= z;

    for(int i = 0; i < n; ++i)
        cout << (x^v[i]) << " ";
    cout << "\n";
}

Measured memory_bytes: 3932
#include <stdio.h>

int	 main(void)
{
	int	a,b,c;
	int	i;
	
	scanf("%d%d%d",&a,&b,&c);

	for(i=0; a<=b; a++){
	  if((c%a)==0)
	    i++;
	}
	
	printf("%d\n",i);

	return(0);
}

Measured memory_bytes: 1028
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n=gif
if n % 2 == 0
puts n
else
  puts n*2
end


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

int main()
{
    /* ------- 宣言と入力 ------- */

    int H,A;

    cin >> H>>A;

    
    /* ------- 計算 ------- */
    
    int ans=0;

    while (H>0)
    {
        H -= A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1000005;
int n,i,j,k,head[N],adj[N*2],nxt[N*2],d[N],f[N];
void dfs(int x,int dad)
{
	f[x]=0;
	int num=0;
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad)
		{
			dfs(adj[y],x);
			f[x]+=f[adj[y]];
			if(!f[adj[y]])
				++num;
		}
	if(num)
		f[x]+=num-1;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
		++d[j],++d[k];
	}
	for(i=0;i<n;++i)
		if(d[i]>2)
			break;
	if(i>=n)
	{
		if(n>1)
			printf("1");
		else
			printf("0");
		return 0;
	}
	dfs(i,-1);
	printf("%d",f[i]);
	return 0;
}



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

using namespace std;
typedef long long int ll;

int N,K;
int main() {

  cin>>N>>K;
  vector<int> v;
  for(int i = 0;i<N;i++){
    int l;
    cin>>l;
    v.push_back(l);
  }
  sort(v.begin(), v.end(),greater<int>());

  int sum=0;
  for(int i = 0;i<K;i++){
    sum+=v[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1'000'000'007;

ll fast_expo(ll base, ll expt) {
    if (expt == 1) return base;
    ll ans = fast_expo(base, expt / 2);
    ans = (ans + MOD) % MOD;
    ans = (ans * ans + MOD) % MOD;
    if (expt & 1LL) ans = (ans * base + MOD) % MOD;
    return ans;
}

ll C(ll n, ll m) {
    ll to = max(m, n - m);
    ll to2 = min(m, n - m);
    ll p1 = 1;
    for (ll i = n; i > to; --i) {
        p1 *= (i % MOD);
        p1 %= MOD;
    }
    ll p2 = 1;
    for (ll i = 1; i <= to2; ++i) {
        p2 *= (i % MOD);
        p2 %= MOD;
    }
    ll div = fast_expo(p2, MOD - 2);
    div %= MOD;
    p1 %= MOD;
    ll ans = p1 * div;
    ans %= MOD;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = fast_expo(2, n) - 1;
    ans = (ans - C(n, a) + MOD) % MOD;
    ans = (ans - C(n, b) + MOD) % MOD;
    cout << ans << '\n';
}
/*
 * 140,624,998
 * 34076506

 * */

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

int main() {
  std::string str[3];
  std::cin >> str[0] >> str[1] >> str[2];

  for (int i = 0; i < 3; ++i) {
    std::cout << str[i][0];
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstring>
using namespace std;
typedef long long ll;
int n[105];
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int cnt=0;
        for(int i=0; i<105; i++)
            n[i]=0;
        for(int i=1; i<=a; i++)
        {
            if(a%i==0)
                n[i]++;
        }
        for(int i=1; i<=b; i++)
        {
            if(b%i==0)
                n[i]++;
        }
        for(int i=100; i>=1; i--)
        {
            if(n[i]==2)
                cnt++;
            if(cnt==c)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
}


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

int main()
{
    int x;
    for(int i = 1; ;i++){
        scanf("%d", &x);
        if (x == 0) break;
        printf("Case %d: %d\n", i, x);
    }
}



Measured memory_bytes: 3160
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
C.sort()

ans = 0

def bisect(array, threshold, equal=False):
    OK = -1
    NG = N
    while NG - OK > 1:
        mid = (OK + NG) // 2
        if array[mid] < threshold:
            OK = mid
        elif equal == True and array[mid] == threshold:
            OK = mid
        else:
            NG = mid
    return OK + 1

for i in B:
    ans += bisect(A, i) * (N - bisect(C, i, True))

print(ans)

Measured memory_bytes: 23292
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

struct Dice{
	int n,e,w,s,d,u;
	Dice(){
		u=1; s=2; e=3; w=4; n=5; d=6;
	}
	void North(){
		int t=u;
		u=s; s=d; d=n; n=t;
	}
	void East(){
		int t=u;
		u=w; w=d; d=e; e=t;
	}
	void West(){
		int t=u;
		u=e; e=d; d=w; w=t;
	}
	void South(){
		int t=u;
		u=n; n=d; d=s; s=t;
	}
	void Right(){
		int t=s;
		s=e; e=n; n=w; w=t;
	}
	void Left(){
		int t=s;
		s=w; w=n; n=e; e=t;
	}
	int Spin(string s){
		if(s=="North") North();
		else if(s=="East") East();
		else if(s=="West") West();
		else if(s=="South") South();
		else if(s=="Right") Right();
		else if(s=="Left") Left();
		return u;
	}
};


int main(){
	int n;
	while(cin>>n && n>0){
		Dice d;
		string s;
		int sum=1;
		rep(i,n){
			cin>>s;
			sum+=d.Spin(s);
		}
		cout<<sum<<endl;
	}
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

vector<int> getBit(int n){
	vector<int> ret;
	while(n){
		ret.push_back(n&1);
		n >>= 1;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int l;
	cin>>l;
	if(l == 2){
		cout<<"2 2\n1 2 0\n1 2 1\n";
		exit(0);
	}
	vector<int> bit = getBit(l - 1);
	int n = bit.size();
	vector<pair<int, pair<int, int> > >edges;
	for(int i = n - 1; i >= 1; i--){
		edges.push_back({0, {i, i + 1}});
		edges.push_back({1<<(n - 1 - i), {i, i + 1}});
	}
	for(int i = 2; i <= n; i++){
		int val = (l-1)>>(n - i);
		if(val&1){
			edges.push_back({(val>>1)<<(n - i + 1), {1, i}});
		}
	}
	edges.push_back({l - 1, {1, n}});
	cout<<n<<" "<<edges.size()<<'\n';
	for(auto pp : edges){
		cout<<pp.second.first<<" "<<pp.second.second<<" "<<pp.first<<'\n';
	}

	return 0;
}

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

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k -1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d=1;
  cin >> a >> b >> c;
  if(a!=b&&a!=c&&b!=c)d=3;
  else if(a==c&&a!=b)d=2;
  else if(a==b&&a!=c)d=2;
  else if(b==c&&b!=a)d=2;
  else d=1;
  cout << d << endl;
}


Measured memory_bytes: 256
h, w = gets.chomp.split(" ").map(&:to_i)
ar = []
arr = Array.new(w+2,"#")
ar << arr
h.times do |i|
    a = gets.chomp.split("")
    a.unshift("#")
    a.push("#")
    ar << a
end
ar << arr
ar.each do |i|
    i.each do |j|
        print j
    end
    print "\n"
end

Measured memory_bytes: 14632
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

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

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

int main() {
    int n;
    while(cin >> n) {
    	ll ret = 0;
    	int m = 600 / n;
    	rep(i,0,m) {
    		ret += n * (i * i * n * n);
    	}
    	cout << ret << endl;
    }
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<PII> p(n);
  rep(i,n){
    cin>> p[i].second >> p[i].first;
  }

  sort(all(p));

  ll current = 0;
  rep(i,n){
    if(current <= p[i].first-p[i].second){
      current += p[i].second;
    }else{
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 1792
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		BigInteger n = new BigInteger(sc.next());
		String[] cds = new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
		
		BigInteger index = BigInteger.valueOf(26);
		BigInteger nextVal = n;
		int exact = 0;
		StringBuilder ans = new StringBuilder();
		BigInteger border = BigInteger.ONE;
		
		while (true) {
			n = n.subtract(BigInteger.ONE);
			nextVal = n.divide(index);
			exact = n.mod(index).intValue();
			
			ans.insert(0, cds[exact]);
			
			if (nextVal.equals(BigInteger.ZERO)) {
				break;
			}
			n = nextVal;
		}
		System.out.println(ans);
	}
}


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

int cmp1(const char *a,const char *b){
  return *a-*b;
}
int cmp2(const char *a,const char *b){
  return *b-*a;
}
int main(){
  char a[111],b[111];
  scanf("%s%s",a,b);
  qsort(a,strlen(a),sizeof(a[0]),cmp1);
  qsort(b,strlen(b),sizeof(b[0]),cmp2);
  puts(strcmp(a,b)<0?"Yes":"No");
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] A = new int[N + 10];
    int count = 0;
    for (int i = 0; i < N; i++){
      A[i] = scanner.nextInt();
    }
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for (int i = 0; i < N; i++){
      if (map.containsKey(A[i])){
        map.put(A[i], map.get(A[i]) + 1);
      } else {
        map.put(A[i], 1);
      }
    }
    ArrayList<Integer> list = new ArrayList<Integer>(map.values());
    Collections.sort(list);
    for (int i = 0; i < list.size() - K; i++){
      count += list.get(i);
    }
    System.out.println(count);
  }
}

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

using namespace std;

using ll = long long;

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 最小公倍数を計算
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll result = lcm(a, b);
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, D;
ll a[300050];
int main() {
    cin >> N >> D;
    ll Grundy = 0;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] = a[i] + D;
        a[i] = a[i] % (D + 1);
        //cout << a[i] << endl;
        Grundy = Grundy ^ a[i];
    }
    if(Grundy == 0) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}


Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    LL a[7];
    for(int i=0;i<7;i++){
        cin >> a[i];
    }
    cout << (a[0]&&a[3]&&a[4]?max(((a[0]-1)/2+(a[3]-1)/2+(a[4]-1)/2)*2+a[1]+3,(a[0]/2+a[3]/2+a[4]/2)*2+a[1]):(a[0]/2+a[3]/2+a[4]/2)*2+a[1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 10e9 + 7;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	double a, b;
	cin >> a >> b;
	if (a < b) {
		cout<<"LESS"<<endl;
	}
	else if (a == b) {
		cout<<"EQUAL"<<endl;
	}
	else {
		cout<<"GREATER"<<endl;
	}
	return 0;
}


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

ll n,h,w,d[10];
map<pair<ll,ll>,ll> m,ob;
pair<ll,ll> p[100005];

long long kita(ll x,ll y)
{
    if(x<=1||(y<=1||(x>=h||y>=w)))
        return 0;
    if(ob[{x,y}]>0)
        return 0;
    ll br=0;
    br+=m[{x,y}];
    br+=m[{x+1,y}];
    br+=m[{x-1,y}];
    br+=m[{x,y+1}];
    br+=m[{x,y-1}];
    br+=m[{x+1,y+1}];
    br+=m[{x-1,y+1}];
    br+=m[{x+1,y-1}];
    br+=m[{x-1,y-1}];

    ob[{x,y}]++;

    return br;
}

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

    cin>>h>>w>>n;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        m[{x,y}]++;
        p[i]={x,y};
    }

    for(ll i=0;i<n;i++)
    {
        ll x,y;
        x=p[i].first; y=p[i].second;
        d[kita(x,y)]++;
        d[kita(x+1,y)]++;
        d[kita(x-1,y)]++;
        d[kita(x,y+1)]++;
        d[kita(x,y-1)]++;
        d[kita(x+1,y+1)]++;
        d[kita(x-1,y+1)]++;
        d[kita(x+1,y-1)]++;
        d[kita(x-1,y-1)]++;
    }
    cout<<(h-2)*(w-2)-d[1]-d[2]-d[3]-d[4]-d[5]-d[6]-d[7]-d[8]-d[9]<<endl;
    for(ll i=1;i<10;i++)
        cout<<d[i]<<endl;

    return 0;
}


Measured memory_bytes: 217660
import java.util.*;
public class Main {
    public static void main(String[]args){
        // 標準入力
        Scanner sc = new Scanner(System.in);

        Long N = sc.nextLong();
        Long A = 0L; 
        for (long i = 1 ;i*i <=N; i++){
            if (N%i == 0 && i> A)
            A = i;

        }
        Long B = N/A;

        System.out.println(A+B-2);
    }   
       
}       

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

int main() {
  vector<int>X(3);
  for(int i=0;i<3;i++){
    cin>>X.at(i);}
  sort(X.begin(),X.end());
  
    cout<<X.at(0)<<" "<<X.at(1)<<" "<<X.at(2)<<endl;
  return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1000000001
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int n,k;
ll a[100002];
ll dp[100002];

int rec(int i){
	if(i+k>=n)return abs(a[i]-a[n-1]);
	if(dp[i]!=inf)return dp[i];
	rep(j,0,k){
		dp[i]=min(dp[i],abs(a[i]-a[i+j+1])+rec(i+1+j));
	}
	return dp[i];
}

int solve(){
	rep(i,0,100002)dp[i]=inf;
    cin>>n>>k;
	rep(i,0,n)cin>>a[i];
	cout<<rec(0)<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    
    int n, x;
    
    while(true){
        int count = 0;
        cin >> n >> x;
        
        if(n == 0 && x == 0) break;
        
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) count++; 
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

struct Point{
  int n,a;
};

int main(){
  int i,j,k,n,a[4][14],b[10],ans,max,c;
  string str;
  Point p[5];
  bool aaa = false;
  while(cin >> n){
    if(aaa) cout << endl;
    aaa = true;
    for(i=0;i<4;i++){
      for(j=1;j<14;j++) cin >> a[i][j];
    }
    b[0] = 0;
    for(i=1;i<10;i++) cin >> b[i];
    for(i=0;i<n;i++){
      ans = 0;
      max = 0;
      for(j=0;j<5;j++){
	cin >> str;
	if(str[0] == 'A') p[j].n = 1;
	else if(str[0] == 'T') p[j].n = 10;
	else if(str[0] == 'J') p[j].n = 11;
	else if(str[0] == 'Q') p[j].n = 12;
	else if(str[0] == 'K') p[j].n = 13;
	else p[j].n = str[0] - '0';
	if(str[1] == 'S') p[j].a = 0;
	else if(str[1] == 'C') p[j].a = 1;
	else if(str[1] == 'H') p[j].a = 2;
	else if(str[1] == 'D') p[j].a = 3;
	ans += a[p[j].a][p[j].n];
      }

      c = 1;
      for(j=1;j<5;j++){
	if(p[0].a == p[j].a) c++;
      }
      if(c == 5 && max < 5) max = 5;

      for(j=0;j<5;j++){
	c = 1;
	for(k=j+1;k<5;k++){
	  if(p[j].n == p[k].n){
	    c++;
	    if(max < 1) max = 1;
	    if(max < 3 && c == 3) max = 3;
	    if(max < 7 && c == 4) max = 7;

	    for(int l=0;l<5;l++){
	      if(l != j && l != k){
		int cc = 1;
		for(int m=l+1;m<5;m++){
		  if(m != k && m != j && p[l].n == p[m].n){
		    cc++;
		    if(max < 2) max = 2;
		    if(max < 6 && cc == 3) max = 6;
		  }
		}
	      }
	    }
	  }
	}

      }

      int st[5];
      for(j=0;j<5;j++) st[j] = p[j].n;
      sort(st,st+5);
      for(j=1;j<10;j++){
	if(st[0] == j && st[1] == j+1 && st[2] == j+2 && st[3] == j+3 && st[4] == j+4){
	  if(max < 4) max = 4;
	  c = 1;
	  for(k=1;k<5;k++){
	    if(p[0].a == p[k].a) c++;
	  }
	  if(c == 5 && max < 8) max = 8;
	}
      }

      if(st[0] == 1 && st[1] == 10 && st[2] == 11 && st[3] == 12 && st[4] == 13){
	if(max < 4) max = 4;
	c = 1;
	for(k=1;k<5;k++){
	  if(p[0].a == p[k].a) c++;
	}
	if(c == 5 && max < 9) max = 9;
      }
      cout << ans * b[max] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 932
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,k;
Vi p;
Vi sum;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>k;
    p.resize(n);
    sum.resize(n+1,0);
    rep(i,n){
        cin>>p[i];
        sum[i+1] += sum[i] + p[i];
    }
    ll mx = 0;
    ll id = 0;
    rep(i,n){
        if(i+k>n)break;
        if(chmax(mx,sum[i+k]-sum[i]))id=i;
    }
    long double ans = 0.0;
    rep(i,k){
        ans += (long double)(p[i+id]+1)/2.0;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3328
S = input()

if len(S) < 26:
    for c in [chr(i) for i in range(ord('a'), ord('a') + 26)]:
        # print(c)
        if c not in S:
            ans = S + c
            break
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    ans = -1
else:
    for i in range(1, len(S)):
        j = - i
        if ord(S[j - 1]) < ord(S[j]):
            break
    # print(S[j:])
    change = 'z'
    for c in S[j:]:
        if ord(S[j - 1]) < ord(c) < ord(change):
            change = c
    ans = S[:j - 1] + change
print(ans)

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            List<int> price = new List<int>();

            price.AddRange(str);

            var min = price.Min();

            price.Remove(min);

            if (min + price[0] < min + price[1])
            {
                Console.WriteLine(price[0] + min);
            }
            else
            {
                Console.WriteLine(price[1] + min);
            }
        }
    }
}

Measured memory_bytes: 13152
N=int(input())

import itertools
li_c=list(itertools.permutations(range(N),2))

rocation=[]
for i in range(N):
    x=list(map(int,input().split()))
    rocation.append(x)

import math
distance=[]
for j in range(len(li_c)):
    distance.append(math.sqrt((rocation[li_c[j][0]][0]-rocation[li_c[j][1]][0])**2+(rocation[li_c[j][0]][1]-rocation[li_c[j][1]][1])**2))

print(sum(distance)/N)


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

int main() {

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

  long long int w, h;

  while( true ) {

    cin >> w >> h;

    if ( w == 0 ) break;

    int map[52][52] = {0};

    for ( int y = 0; y < h; y++ ) {
      for ( int x = 0; x < w; x++ ) {

	cin >> map[x+1][y+1];

      }
    }

    int ans = 0;

    while( true ) {

      bool flag = false;
      for ( int y = 1; y < h + 1; y++ ) {
	for ( int x = 1; x < w + 1; x++ ) {

	  if ( map[x][y] == 1 ) {
	    queue<int> qx, qy;
	    qx.push(x);
	    qy.push(y);
	    map[x][y] = 0;
	    while( qx.size() > 0 ) {

	      int lx = qx.front();
	      int ly = qy.front();
	      for ( int i = 0; i < 8; i++ ) {
		if ( map[lx+dx[i]][ly+dy[i]] == 1 ) {
		  map[lx+dx[i]][ly+dy[i]] = 0;
		  qx.push(lx+dx[i]);
		  qy.push(ly+dy[i]);
		}
	      }
	      qx.pop();
	      qy.pop();

	    }
	    flag = true;
	    break;
	  }

	}
	if ( flag ) break;
      }
      if ( flag == false ) break;

      ans++;

    }

    cout << ans << endl;

  }

  return 0;

}

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

int main() {
  int64_t N;
  cin >> N;
  int64_t X = 0;
  
  for(int64_t i = 1; i <= N; i++ ){
    if(i%3 != 0 && i%5 != 0) {
   X += i;
  }
  }
  cout << X << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <set>
#include <algorithm>

int x[200010];
std::multiset<int> S;
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	std::sort(x+1,x+a+1);
	
	S.insert(x[a]);
	long long int ans = 0;
	for(int i=a-1;i>=1;i--)
	{
		std::multiset<int> ::iterator it = S.end();
		it--;
		
		ans += (*it);
		S.erase(it);
		S.insert(x[i]);
		S.insert(x[i]);
	}
	printf("%lld",ans);
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    cout << count(all(s), '+') - count(all(s), '-') << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7708
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
for _ in range(N - 1):
  u, v, c = map(int, input().split())
  e[u].append((v, c))
  e[v].append((u, c))
Q, K = map(int, input().split())
import heapq
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 6)
      v0 = v // (10 ** 6)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0])
    return d
dij = dijkstra(N, e)
p = dij.path(K, 0)

for _ in range(Q):
  u, v = map(int, input().split())
  print(p[u] + p[v])

Measured memory_bytes: 102488
N = int(input())
S = list((input() for _ in range(N)))
S_set = set(S)
M = int(input())
T = list((input() for _ in range(M)))
counters = []

for si in S_set:
    counter = 0
    for t in T:
        if t == si:
            counter += -1
    for s in S:
        if s == si:
            counter += 1
    counters.append(counter)
print(max(max(counters),0))            
        

Measured memory_bytes: 9196
#include <stdio.h>

int ABS(int x){
	if(x<0)return -x;
	else return x;
}

int main(){
    int x,y;
	int ans = 0;
	scanf("%d %d",&x,&y);
	if(x == y){ans = 0;}
	else if(x == 0){
		if(y<0){ans = 1-y;}
		else{ans = y;}
	}
	else if(y == 0){
		if(x<0){ans = ABS(x);}
		else{ans = x+1;}
	}
	else if(ABS(x)<ABS(y)){
		ans = (ABS(y)-ABS(x));
		if(x > 0 && y < 0)ans++;
		else if(x < 0 && y > 0)ans++;
		else if(x < 0 && y < 0)ans+=2;
	}
	else{
		ans = (ABS(x)-ABS(y));
		if(x < 0 && y > 0)ans++;
		else if (x > 0 && y > 0)ans+=2;
		else if (x > 0 && y < 0)ans++;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)

from bisect import bisect_left,bisect

ans = 0
for i in range(N):
    ans += bisect_left(A,B[i]) * (N-bisect(C,B[i]))

print(ans)

Measured memory_bytes: 106724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc172_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.Write(a + a*a + a*a*a);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27448