akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int K;
    string S;
    cin >> K >> S;
    int N=S.size();
    if(N<=K) cout << S << endl;
    else{
        rep(i,K) cout << S[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3656
///*
#include<iostream>
#include<string>
using namespace std;

int main() {

	string input;
	int change10 = 0, change01 = 0;
	cin >> input;

	for (int count = 0; count < input.length(); count++) {//1-0
		if (count % 2 == 0) { if (input[count] == '0')change10++; }//Left
		else if (input[count] == '1') { change10++; }//Right
	}

	for (int count = 0; count < input.length() ; count++) {//0-1
		if (count % 2 == 0) { if (input[count] == '1')change01++; }//Left
		else if (input[count] == '0'){change01++; }//Right
	}

	change01 < change10 ? cout << change01 << endl : cout << change10 << endl;
	//cout << change01 << endl; cout << change10 << endl;

	return 0;
}
//*/

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var answer = 0;
            for (var i = 0; i < x.Length; i++)
            {
                answer += Math.Min(x[i], K - x[i]) * 2;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28316
#include <iostream>
#include <climits>
#include <cstring>
#include <vector>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
const ll maxn = 100010;
vector <ll> adj[maxn];
ll dp[maxn];

ll dfs(ll p){
    if(dp[p] != -1) return dp[p];
    ll maxpath = 0;
    for(auto x: adj[p]){
        maxpath = max(maxpath,1+dfs(x));
    }
    return dp[p] = maxpath;
}
int main(){
    memset(dp,-1,sizeof dp);

    ll n,k;

    scanf("%lld %lld",&n,&k);

    for(ll i = 0; i < k; i++){
        ll a,b;
        scanf("%lld %lld",&a,&b);
        adj[a].push_back(b);
    }
    ll ans = -1;
    for(ll i = 1; i <= n; i++){
        ans = max(ans,dfs(i));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 8576
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  bool zero=false;
  ll count=0;
  rep(i,n){
    if(a[i]<0){
      count++;
    }
    if(a[i]==0)zero=true;
  }
  if(zero||count%2==0){
    rep(i,n)ans+=abs(a[i]);
    cout<<ans<<endl;
    return 0;
  }
  rep(i,n)a[i]=abs(a[i]);
  sort(a.begin(),a.end());
  ans=-a[0];
  rep(i,n-1)ans+=a[i+1];
  cout<<ans<<endl;
}
  
  

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
int n;
  int count;
  int ans=1;
char s[100010];
scanf("%d",&n);
scanf("%s",s);
  for(count=0;count<n;count++){
  if(s[count]!=s[count+1]){ans++;}
  }
  printf("%d\n",ans-1);
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define vec vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define vsort(vec) sort(vec.begin(),vec.end())
using namespace std;
signed main() {
	int ans = 0, w = 0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			ans += i - w;
			w++;
		}
	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


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

using namespace std;


using ll = long long;


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};



int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    combination c(N);

    mint ans;
   for (ll i = 0; i < N; i++) {
       ans += (c(i, K - 1) - c(N - i - 1, K - 1)) * mint(A[i]);
   }
   cout << ans.x << endl;

    return 0;
}

/*
   int main() {
   ll N, K;
   cin >> N >> K;
   vector<ll> A(N);
   for (ll i = 0; i < N; i++) {
   cin >> A[i];
   }
   sort(A.begin(), A.end());

   init(N);

   mint sigma_max, sigma_min;
   mint ans;
   for (ll i = 0; i < N; i++) {
   ans += (comb(i, K - 1) - comb(N - i - 1, K - 1)) * mint(A[i]);
// sigma_max += mint(A[i]) * comb(i, K - 1);
// sigma_min += mint(A[i]) * comb(N - i - 1, K - 1);
}
// mint ans = sigma_max - sigma_min;
cout << ans.a << endl;
}
*/


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int64_t, int64_t> mp;
  mp[0]++;
  int64_t res = 0, x = 0;
  for (int i = 0; i < N; i++) {
    x += A[i];
    res += mp[x]++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 17080
import java.util.Scanner;

public class Main {
	static int count=0;
	public static int merge(int[] A, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = A[left + i];

		}
		for (int i = 0; i < n2; i++) {
			R[i] = A[mid + i];

		}
		L[n1] = 1000000001;
		R[n2] = 1000000001;
		int i = 0;
		int j = 0;
		for (int k = left; k < right ; k++) {
			count++;
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i = i + 1;
			} else {
				A[k] = R[j];
				j = j + 1;
			}
			
		}
		return count;
		
	}

	public static int mergeSort(int[] A, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			count = merge(A, left, mid, right);
		}
		return count;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] numbers = new int[n];
		for (int i = 0; i < n; i++) {
			numbers[i] = scanner.nextInt();
		}
		count = mergeSort(numbers, 0, n);
		System.out.print(numbers[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + numbers[i]);
		}
		System.out.println();
		System.out.println(count);
		scanner.close();
	}

}



