akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	solve()
}

func solve() {
	s := ReadLine()
	var ans string

	if s == "Sunny" {
		ans = "Cloudy"
	} else if s == "Cloudy" {
		ans = "Rainy"
	} else {
		ans = "Sunny"
	}
	fmt.Println(ans)
}

func ReadLine() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func ReadWords() []string {
	str := strings.Split(ReadLine(), " ")
	return str
}

func ReadLineInt64() []int64 {
	str := ReadWords()
	l := len(str)

	ret := make([]int64, l)

	for i, s := range str {
		ret[i] = s2i64(s)
	}
	return ret
}

func ReadLineInt() []int {
	values := ReadLineInt64()
	ret := make([]int, len(values))
	for i, v := range values {
		ret[i] = int(v)
	}
	return ret
}

func ReadInt() int {
	v := ReadLineInt()
	return v[0]
}
func ReadInt2() (int, int) {
	v := ReadLineInt()
	return v[0], v[1]
}
func ReadInt3() (int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2]
}
func ReadInt4() (int, int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2], v[3]
}

func ReadInt64() int64 {
	v := ReadLineInt64()
	return v[0]
}
func ReadInt64_2() (int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1]
}
func ReadInt64_3() (int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2]
}
func ReadInt64_4() (int64, int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2], v[3]
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int64
func Bool2Int64(b bool) int64 {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func Max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func Distance64(a, b int64) int64 {
	return Abs64(a - b)
}

// For int
func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func Max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 2532
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  double L;
  cin>>L;
  cout <<setprecision(10)<< ((double)(L*L*L))/27 << endl;
  return 0;
}



Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = 'War'
for i in range(c+1, d):
    if max(x) < i:
        if min(y) >= i:
            z = 'No War'
print(z)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    REP(i, n) cin >> a[i] >> b[i];
    REP(i, m) cin >> c[i] >> d[i];
    
    REP(i, n){
        int minDist=abs(a[i]-c[0]) + abs(b[i]-d[0]), chkpt=0;
        
        for(int j = 1; j < m; j++){
            int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(minDist > dist){
                minDist = dist; chkpt = j;
            }
        }
        cout << chkpt+1 << "\n";
    }
    return 0;
}

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