Measured memory_bytes: 168656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int power3(int n){
    int ans = 1;
    REP(i, n) ans *= 3;
    return ans;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ng_cnt = 1;
    REP(i, n){
        int a;
        cin >> a;
        if(a % 2 == 1){
            ng_cnt *= 1;
        }else{
            ng_cnt *= 2;
        }
    }
    cout << power3(n) - ng_cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 100000000 

void func()
{
    ll n;
    cin>>n;
    ll a[1000000]={0};
    loop(x,1,150){
        loop(y,1,150){
            loop(z,1,150){
                ll t=x*x + y*y + z*z +x*y + y*z +z*x;
                a[t]++;
            }
        }
    }
    loop(i,1,n+1){
        cout<<a[i]<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 11416
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int k;
    cin >> k;
    int s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if(s-(i+j) >= 0 && s - (i+j) <= k) {
                ans++;
                //cout << i << j << std::endl;
            }
        }
    }
    cout << ans << std::endl;
    return 0;
}

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

int main() {
  long long x,k,d;
  cin >> x >> k >> d;

  long long n = abs(x) / d;

  if(k > n){
    if(x >= 0){
      long long x2 = x - d*n;
      if(abs(x2) > abs(x2-d)){
        x2 -= d;
        n++;
      }

      if((k-n) % 2 == 0){
        cout << abs(x2) << endl;
      }
      else{
        cout << abs(d - abs(x2)) << endl;
      }
    }
    else{
      long long x2 = x + d*n;
      if(abs(x2) > abs(x2+d)){
        x2 += d;
        n++;
      }

      if((k-n) % 2 == 0){
        cout << abs(x2) << endl;
      }
      else{
        cout << abs(d - abs(x2)) << endl;
      }
    }
  }
  else{
    if(x >= 0){
      cout << abs(x - d*k) << endl;;
    }
    else{
      cout << abs(x + d*k) << endl;
    }
  }

  return 0;
}

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

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define MOD 1000000007