int main() {
  int N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  if(S.at(K-1)=='A') S.at(K-1)='a';
  else if(S.at(K-1)=='B') S.at(K-1)='b';
  else if(S.at(K-1)=='C') S.at(K-1)='c';
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define all(a) a.begin(),a.end()
#define i64 long long int
const double pi = 2*acos(0) ;
const int maxn = (i64)2e5+5;

int main()
{
    int n,i,j;
    cin>>n;
    i64 sum = 0;
    for(i = 1 ; i<n ; i++)
    {
        sum += i;
    }
    cout<<sum;

return 0;
}


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

int main()
{
    int n, k, q, p[100000] = {}, d;
    cin >> n >> k >> q;
  
  	for(int i = 0; i < q; i++)
    {
      	cin >> d;
      	d--;
      	p[d]++;
    }

    for(int i = 0; i < n; i++) cout << ((p[i] + k - q > 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[505][505];

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#') putchar('#');
			else if(j==1) putchar('#');
			else if(j==m) putchar('.');
			else if(i%2==1) putchar('#');
			else putchar('.'); 
		}
		puts("");
	}
	puts("");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#') putchar('#');
			else if(j==m) putchar('#');
			else if(j==1) putchar('.');
			else if(i%2==0) putchar('#');
			else putchar('.');
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N >> K;
    v.resize(0);
    for(int i = 0; i < N ; ++i){
        cin >> n;
        v.push_back(n);
    }
    sort(v.begin(), v.end());
    while(K and v.size() > 0){
        v.pop_back();
        --K;
    }
    if(v.size() == 0) cout << 0;
    else cout << accumulate(v.begin(), v.end(), 0LL);
      return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (N == i * j) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    int i,j,k,n,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    string a,s;
    cin>>a>>s;
    int len=s.size();
    int m=a.size();
    int arr[m+5][len+5];
    memset(arr,0,sizeof arr);
    for(i=1;i<=m;i++){
        for(j=1;j<=len;j++){
            if(s[j-1]==a[i-1])arr[i][j]=arr[i-1][j-1]+1;
            else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        }
    }
    string sub;
    i=m;
    j=len;
    while(i>0 and j>0){
        if(arr[i][j]==arr[i][j-1])j--;
        else if(arr[i][j]==arr[i-1][j])i--;
        else sub+=a[i-1],i--,j--;
    }
    reverse(sub.begin(),sub.end());

    cout<<sub<<endl;
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 35584
N=input().split(" ")
a=int(N[0])
b=int(N[1])
c=int(N[2])
if c-a-b<0:
    print("No")
else:
    if 4*a*b<c**2+a**2+b**2-2*a*c-2*b*c+2*a*b:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
C = [list(map(int,input().split())) for i in range(3)]
check = [[0]*3]*3
flag = "True"
while(flag=="True"):
    flag = "false"
    for i in range(3):
        if min(C[i][0],C[i][1],C[i][2])!=0:
            C[i][0] -= 1
            C[i][1] -= 1
            C[i][2] -= 1
            flag = "True"
            break
        elif min(C[0][i],C[1][i],C[2][i])!=0:
            C[0][i] -= 1
            C[1][i] -= 1
            C[2][i] -= 1
            flag = "True"
            break
if C == check:
    print("Yes")
else:
    print("No")

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

int main(){
  string s,t;
  
  cin >> s ;
  cin >> t ;
  //cout << t.substr(0,s.size());
  
  
  if (s == t.substr(0,s.size())){
    if (t.size() == s.size()+1){
        cout << "Yes";
    }
  }
  else {
    cout << "No";
  }
  
}


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

int main(){
    ll n,cnt=0,x,a,b,s;
	cin>>n>>a>>b>>s;
	for(int i=2;i<=n;i++)
	{
		cin>>x;
		cnt+=min((x-s)*a,b);
		s=x;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
def calc(s)
  c, l = 0, s.size
  if l.odd?
    c += 1 if s[l / 2] < 42
  end
  (0 .. l / 2 - 1).each do |i|
    if s[i] < 42
      c += 1 if (s[i] - s[l - i - 1]).abs != 1
    else
      c += 1 if s[i] != s[l - i - 1]
    end
  end
  c
end
1.times do
  s = gets.chomp.bytes
  puts calc(s)
end

Measured memory_bytes: 8628
using System;

namespace VisualStudioCode
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            string input = Console.ReadLine();
            foreach(char c in input)
            {
                if(c == '1')
                {
                    count++;
                }
            }

            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 13140
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

long long int h,n;
long long int f[2000005];
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	f[0]=0;	
	for(int i=1;i<=2000000;i++){
		f[i]=0x7ffffffffffffff;
	}
	cin>>h>>n;
	long long int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(int j=1;j<=n;j++){
		for(int i=a[j];i<=20000;i++){
			f[i]=min(f[i-a[j]]+b[j],f[i]);
		}
	}
	long long int minv=0x7ffffffffffffff;
	for(int i=h;i<=20000;i++){
		if(f[i]<minv){
			minv=f[i];
		}
	}
	cout<<minv;
}

Measured memory_bytes: 15872
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:x[2], reverse=True)
ht = a[0][2]
x = a[0][0]
y = a[0][1]
ans = True
for i in range(100+1):
    for j in range(100+1):
        h = ht + abs(x-i) + abs(y-j)
        ans = True
        for case in a:
            if not case[2] == max(h - abs(case[0] - i) - abs(case[1] - j), 0):
                ans = False
                break
        if ans:
            break
    if ans:
        break
print(i, j, h)


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

i = 0
ab = []
while i < n:
    a, b = map(int, input().split())
    ab.append((a, b)) 
    i += 1

ab.sort(key=lambda x: x[1])

i = 0
ans = 'Yes'
days = 0
while i < n:
    days += ab[i][0]
    if days > ab[i][1]:
        ans = 'No'
        break
    i += 1
print(ans)

Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

signed main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
  }

  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++)
  {
    a.at(i) = (i + 1) * N;
    b.at(N - i - 1) = (i + 1) * N;
  }
  for (int i = 0; i < N; i++)
  {
    a.at(p.at(i) - 1) += i;
  }

  for (int i = 0; i < N; i++)
  {
    cout << a.at(i);
    if (i == N - 1)
      cout << endl;
    else
      cout << " ";
  }
  for (int i = 0; i < N; i++)
  {
    cout << b.at(i);
    if (i == N - 1)
      cout << endl;
    else
      cout << " ";
  }
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

long long a, b;

int main()
{
	cin >> a >> b;
	if ((a + b) / 2 * 2 == (a + b))
	{
		cout << (a + b) / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


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


int main(){
  ll a,b; cin >> a >> b; ll tapsum = 1; ll count = 0;
  
  while(tapsum < b){
    tapsum += a-1;
    count++;
  }
  
  cout << count << endl;
}
  

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

typedef long long ll;
int main() {
  ll n, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  for(int i=0;i<n;i++) {
    cin >> w[i] >> v[i];
  }
  ll w1 = w[0];
  for(int i=0;i<n;i++)
    w[i] -= w1;

  ll dp[n+1][102][310];
  for(int i=0;i<n;i++) {
    for(int j=0;j<102;j++) {
      for(int k=0;k<310;k++) {
        dp[i][j][k] = 0;
      }
    }
  }
  for(int i=1;i<n+1;i++) {
    for(int j=1;j<102;j++) {
      for(int k=0;k<310;k++) {
        if(k-w[i-1] < 0)
          dp[i][j][k] = dp[i-1][j][k];
        else
          dp[i][j][k] = max(dp[i-1][j-1][k-w[i-1]] + v[i-1], dp[i-1][j][k]);
      }
    }
  }
  ll mx = 0;
  for(int j=1;j<101;j++) {
    for(int k=0;k<310;k++) {
      if(j*w1 + k <= W && mx < dp[n][j][k]) {
        mx = dp[n][j][k];
      }
    }
  }
  cout << mx << endl;
}



Measured memory_bytes: 25216
N,K=gets.split.map &:to_i
m=10**9+7
*I=x=y=1
s=0
[N,K+1].min.times{|i|s+=x*y
x*=N-i
y*=N-i+=1
I<<r=i<2?1:m/i*-I[m%i]%m
x=x*r%m
y=y*r%m}
p s%m

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

sample = [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(sample[k-1])

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

int N, M, T; double p;

int main(){
	scanf("%d%d",&N,&M);
	T = M*1900+(N-M)*100;
	p = 1/(double)(1<<M);
	printf("%d\n",(int)(T/p));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

Mint<> fact(int n){
    if(n == 1) return Mint<>(1);
    return Mint<>(n) * fact(n - 1);
}

signed main(){
    int n;
    cin >> n;
    ll x[n];
    rep(i,n){
        cin >> x[i];
    }
    Mint<> ans = 1;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(x[i] < cnt * 2 + 1){
            ans *= (cnt + 1);
            cnt--;
        }
        cnt++;
    }
    ans *= fact(cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
using System;
using static System.Console;

namespace AtCoder172
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveB();
        }

        static void SolveB()
        {
            var s = ReadLine();
            var t = ReadLine();
            var cnt = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) cnt++;
            }
            WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 27428
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main{

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		nPoint = in.nextInt();
		
		List<E> lE = new ArrayList<E>();
		for (int i=0;i<nPoint;i++) {
			for (int j=0;j<nPoint;j++) {
				int d = in.nextInt();
				if (d>=0) lE.add(new E(i, j, d));
			}
		}
		arEdge = lE.toArray(new E[0]);
		
		System.out.println(kruskal(0));
	}

	static int nPoint;
	static E[] arEdge;
	
	// s is index of start point
	static long kruskal(int s) {
		initUF(nPoint);
		Arrays.sort(arEdge);
		
		long res=0;
		Set<E> already = new HashSet<E>();
		int index = 0;
		while (already.size() != nPoint-1) {
			E next = arEdge[index++];
			if (!same(next.from, next.to)) {
				unite(next.from, next.to);
				already.add(next);
				res += next.dist;
			}
		}
		return res;
	}
	
	static class E implements Comparable<E> {
		int from; int to; int dist;
		public E(int from, int to, int dist) {this.from=from; this.to=to; this.dist=dist;}
		public int compareTo(E p) {return this.dist - p.dist;}
	}

	/// Union-Find
	static int[] par;
	static int[] rank;

	static void initUF(int n) {
		par = new int[n];
		rank = new int[n];
		for (int i=0;i<n;i++){
			par[i] = i;
			rank[i] = 1;
		}
	}
	
	static int root(int n) {
		if (par[n]==n) {
			return n;
		} else {
			return (par[n] = root(par[n]));
		}
	}
	
	static boolean same(int i, int j) {
		return root(i)==root(j);
	}

	static void unite(int i, int j) {
		int x = root(i);
		int y = root(j);
		
		if (rank[x]>rank[y]) {
			par[y] = x;
		} else {
			par[x] = y;
			if (rank[x]==rank[y]) rank[x]++;
		}
	}


}

Measured memory_bytes: 42236
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;

int R[4000] ={};
int G[4000] ={};
int B[4000] ={};

signed main(){
    cin >> N >> S;
    for(int i=N-1; i>=0; i--){
        if(i != N-1){
            R[i] = R[i+1];
            G[i] = G[i+1];
            B[i] = B[i+1];
        }
        if(S[i] == 'R') R[i]++;
        if(S[i] == 'G') G[i]++;
        if(S[i] == 'B') B[i]++;
    }
    ll ans = 0;
    rep(i, N){
        for(int j=i+1; j<N-1; j++){
            if(S[i] == S[j]) continue;
            if(S[i] != 'R' && S[j] != 'R'){
                ans += R[j+1];
                if(j+j-i < N && S[j+j-i] == 'R') ans--;
            }
            if(S[i] != 'G' && S[j] != 'G'){
                ans += G[j+1];
                if(j+j-i < N && S[j+j-i] == 'G') ans--;
            }
            if(S[i] != 'B' && S[j] != 'B'){
                ans += B[j+1];
                if(j+j-i < N && S[j+j-i] == 'B') ans--;
            }
        }
    }
    cout << ans << endl;
}


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


int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    int w[n];
    for (int i=0; i < n; i++)
        scanf("%d", &w[i]);
    
    int sum2 = 0;
    for (int i=0; i < n; i++)
        sum2 += w[i];

    int sum1 = 0;
    int d_min = 11111111;
    int d;
    for (int i=0; i < n-1; i++){
        sum2 -= w[i];
        sum1 += w[i];
        d = sum2 - sum1;
        if (d < 0)
            d *= -1;
        if(d < d_min)
            d_min = d;
    }

    printf("%d\n", d_min);
    

    
    return 0;
} 

Measured memory_bytes: 128
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
	int N;
  cin >> N;
  int a = N%10;
  if(a==2||a==4||a==5||a==7||a==9)cout << "hon" << endl;
  else if(a==0||a==1||a==6||a==8)cout << "pon" << endl;
  else cout << "bon" << endl;
  return 0;
  
  

    
    
  
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int a, b, c, count=0;

	scanf("%d %d %d", &a, &b, &c);

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

	return 0;
}

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