int main() {

	int n; cin >> n;
	vector<vector<int>> a(n, vector<int>(n, 0));
	for (int i = 0; i <= n - 1; i++) for (int j = 0; j <= n - 1; j++) cin >> a[i][j];

	vector<vector<long long>> dp(n, vector<long long>((1 << n), 0));
	long long ans = 0;

	for (int i = 0; i <= n - 1; i++) {

		for (int m = 0; m <= (1 << n) - 1; m++) {
			if (__builtin_popcount(m) != i + 1) continue;

			for (int j = 0; j <= n - 1; j++) {

				if (a[i][j] == 1 and (m & (1 << j)) != 0) {

					if (i == 0) dp[i][m] = 1;

					else {
						dp[i][m] += dp[i - 1][m - (1 << j)];
						if (dp[i][m] >= MOD) dp[i][m] %= MOD;
					}

				}
			}

			if (i == n - 1) {
				ans += dp[i][m];
				if (ans >= MOD) ans %= MOD;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 363776
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;



int main(){

	int n,k;
	cin>>n>>k;
	int p[n];
	for(int i=0;i<n;i++)cin>>p[i];

	double e[n];
	for(int i=0;i<n;i++){
		e[i]=(p[i]+1)/2.0;
	}

	double max=0,ans=0;
	double sum[n-k];
	for(int i=0;i<k;i++){
		sum[0]+=e[i];
	}
	max = sum[0];
	for(int i=1;i<n-k+1;i++){
		sum[i]=sum[i-1]-e[i-1]+e[i+k-1];
		if(max<sum[i])max=sum[i];
	}

	printf("%.6lf",max);
	cout<<endl;

	return 0;
}


Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n + 1)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

int main(void)
{
    int n, k;
    factorial f(2000);

    cin >> n >> k;

    for (int i = 1; i <= k; i++)
    {

        cout << (f.comb(n - k + 1, i) * f.comb(k - 1, i - 1)) % MOD << endl;
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int head[100001],to[100001],nxt[100001];
int f[100001];
int tot;
int n,m;
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot; 
}
int dfs(int index)
{
	if(f[index]!=-1)
		return f[index];
	f[index]=0;
	for(int i=head[index];i;i=nxt[i])
	{
		int v=to[i];
		f[index]=max(f[index],dfs(v)+1);
	}
	return f[index];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v);
	}
	memset(f,0xff,sizeof(f));
	for(int i=1;i<=n;i++)
	{
		f[0]=max(f[0],dfs(i));
	}
	printf("%d",f[0]);
}

Measured memory_bytes: 3200
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    if k == 1:
        for i in range(n):
            print(i+1,i+1+n,i+1+2*n)
        return
    a = [i+k for i in range(n)]
    b = [i+n+k for i in range(n)]
    c = [i+2*n+k for i in range(n)]
    if n%2 == 0:
        ans = [[a[i],b[(i+n-k)%n],c[2*i]] if 2*i < n else [a[i],b[(i+n-k)%n],c[(2*i+1)%n]] for i in range(n)]
    else:
        ans = [[a[i],b[(i+n-k)%n],c[(2*i)%n]] for i in range(n)]
    for a,b,c in ans:
        if a+b > c:
            print(-1)
            return
    for a in ans:
        print(*a)
    return
def test():
    def change(m):
        res = []
        for i in range(3*n):
            res.append(m%n)
            m //= n
        return res

    def check(a):
        return a[0]+a[1] <= a[2]
    n,k = LI()
    l = [k+i for i in range(3*n)]
    print(n**(3*n))
    f = [change(i) for i in range(n**(3*n))]
    for k in f[::-1]:
        if all([k.count(i) == n for i in range(n)]):
            a = [[l[i] for i in range(3*n) if k[i] == j] for j in range(n)]
            if all([check(i) for i in a]):
                print(a)
#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 62336
'use strict'
function Main(input){
  input=input.split(' ');
  var A=parseInt(input[0]);
  var B=parseInt(input[1]);
  var yakusu=(B%A===0)?true:false;
  if(yakusu){
    console.log(A+B);
    return;
  }
  console.log(B-A);
} 



Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
from sys import stdin
readline = stdin.readline

N, M = map(int, readline().split())

ab = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, readline().split())
    ab[a].append(b)

dp = [0] * (N + 1)
for i in range(1, N + 1):
    dp[i] = max(dp[i], dp[i - 1])
    for j in ab[i]:
        dp[j] = max(dp[j], dp[i] + 1)

print(dp[N])


Measured memory_bytes: 23176
n = int(input())
li = []
for i in range(n):
    li.append(list(input().split()))
    li[i].append(i + 1)
    li[i][1] = int(li[i][1])
li.sort(key=lambda x: x[1], reverse = True)
li.sort(key=lambda x: x[0])
for i in li:
    print(i[2])

Measured memory_bytes: 3060
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn gcd(a: usize, b: usize) -> usize {
    let mut x = a;
    let mut y = b;
    while y != 0 {
        let tmp = y;
        y = x % y;
        x = tmp;
    }
    a * b / x
}

fn main() {
    let (n, m) = {
        let v: Vec<usize> = read()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        (v[0], v[1])
    };
    let s: Vec<char> = read().trim().chars().collect();
    let t: Vec<char> = read().trim().chars().collect();

    let len = gcd(n, m);
    let num_s = len / n;
    let num_t = len / m;
    let step = gcd(num_s, num_t);
    let mut res = true;
    let mut i = 0;
    while i < len {
        if s[i / num_s] != t[i / num_t] {
            res = false;
            break;
        }
        i += step
    }

    if res {
        println!("{}", len);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
/*
AizuOnline A0102
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int sheet[11][11];
int N;
//
print_sheet()
{
  int i,j;

  for(i=0;i<=N;i++)
    {
    for(j=0;j<=N;j++)
      {
     	printf("%5d",sheet[i][j]);

      }
    printf("\n");
    }
}
main()
{
  int i,j,value;
  
  while(EOF != scanf("%d",&N) && N)
    {
  
      for(j=0;j<=N;j++)
	sheet[N][j]=0;
      for(i=0;i<N;i++)
	{
	  sheet[i][N]=0;
	  for(j=0;j<N;j++)
	    {
	      scanf("%d ",&value);
	      sheet[i][j] = value;
	      sheet[i][N] += value;
	      sheet[N][j] += value;
	      sheet[N][N] += value;
	    }
	}
      print_sheet();
    }
return(0);
}

Measured memory_bytes: 616
import fractions
a, b, c, d = map(int, input().split())
ans = b - (b//c)
ans -= b//d
ans += b//((c*d)//fractions.gcd(c, d))
x = (a-1)-((a-1)//c)
x -= (a-1)//d
x += (a-1)//((c*d)//fractions.gcd(c,d))
ans -= x
print(ans)


Measured memory_bytes: 5048
#include<stdio.h>

void run(void){
  int x,p;
  scanf("%d%d",&x,&p);
  double q=(double)p/100;
  if(x%2==0){
    x/=2;
    printf("%.7f\n",x/q);
  } else {
    double ans=1+q*((x-1)/2/q)+(1-q)*((x+1)/2/q);
    printf("%.7f\n",ans);
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    static FastReader sc = new FastReader();
    static final double E = 0.000000001;
    static final long MOD = (long) (1e9 + 7);
    static final long MAX = (long) 1e9;

    public static void main(String[] args) throws IOException {
        long a = sc.nextLong();
        long b = sc.nextLong();
        long gcd = gcd(a, b);
        int res = 1;
        if(gcd%2 == 0)
        {
            res++;
            while(gcd%2 == 0)
            {
                gcd/=2;
            }
        }
      	long sqrt = (long)Math.sqrt(gcd);
        for (int i = 3; i<=sqrt ; i+=2) {
            if(gcd % i == 0)
            {
                res++;
                while(gcd%i == 0)
                    gcd/=i;
            }
        }
        if(gcd > 2)
            res++;
        System.out.println(res);
    }

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

    }


}


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

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


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

using namespace std;

const int N = 1e5+15;

vector<int> adj[N];

int deg[N];

bool vis[N];
int dfs(int x,int p){
    int u,i,r;
    if(deg[x]>=3){
        return x;
    }
    
    for(i=0;i<adj[x].size();++i){
        u = adj[x][i];
        if(vis[u] || u==p)continue;
    
        if( (r = dfs(u,x) )!=-1)return r;
    }
    
    return -1;
}   

int dfs2(int x,int p){

   int i,u,r;

   int ret= 0;

   int line = 0;

   int child = deg[x];
   vis[x]= 1;

   for(i=0;i<adj[x].size();++i){
        u= adj[x][i];
        
        if(vis[u])continue;
        
        --deg[u];
        
       r = dfs2(u,x);
       ret+= r;
       
       if(r==0)
           ++line;
   }
   
   ret+= max(line-1,0);
   return ret;
}

int main(){
    int n,i,a,b;
    cin>>n;
    for(i=0;i<n-1;++i){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
        ++deg[a],++deg[b];
    }
    int R = dfs(0,-1);

    if(R==-1){
        cout<<1<<endl;
    }
    else{
        cout<<dfs2(R,-1)<<endl;
    }
}


Measured memory_bytes: 10752
n=int(input())
ans=0
#約分
def make_divisors(n):  
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
l=make_divisors(n)
for li in l:
  m=(n-li)//li
  if li <= m-1:
    ans+=m
print(ans)

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

vector<vector<int>> graph(8,vector<int>(8,0));
int N, M;
int cnt = 0;
vector<int> seen(8,0);

void dfs(int now, int depth){


    // 探索する頂点が探索済ならreturn
    if(seen[now] == 1){
        return;
    }

    // 全部の頂点を探索済ならcntをインクリメントする
    if(depth == N){
        cnt += 1;
        return;
    }

    seen[now] = 1;
    for(int i = 0; i < N; i++){
        if(graph[now][i] == 1) {
            int next = i;
            dfs(next, depth + 1);
        }
    }
    seen[now] = 0;
    return;
}

int main(){
    cin >> N >> M;
    vector<int> a(M), b(M);
    rep(i, M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    rep(i, M){
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }

    dfs(0, 1);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def check_rote(a, b, t, x, y):
    cost_min = abs(a - x) + abs(b - y)
    if cost_min <= t and (t - cost_min) % 2 == 0:
        return True
    else:
        return False

n = int(input())
rotes = []

for i in range(n):
    rotes.append(tuple((int(x) for x in input().split())))

copy_t = 0
copy_a = 0
copy_b = 0

for i in rotes:
    t, a, b = i
    if not check_rote(a, b, t - copy_t, copy_a, copy_b):
        print("No")
        break
    copy_t = t
    copy_a = a
    copy_b = b
else:
    print("Yes")


Measured memory_bytes: 17292
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#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++)
int par[100000];
int rank1[100000];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find1(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find1(par[x]);
	}
}
void unite1(int x, int y) {
	x = find1(x);
	y = find1(y);
	if (x == y)return;
	if (rank1[x] < rank1[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank1[x] == rank1[y])rank1[x]++;
	}
}
bool same(int x, int y) {
	return find1(x) == find1(y);
}
struct edge { int u, v, cost; };
bool comp(const edge&e1, const edge&e2) {
	return e1.cost < e2.cost;
}
edge es[100000];
int V, E; vector<int>v;
void kruskal() {
	sort(es, es + E, comp);
	init(V); v.clear();
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite1(e.u, e.v);
			v.push_back(e.cost);
		}
	}
}
int main() {
	while (cin >> V >> E, V) {
		int x, y, z;
		rep(i, E) {
			cin >> x >> y >> z; x--; y--;
			es[i] = { x,y,z };
		}
		kruskal();
		cout << v[V/ 2-1] << endl;
	}
	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0) return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}

long long ADD(long long x, long long y) { return (x+y) % MOD; }
long long SUB(long long x, long long y) { return (x-y+MOD) % MOD; }
long long MUL(long long x, long long y) { return x*y % MOD; }
long long POW(long long x, long long e) { long long v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
long long DIV(long long x, long long y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


void Main() {
    int X, Y;
    cin >> X >> Y;

    int a, b;
    bool flag = true;
    if ((X + Y) % 3 != 0){flag = false;}
    a = Y - (X + Y) / 3;
    b = X - (X + Y) / 3;
    if (a < 0 || b < 0){flag = false;}
    if (flag){
        if (a == 0 || b == 0){
            cout << 1 << endl;
        } else {
            combination_init();
            cout << combination2(a+b, a) << endl;
        }
    } else {
        cout << "0" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12160
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;


int C[1000];
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		C[s[i]]++;
	}
	for (int i = 'a'; i <= 'z'; i++) {
		if (C[i] == 0) {
			cout << char(i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

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

using namespace std;

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

  int x;
  cin >> x;
  unordered_set<int> beki;
  beki.insert(1);
  for (int i = 2; i < 100; ++i) {
    for (int j = 2;; ++j) {
      int t = pow(i, j);
      if (1000 < t)
        break;
      beki.insert(t);
    }
  }
  for (int i = x; 0 < i; --i) {
    if (beki.find(i) != beki.end()) {
      cout << i << "\n";
      break;
    }
  }
}


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

int a[4];

int main(void){
    string str;
    cin>>str;
    a[0]=str[0]-'0';
    a[1]=str[1]-'0';
    a[2]=str[2]-'0';
    a[3]=str[3]-'0';
    string s=to_string(a[0]);
    int check=a[0];
    for(int bit=0;bit<(1<<3);++bit){
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                check+=a[i+1];
                s+="+";
                s += to_string(a[i+1]);
            }else{
                check-=a[i+1];
                s+="-";
                s += to_string(a[i+1]);
            }
        }
        if(check==7){
            s += "=7";
            cout << s << endl;
            break;
        }else{
            s=to_string(a[0]);
            check=a[0];
        }
        }
        return 0;
}


Measured memory_bytes: 764
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

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


    for(int m = 1; m <= n; m++){
        int temp = m * (m-1) / 2;
        if((n-m) <= temp){
           M = m;
           break;
        }
    }

    cout << M << endl;
    int s = n - M;
    M--;
    while(s>0){
        if(M<=s){
            cout << M << endl;
            s -= M;
            M--;
        }else{
            M--;
        }
    }
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int N = Integer.parseInt(str[0]);
		int X = Integer.parseInt(str[1]);
		int[] L = new int[N];
		String[] Lstr = reader.readLine().split(" ");
		for (int i = 0; i < N; i++) {
			L[i] = Integer.parseInt(Lstr[i]);
		}
		int ans = 0;
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += L[i];
			if (sum > X) {
				ans = i+1;
				break;
			}
		}
		if (X >= sum) {
			ans = N+1;
		}
		System.out.println(ans);
		
	}
}


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

typedef long long ll;

 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = min(b, d) - max(a, c);
  if(ans < 0 ) ans = 0;
  cout << ans << endl;
  return 0;
}

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

main()
{
  int N,i,a,b,c;
  scanf("%d",&N);
  
  a = N/100;
  b = N%100 / 10;
  c = N%10;
  if(a>=b)
  {
    if(a==b&&b<c)
      N = (a+1)*111;
    else
      N = a*111;
  }
  else
  {
    N = (a+1)*111;
  }
  printf("%d\n",N);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int count = Integer.parseInt(scanner.nextLine());
        
        boolean[] club = new boolean[]{false,false,false,false,false,false,false,false,false,false,false,false,false};
        boolean[] spade = new boolean[]{false,false,false,false,false,false,false,false,false,false,false,false,false};
        boolean[] heart = new boolean[]{false,false,false,false,false,false,false,false,false,false,false,false,false};
        boolean[] dia = new boolean[]{false,false,false,false,false,false,false,false,false,false,false,false,false};
        
        for (int i=0; i<count; i++) {
            String[] cards = scanner.nextLine().split(" ");
            String symbol = cards[0];
            int number = Integer.parseInt(cards[1]) - 1;
            
            switch (symbol) {
                case "S":
                    spade[number] = true;
                    break;
                case "H":
                    heart[number] = true;
                    break;
                case "C":
                    club[number] = true;
                    break;
                case "D":
                    dia[number] = true;
                    break;                
                default:
                    break;
            }
        }
        output(spade, "S");
        output(heart, "H");
        output(club, "C");
        output(dia, "D");
    }
    
    private static void output(boolean[] bools, String symbol) {
        for (int i=0; i<bools.length; i++) {
            if (bools[i] == false) {
                System.out.println(symbol + " " + (i+1));
            }
        }
    }
}


Measured memory_bytes: 26240
while true
    num = gets.to_i
    if num == 0
        break
    else
        numbers = gets.split.map(&:to_f)
        abverage = numbers.reduce(:+)/numbers.length
        stdv = 0
        numbers.each do |num|
            stdv += (num-abverage)**2
        end
        puts "#{sprintf("%.4f",(stdv/numbers.length)**0.5)}"
    end
end


Measured memory_bytes: 6972
def c_tax_increase():
    from math import floor, ceil
    A, B = [int(i) for i in input().split()]
    lower = ceil(max(25 * A / 2, 10 * B))
    upper = floor(min(25 * (A + 1) / 2, 10 * (B + 1)))
    return lower if lower < upper else -1

print(c_tax_increase())

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area
const int MAX = 2100;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//main area
int main(){
    COMinit();
    int s;
    cin >> s;
    ll ans = 0;
    rep(i,s){
        int k = s - 3*(i+1);
        ans += COM(k+i, i);
        ans %= MOD;
    }
    cout << ans << endl;
}
/*



*/

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
signed main(){
	
	ll N;
	cin>>N;

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

	ll ans=N/(A+B)*A;

	//cout<<ans<<endl;

	ans+=min(A, N%(A+B));

	cout<<ans<<endl;

    return 0;
}


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

map<int, int> m;
int N, M, s, c, result;

int main() {
  cin >> N >> M;
  result = 1;
  for (int i=0; i<M; i++) {
    cin >> s >> c;
    if (m.find(s) != m.end()) {
      if (m[s] != c) {
        result = 0;
        break;
      }
    } else {
      if (N > 1 && s == 1 && c == 0) {
        result = 0;
        break;
      } else {
        m[s] = c;
      }
    }
  }
  if (m.find(1) == m.end() && N > 1) {
    m[1] = 1;
  }
  if (result) {
    for (int i=1; i<=N; i++) {
      cout << m[i];
    }
  } else {
    cout << -1;
  }
  cout << endl;
  return 0;
}


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

int main(){
  int n;
  int sum,maxv,minv,tmp;

  while(cin >> n){
    if(n==0)break;
    
    cin >> sum;
    maxv = minv = sum;
    for(int i=0;i<n-1;i++){
      cin >> tmp;
      sum += tmp;
      if(maxv < tmp)maxv = tmp;
      if(minv > tmp)minv = tmp;
    }

    cout << (sum-maxv-minv)/(n-2) << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long long n;
long long srd[1000001]={2};
void dg(long long n){
	srd[n]=srd[n-1]*2+2;
	return;
}    
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		dg(i);
	cout<<srd[n];
	return 0;
}

Measured memory_bytes: 384
def modpow(a, b, mod=1):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


MOD = 10 ** 9 + 7
X, Y = map(int, input().split())

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
elif (2 * X - Y) // 3 < 0 or (2 * Y - X) // 3 < 0:
    print(0)
else:
    A, B = (2 * X - Y) // 3, (2 * Y - X) // 3
    ans = 1
    for n in range(A + B, A, -1):
        ans = ans * n % MOD
    for n in range(1, B + 1):
        ans = ans * modpow(n, MOD - 2, MOD) % MOD
    print(ans % MOD)


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

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

  if (B < A) {
    cout << 0 << endl;
    return 0;
  }

  if (A == B) {
    cout << 1 << endl;
    return 0;
  }

  ll l = A * (N - 1) + B;
  ll r = B * (N - 1) + A;
  ll ans = max(r - l + 1, ll(0));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    vector<int> b(n, 0);
    for (int j = 0; j < min(k, 100); j++){
        if(j != 0)
        b.assign(n, 0);
        for (int i = 0; i < n; i++) {
            int l = max(0, i - a[i]);
            int r = min(n - 1, i + a[i]);
            b[l]++;
            if (r + 1 < n)
                b[r + 1]--;
        }
        for (int i = 1; i < n; i++)
            b[i] += b[i - 1];
        for(int i = 0; i < n; i++)
            a[i] = b[i];
    }
    for (int i = 0; i < n; i++)
        cout << (b[i] >= n ? n : b[i]) << (i == n - 1 ? "\n" : " ");
}


Measured memory_bytes: 4764
#include <iostream>

using namespace std;

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

  int day = 0;
  int sum = 0;

  while (sum < c) {
    ++day;
    sum += (day % 7 == 0) ? a + b : a;
  }

  cout << day << endl;
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n + 1];
        int[] x = new int[n + 1];
        int[] y = new int[n + 1];
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        for (int i = 1; i <= n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        boolean success = true;
        for (int i = 1; i <= n; i++) {
            int T = t[i] - t[i - 1];
            int a = Math.abs(x[i] - x[i - 1]);
            int b = Math.abs(y[i] - y[i - 1]);

            int m = T - (a + b);
            if (m < 0 || m % 2 != 0) {
                success = false;
                break;
            }
        }
        if (success){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
    int r, c;
    cin >> r >> c;

    int numbers[r + 1][c + 1];
    for (int j = 0; j <= c; j++) {
        numbers[r][j] = 0;
    }

    for (int i = 0; i < r; i++) {
        numbers[i][c] = 0;
        for (int j = 0; j < c; j++) {
            cin >> numbers[i][j];
            numbers[i][c] += numbers[i][j];
            numbers[r][j] += numbers[i][j];
            numbers[r][c] += numbers[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j < c; j++) {
            cout << numbers[i][j] << " ";
        }
        cout << numbers[i][c] << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int r; cin >> r;

    cout << r*r ;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

// int N = 4;
// int d[] = {10, 8, 8, 6};

int N;

int main() {
    cin >> N;
    int d[N];

    rep(i, N) {
        cin >> d[i];
    }
    sort(d, d + N, greater<int>());

    int result = 1;
    rep(i, N - 1) {
        if (d[i] > d[i+1]) {
            result++;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int b,c;

    // スペース区切りの整数の入力
    scanf("%d %d",&b,&c);
  
  	if ((b * c) % 2 == 0)
    {
      printf("Even\n");
    }
  	else
    {
      printf("Odd\n");
    }

    return 0;
}


Measured memory_bytes: 128
import bisect
n = int(input())
l = [int(x) for x in input().split()]
l.sort()

ans = 0

for i in range(n):
    for j in range(i+1, n):
        a = l[i] + l[j]
        ans += max(bisect.bisect_left(l,a) - j - 1, 0)

print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, re

def main():
    a = list(map(int, input().split(" ")))

    a.sort()

    ans = 0
    for i in range(0, len(a)-1):
        ans = ans + a[i+1] - a[i]

    print(ans)

    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3188