vector<int> ea[200001],eb[200001];
const int MAXN = 200000,MAXLOG = 18;
int p[MAXLOG+1][MAXN+1],dep[MAXN+1];
vector<int> e[MAXN+1];
void dfs(int x,int fa){
	p[0][x]=fa;
	for(int i=0;i+1<=MAXLOG;i++)
		p[i+1][x]=p[i][p[i][x]];
	for(int it:eb[x])
		if(it!=fa){
			dep[it]=dep[x]+1;
			dfs(it,x);
		}
}
int LCA(int a,int b){
   if(dep[a]>dep[b])   swap(a,b);
   int k=0;
   for(int i=dep[b]-dep[a];i;i/=2){
      if(i%2)  b=p[k][b];
      k++;
   }
   if(a==b) return a;
   for(int i=MAXLOG;i>=0;i--)
      if(p[i][a]!=p[i][b]){
         a=p[i][a];
         b=p[i][b];
      }
      return p[0][a];
}

int dist(int x,int y){
	int l=LCA(x,y);
	return dep[x]+dep[y]-2*dep[l];
}

int d[MAXN+1];
bool ok[MAXN+1];
int ans=0;
void dfs2(int x,int fa){
	if(d[x]>=dep[x])	return;
	if(ok[x]){
		cout<<-1<<endl;
		exit(0);
	}
	ans=max(ans,dep[x]);
	for(int it:ea[x])
		if(it!=fa){
			d[it]=d[x]+1;
			dfs2(it,x);
		}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		ea[u].emplace_back(v);
		ea[v].emplace_back(u);
	}
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		eb[u].emplace_back(v);
		eb[v].emplace_back(u);
	}
	dfs(y,0);
	for(int i=1;i<=n;i++)
		for(int it:ea[i])
			if(dist(i,it)>2)
				ok[i]=ok[it]=true;
	dfs2(x,0);
	cout<<ans*2<<endl;
}


Measured memory_bytes: 51964
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int[] hills = new int[10];
	for (int i = 0; i < 10; i++) {
	    hills[i] = scan.nextInt();
	}
	for (int i = 0; i < 10; i++) {
	    for (int j = i+1; j < 10; j++) {
		if (hills[i] < hills[j]) {
		    int tmp = hills[i];
		    hills[i] = hills[j];
		    hills[j] = tmp;
		}
	    }
	}
	System.out.println(hills[0]);
	System.out.println(hills[1]);
	System.out.println(hills[2]);
    }
}
    

Measured memory_bytes: 26324
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	bool is_input_ok = true;
	map<int, int> _map;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		_map[tmp]++;
	}
	if (n % 2)
	{
		if (_map[0] != 1)
			is_input_ok = false;
		for (int i = 2; i < n; i += 2)
			if (_map[i] != 2)
				is_input_ok = false;
	}
	else
		for (int i = 1; i < n; i += 2)
			if (_map[i] != 2)
				is_input_ok = false;
	if (is_input_ok)
		cout << repeat_squaring(2, n / 2, mod) << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 7300
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
use std::cmp::Ordering;
 
use std::cmp;
use std::cmp::min;
use std::collections::BTreeMap;
use std::process;
use std::cmp::Ord;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::mem;
 
use std::ops::{Deref, DerefMut, Index, IndexMut};
use std::any::{Any, TypeId};

fn main(){
    input!{
        k:usize,
    }
    fn f(n:usize)->usize{
        let mut res = 0;
        let mut n = n;
        while(n>0){
            res += n%10;
            n/=10;
        }
        res
    }
    fn g(n:usize)->f64{
        n as f64/ f(n) as f64
    }
    let mut x = 0;
    for _ in 0..k{
        x+= 1;
        let mut pow = 1;
        while(pow<x){
            while g(x+pow) < g(x){
                x+=pow;
            }
            pow*=10;
        }
        println!("{}", x);
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
bool isPrime(int x){
    int i = 2;
    bool ans = true;
    if(x==2){
        ans = true;
    }
    else{
        while(i<x){
            if(x%i==0){
                ans = false;
                break;
            }
            i++;
        }
    }
    return ans;
}
int main(){
    int x;
    cin >> x;
    while(1){
        if(isPrime(x)){
            break;
        }
        else{
            x++;
        }
    }
    cout << x <<endl;
}

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

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

      a = Integer.parseInt(sc.next());
      b = Integer.parseInt(sc.next());

      if(b%a == 0){
        System.out.println(a + b);
      }else{
        System.out.println(b - a);
      }
    }
    catch (Exception e) {
    }
  }
}


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

int main()
{
  long long w, h, x, y;
  scanf("%lld %lld %lld %lld", &w, &h, &x, &y);
  double area = (double)(w * h) / 2.0;
  int has_multiple_answer = x * 2 == w && y * 2 == h;
  printf("%lf %d\n", area, has_multiple_answer);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  string s;cin >> s;
  if(s.at(2) == s.at(3)&&s.at(4) == s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
	int N, M; cin >> N >> M;
	map<int, int> m;
	for(int i = 0; i < M; i++){
		int a, b; cin >> a >> b;
		m[a]++;
		m[b]++;
	}
	for(int i = 1; i <= N; i++){
		cout << m[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
int N, K;
int X[100];
int main()
{
    cin>>N>>K;
    for(int i = 0; i < N; ++i)
    {
        cin>>X[i];
    }
    int ans = 0;

    for(int i = 0; i < N; ++i)
    {
        int tmp = min(X[i], K - X[i]);
        //cout<<"TY"<<tmp<<endl;
        ans += tmp;
    }
    printf("%d\n", ans * 2);
    return 0;
}

//#include<cstdio>
//#include<algorithm>
//using namespace std;
//const int MAX_N = 100;
//int N, K;
//int X[MAX_N];
//int main()
//{
//    scanf("%d", &N);
//    scanf("%d", &K);
//    for(int i = 0; i < N; ++i)
//    {
//        scanf("%d", X+i);
//    }
//    int ans = 0;
//    for(int i = 0; i < N; ++i)
//    {
//        int tmp = min(X[i], K - X[i]);
//        ans += tmp;
//    }
//    printf("%d\n", ans * 2);
//    return 0;
//}


Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <vector>
#include "cmath"
#include <cstdlib>

using namespace std;
typedef long long ll;

const ll INF = 10000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;

    cin >> N >> W;

    vector<ll> w(N);
    vector<ll> v(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    vector<vector<ll> > dp(N, vector<ll>(sum + 1, INF));

    ll ans = 0;
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];
    if (N == 1) {
        if (dp[0][v[0]] <= W) {
            ans = v[0];
        }
    }


    for (int i = 1; i < N; i++) {
        for (int j = 0; j < sum+1; j++) {
            dp[i][j] = (j >= v[i]) ?
                       min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]) :
                       dp[i - 1][j];
            if (i == N-1) {
                if (dp[i][j] <= W) {
                    ans = j;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	map<string, int> m;
	for (int i=0; i<n; i++)
	{
		string s;
		cin >> s;
		m[s]++;
	}

	int maxv=0;
	for (auto const & v:m)
	{
		maxv = max(maxv, v.second);
	}
	for (auto const & v:m)
	{
		if (v.second == maxv)
		{
			cout << v.first << endl;
		}
	}
}

Measured memory_bytes: 25216
#include<iostream>
#include<set>
#include<string>
#include<algorithm>

using namespace std;

long long Q,H,S,D;
long long N;

int main(){

  cin>>Q>>H>>S>>D;
  cin>>N;

  long long m=min({8*Q,4*H,2*S,D});

  long long result;
  
  if(m==8*Q) result=N*4*Q;
  else if(m==4*H) result=N*2*H;
  else if(m==2*S) result=N*S;
  else {
    long long m_o=min({4*Q,2*H,S});
    if(N%2==0) result=N/2*D;
    else result=N/2*D+m_o;
  }

  cout<<result<<endl;
  
    
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
using namespace std;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(n) scanf("%s",&n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mes(a,b) memset(a,b,sizeof a)
#define mem(a,b,n) memset(a,b,n*sizeof(int))
#define uint unsigned int

const  int N = 1e5 + 1000;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;

int n;
int arr[N];

int main()
{
	int a, b;
	cin >> a >> b;
	arr[0] = a + b;
	arr[1] = a - b;
	arr[2] = a * b;
	sort(arr, arr + 3);
	cout << arr[2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <algorithm>
#include <functional>

const int N = 3000 + 10, MOD = 1000000007;

int n;
char s[N];

int a[N], b[N];

int main() {
  int m;
  scanf("%d%d %s", &n, &m, s + 1);
  for (int i = 1; i <= n; ++i) a[i] = b[i] = s[i] - '0';
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    std::sort(a + l, a + r + 1);
    std::sort(b + l, b + r + 1, std::greater<int>());
  }
  for (int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
  static int f[N][N];
  f[1][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int cur = f[i][j];
      if (!cur) continue;
      if (a[i] <= j && j <= b[i]) (f[i + 1][j] += cur) %= MOD;
      if (a[i] <= j + 1 && j + 1 <= b[i]) (f[i + 1][j + 1] += cur) %= MOD;
    }
  }
  printf("%d\n", f[n + 1][a[n]]);
  return 0;
}


Measured memory_bytes: 12416
n = int(input())
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))

ans = 0
for i in range(n):
    total = 0
    num = i
    while num >= 0:
        total += c1[num]
        num -= 1
    for j in range(i,n):
        total += c2[j]
    ans = max(ans, total)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

class UnionFind {
  vector<int> par;
  vector<int> sizes;
  public:
  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
  long long N, M;
  std::cin >> N >> M;
  vector<long long> x(M);
  vector<long long> y(M);
  vector<long long> z(M);

  for (int i = 0; i < M; i++) {
    std::cin >> x[i] >> y[i] >> z[i];
  }

  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    uf.unite(x[i]-1, y[i]-1);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (uf.find(i) == i) {
      ans++;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

ll op(ll a, ll b) {return a + b;}
ll e(){return 0LL;}

int main()
{
	int N, Q; cin >> N >> Q;
	vector<ll> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	atcoder::segtree<ll, op, e> tree(A);

	while(Q--) {
		int t, l, r; cin >> t >> l >> r;
		if(t == 0) {
			tree.set(l, r + tree.get(l));
		} else {
			cout << tree.prod(l, r) << endl;
		}
	}
}

Measured memory_bytes: 16424
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
SP = [[0, 0] for _ in range(N)]
for i in range(N):
	S, P = input().split()
	SP[i][0], SP[i][1] = S, int(P)

SPi = [(i+1, (S, P)) for i, (S, P) in enumerate(SP)]
SPi.sort(key=lambda x:(x[1][0], -x[1][1]))
print(*[x[0] for x in SPi], sep="\n")


Measured memory_bytes: 5200
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int asum = 0, bsum = 0;
  rep(i, n) {
    if (i % 2 == 0)
      asum += a[n - 1 - i];
    else
      bsum += a[n - 1 - i];
  }
  cout << asum - bsum << endl;
  return 0;
}


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

using namespace std;

int n, m;

int main(){
    cin >> n >> m;
    vector<int> v;

    for(int i=1; i<=m/2; i++){
        if(m % i == 0){
            v.push_back(i);
        }
    }
    v.push_back(m);
/*
    int right = v.size();
    int left = -1;
    while (right - left > 1){
        int mid = (left+right)/2;
        if (v[mid] * n <= m){
            left = mid;
        } else {
            right = mid;
        }
    }
*/
    cout << *(upper_bound(v.begin(), v.end(), m/n)-1)<< endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)

typedef long double D;
typedef valarray<D> vec;
typedef valarray<vec> mat;

inline int pivoting(mat &a,int k){
	int n=a.size(),p=k,ret=0;
	D cmax=abs(a[k][k]);
	range(i,k+1,n){
		if(abs(a[i][k])>cmax){
			p=i,ret=1;
			cmax=abs(a[i][k]);
		}
	}
	if(k!=p) swap(a[k],a[p]);
	return ret;
}

int forward(mat &a){
	int n=a.size(),m=a[0].size(),ret=0;
	rep(i,n-1){
		ret+=pivoting(a,i);
		if(abs(a[i][i])<1e-10) break;
		range(j,i+1,n){
			D coef=a[j][i]/a[i][i];
			range(k,i,m) a[j][k]-=coef*a[i][k];
		}
	}
	return ret;
}

vec back(mat &a){
	int n=a.size(),m=a[0].size();
	vec x(0.0,n);
	x[n-1]=1.0;
	for(int i=n-2;i>=0;i--){
		D sum=0.0;
		if(i+1<n) range(j,i+1,n) sum+=a[i][j]*x[j];
		x[i]=1.0/a[i][i]*(a[i][m-1]-sum);
	}
	return x;
}

int s,n,k;
D dp[11][120];

void init(int m){
	dp[0][0]=1.0;
	rep(i,k)rep(j,m+1){
		range(add,1,n+1){
			dp[i+1][j+add]+=1.0*dp[i][j]/n;
		}
	}
	return;
}

mat mul(mat a,mat b){
	int m=a.size();
	mat c(vec(0.0,m),m);
	rep(i,m)rep(j,m) rep(k,m) c[i][j]+=a[i][k]*b[k][j];
	return c;
}

mat power(mat a,int n){
	int m=a.size();
	mat b(vec(0.0,m),m);
	rep(i,m) b[i][i]=1.0;
	while(n){
		if(n&1) b=mul(b,a);
		a=mul(a,a);
		n>>=1;
	}
	return b;
}

int main(void){
	cin >> s >> n >> k;
	s=abs(s);
	if(n==1){
		if(s%k)
			cout << -1 << endl;
		else
			cout << s/k << endl;
		return 0;
	}
	int m=n*k+1;
	init(m);
	mat a(vec(0.0,m+1),m);

	rep(i,m) a[i][i]-=1.0;
	rep(i,m-1){
		int cur=i+1;
		rep(j,m){
			int tar=abs(cur-j);
			if(tar>0) a[i][tar-1]+=dp[k][j];
		}
	}
	rep(i,m) a[i][m-1]+=1.0,a[i][m]=0.0;

	forward(a);
	vec x=back(a);

	cout.precision(20);
	if(s<=n*k){
		cout << fixed <<  x[s-1] << endl;
		return 0;
	}

	mat b(vec(0.0,m),m);
	rep(i,m-1) b[i][i+1]=1.0,b[m-2][i]=dp[k][m-1-i];
	b[m-2][m-1]=b[m-1][m-1]=1.0;

	b=power(b,s-n*k);
	D ans=0.0;
	rep(i,m) ans+=b[m-2][i]*x[i];
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 2300
a = [int(num) for num in input().split()]
a1 = a[0]
a2 = a[1]
a3 = a[2]
ans = min(abs(a1-a2)+abs(a3-a2),abs(a3-a1)+abs(a3-a2))
ans = min(ans,abs(a1-a2)+abs(a3-a1))
ans = min(ans,abs(a2-a3)+abs(a3-a1))
ans = min(ans,abs(a3-a1)+abs(a1-a2))
ans = min(ans,abs(a3-a2)+abs(a2-a1))
print(ans)

Measured memory_bytes: 3064
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


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


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    # n, k, s = map(int, input().split())
    
    # v = n - k + 1
    # t = s // v
    # t2 = s % v
    # l = [t] * (v - 1) + [t + t2]
    # ansl = []
    # for i in range(n // len(l) + 1):
    #     ansl+=l
    
    
    
    # print(*ansl[:n])

    
    h = int(input())
    w = int(input())
    n = int(input())
    v = max(h, w)
    print((n - 1)//v + 1)


    


if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
 
    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        ll h[n];
        ll dp[n];
        REP(i,0,n)
        {
            ll t;
            cin>>t;
            h[i]=t;
        }
        dp[0]=0;
        dp[1]=abs(h[0]-h[1]);
        REP(i,2,n)
        {
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
        cout<<dp[n-1]<<'\n';
    }
 
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }

vector<vi> G;
vector<int> parent,depth,sz;
void go( int u, int p, int d ) {
  parent[u]=p;
  depth[u]=d;
  sz[u]++;
  for ( int v:G[u] ) {
    if ( v==p ) continue;
    go(v,u,d+1);
    sz[u]+=sz[v];
  }
}

int main() {
  int n;
  cin >> n;
  G.resize(n);
  parent.resize(n);
  depth.resize(n);
  sz.resize(n);
  rep(i,n-1) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  go(0,-1,0);
  int p=n-1;
  rep(i,(depth[n-1]-1)/2) {
    p=parent[p];
  }
  if ( sz[p]>=n-sz[p] ) {
    cout << "Snuke" << '\n';
  } else {
    cout << "Fennec" << '\n';
  }
  return 0;
}


Measured memory_bytes: 14720
#include <stdio.h>

int main(){
  int a[4];
  int ans=0;
  scanf("%d %d %d",&a[1],&a[2],&a[3]);
  
  for(int i=1;i<=3;i++){
    if(ans<a[i]){
      ans=a[i];
    }
  }
  
  ans=a[1]+a[2]+a[3]-ans;
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128