akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const long long INF = 1000000000000;

int N;
long long h[100100];

long long dp[100100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];

    for (int i = 0; i < N; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    for (int i = 1; i < N; i++) {
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
from math import sqrt, gcd
import sys


def osk_a(M):
    p = [i for i in range(M+1)]
    for x in range(2, int(sqrt(M))+1):
        if p[x] == x:
            for y in range(2*x, M+1, x):
                if p[y] == y:
                    p[y] = x
    return p


def g(a):
    g = 0
    for x in a:
        g = gcd(g, x)
    return g


def main():
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    if g(a) > 1:
        print("not coprime")
        exit()
    p = osk_a(10**6)
    chk = set()
    t = a[0]
    while t > 1:
        chk.add(p[t])
        t //= p[t]

    for x in a[1:]:
        tmp = set()
        while x > 1:
            tmp.add(p[x])
            x //= p[x]
        if chk.isdisjoint(tmp):
            chk |= tmp
        else:
            print("setwise coprime")
            exit()
    print("pairwise coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 113044
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//A	Frog 1
public class Main {

	static void chMin(int[] dp, int i, int v) {
		if (dp[i] > v) {
			dp[i] = v;
		}
	}

	static void chMax(int[] dp, int i, int v) {
		if (dp[i] < v) {
			dp[i] = v;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Integer> hList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			hList.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int[] dp = new int[N];
		for (int i = 0; i < N; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		dp[0] = 0;

		for (int i = 1; i < N; i++) {
			chMin(dp, i, dp[i - 1] + Math.abs(hList.get(i - 1) - hList.get(i)));
			if (i > 1) {
				chMin(dp, i, dp[i - 2] + Math.abs(hList.get(i - 2) - hList.get(i)));
			}
		}

		System.out.println(dp[N - 1]);
	}

}


Measured memory_bytes: 47252
#[allow(dead_code)]
fn main() {
    let (n, m) = i::u2();
    let h = i::uv(n);
    let ab = i::uv2(m);

    let mut s = vec![HashSet::new(); n + 1];
    for i in 0..m {
        let (a, b) = ab[i];
        s[a].insert(b);
        s[b].insert(a);
    }

    let mut count = 0;
    'case: for i in 1..=n {
        let height = h[i - 1];
        for &k in &s[i] {
            let target = h[k - 1];
            if height <= target {
                continue 'case;
            }
        }
        count += 1;
    }
    println!("{}", count);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;

int32_t main() {
IOS;
int n;
cin>>n;
int above=0;
vector<int> cnt(13,0);
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        if(a>=1 and a<=399)cnt[1]=1;
        else if(a>=400 and a<=799)cnt[8]=1;
        else if(a>=800 and a<=1199)cnt[2]=1;
        else if(a>=1200 and a<=1599)cnt[3]=1;
        else if(a>=1600 and a<=1999)cnt[4]=1;
        else if(a>=2000 and a<=2399)cnt[5]=1;
        else if(a>=2400 and a<=2799)cnt[6]=1;
        else if(a>=2800 and a<=3199)cnt[7]=1;
        else above++;
    }
    int ans=0;
    for (int i = 1; i <=8; ++i) {
        ans+=cnt[i];
    }
    cout<<max(1ll,ans)<<" "<<ans+above<<endl;
}

Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
  print("YES")
else:
  if w>v:
    print("NO")
  else:
    if (v-w)*t<abs(b-a):
      print("NO")
    else:
      print("YES")

Measured memory_bytes: 9180
/**
 * Contest : AtCoder Beginner Contest 160
 * Contest URL : https://atcoder.jp/contests/abc160
 * Problem : B - Golden Coins
 * Problem URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

void solve() {
	ll x, ans;
	cin >> x;
	ans = (ll) 1000 * (x / 500);
	x %= 500;
	ans += (ll) 5 * (x / 5);
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  2*1e9;

int main(){
    int N,W;
    cin>>N>>W;
    int VM = 100*N+1;
    vector<vector<int> > dp(N+1,vector<int>(VM,inf) );
    dp[0][0] = 0;
    int res = 0;
    vector<int> v(N),w(N);
    for(int i=0;i<N;i++)cin>>v[i]>>w[i];
    for(int i=0;i<N;i++){
	for(int j=0;j<VM;j++){
	    if( v[i] <= j ){
		dp[i+1][j] = min(dp[i+1][j] , dp[i][j-v[i]] + w[i] );
	    }
	    dp[i+1][j] = min(dp[i+1][j],dp[i][j]) ;
	}
    }
    for(int i=0;i<VM;i++) if( dp[N][i] <= W ) res = max(res,i);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 6832
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    int max = 0;
    for (char c : s)
    {
        if (c == 'I')
        {
            count++;
            if (max < count)
            {
                max = count;
            }
        }
        else
        {
            count--;
        }
    }
    cout << max << "\n";
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        for(int i = 0;i<n;i++){
            t[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        int [][] px = new int[m][2];
        for(int i = 0;i<m;i++){
            px[i][0] = sc.nextInt();
            px[i][1] = sc.nextInt();
        }
        int goukei = 0;
        for(int i = 0;i<n;i++){
            goukei += t[i];
        }
        for(int i = 0;i<m;i++){
            System.out.println((goukei - t[px[i][0]-1] + px[i][1]));
        }
        sc.close();
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 1e6 + 10;
int pre[N];
bool prime[N];
bool prime_shieve(){
	memset(prime, true, sizeof(prime));
	prime[0] = false, prime[1] = false;
	for(int i = 2; i <= 1000; i ++)
		if(prime[i])
			for(int j = i * i; j <= 1000000; j += i)
				prime[j] = false;
		
}
bool work(int x){
	int temp = sqrt(x);
	if(temp * temp == x)
		return true;
	return false;
}
int check(int x){
	if(x == 1){
		return 1;
	}
	int cnt = 0;
	for(int i = 1; i * i < x; i ++)
		if(x % i == 0)
			cnt ++;
	if(work(x))
		return cnt * 2 + 1;
	else
		return cnt * 2;
}
int main(){
	//prime_shieve();
	for(int i = 1; i <= 1000000; i ++)
		pre[i] = check(i);
	int n, sum = 0;
	cin >> n;
	
	for(int i = 1; i < n; i ++)
		sum += pre[n - i];
		
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7580
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
a=t[0];b=1;d=0
for j in range(n):
  d+=1
  if t[j]>a+k or d>c:
     a=t[j]
     b+=1
     d=1
print(b)

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

#define ll long long int

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    //cerr << s << endl;
    if (s == "abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3608
#include<stdio.h>

int minint(int a,int b);

int main(void){
	int x=0,y=0,min,max;
	int amari=0;

	scanf("%d %d",&x,&y);

	min=minint(x,y);

	if(x!=min){
		max=x;
	}else{
		max=y;
	}

	while(min>0){
		amari=max%min;
		max=min;
		min=amari;
	}

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

}

int minint(int a,int b){
	int minint;

	if(a<b){
		minint=a;
	}
	if(b<a){
		minint=b;
	}
	return minint;
}



Measured memory_bytes: 2104
#include<stdio.h>

long long int check(int);
long long int solve();

long long int num,van_num;
long long int cab[1000000];

int main(){
  long long int i;
  long long int ans;

  scanf("%d %d",&num,&van_num);
  for(i=0;i<num;i++){
    scanf("%d",&cab[i]);
  }
  ans=solve();
  printf("%d\n",ans);
  
  return 0;
}

long long int check(int max_burd){
  long long int i=0,j;
  long long int van_burd;
  for(j=0;j<van_num;j++){
    van_burd=0;
    while(van_burd+cab[i]<=max_burd){
      van_burd+=cab[i];
      i++;
      if(i==num) return num;
    }
  }
  return i;
}

long long int solve(){
  long long int left=0;
  long long int right=100000*10000;
  long long int mid;
  long long int num_pie;

  while(right-left>1){
    mid=(left+right)/2;
    num_pie=check(mid);
    if(num_pie>=num){
      right=mid;
    }else{
      left=mid;
    }
  }

  return right;
}

Measured memory_bytes: 1380
N = int(input())
table = list("MARCH")
L = [input() for _ in range(N)]
cnt = [0 for _ in range(5)]
L = list(map(lambda x:x[0],L))
L = list(filter(lambda x:x[0] in table,L))
for x in L:
    if x=='M':
        cnt[0] += 1
    elif x=='A':
        cnt[1] += 1
    elif x=='R':
        cnt[2] += 1
    elif x=='C':
        cnt[3] += 1
    elif x=='H':
        cnt[4] += 1
#print(cnt)
ans = 0
import itertools as it
table  = list(it.combinations(range(5),3))
for x in table:
    ans += cnt[x[0]]*cnt[x[1]]*cnt[x[2]]
print(ans)


Measured memory_bytes: 10540
import java.util.Scanner;

class Main {
	public static double ex(double ox, double oy, double x1, double y1, double x2, double y2){
		double vx1 = x1 - ox;
		double vy1 = y1 - oy;
		double vx2 = x2 - ox;
		double vy2 = y2 - oy;
		return vx1 * vy2 - vx2 * vy1;
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double[][] p = new double[3][2];
			for(int i = 0; i < 3; i++){
				p[i][0] = scan.nextDouble();
				p[i][1] = scan.nextDouble();
			}
			double px = scan.nextDouble();
			double py = scan.nextDouble();

			boolean f = true;
			boolean g = true;
			for(int i = 0; i < 3; i++){
				double ex = 
						ex(p[i][0], p[i][1], p[(i + 1) % 3][0], p[(i + 1) % 3][1], px, py);
				if(ex >= 0){
					f = false;
				}
				if(ex <= 0){
					g = false;
				}
			}
			System.out.println(f||g?"YES":"NO");
		}
	}
}

Measured memory_bytes: 32608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m; cin >> n >>m;
  vvi to(n, vi());
  rep(i,m) {
    int a,b; cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vi from(n, INF);
  queue<int> q;
  q.push(0);
  while(q.size()) {
    int v = q.front(); q.pop();
    for (int u: to[v]) {
      if (u==v) continue;
      if (from[u] == INF) {
        from[u] = v;
        q.push(u);
      }
    }
  }
  for (int i=1; i<n; i++) {
    if (from[i] == INF) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i=1; i<n; i++) {
    cout << from[i] + 1 << endl;
  }
  return 0;
}

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

const int maxn=1e6+10;

int n,Ans;
char s[maxn],t[maxn];
queue<int> q;

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,p;
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	bool flag=1;
	for (i=1;i<=n;i++)
		flag&=s[i]==t[i];
	if (flag) {puts("0"); return 0;}
	for (i=p=n;i>=1;i--)
		if (t[i]!=t[i-1])
		{
			p=min(p,i);
			while (p&&t[i]!=s[p]) p--;
			if (!p) {puts("-1"); return 0;}
			while (!q.empty()&&q.front()-(int)q.size()>=i) q.pop();
			q.push(p);
			if (i!=p) Ans=max(Ans,(int)q.size());
		}
	printf("%d\n",Ans+1);
}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    int a;
    in(a)
    println(a + std::pow(a, 2.0) + std::pow(a, 3.0));
    return 0;
}

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

#define MAX 100
#define rep(i,n) for(int i = 0 ; i < n ; i++)
typedef long long ll;

int main(){
  ll N, M, L, a[MAX][MAX], b[MAX][MAX], c[MAX][MAX];

  std::cin >> N >> M >> L;
  rep(i,N){
    rep(j,M){
      std::cin >> a[i][j];
    }
  }
  rep(i,M){
    rep(j,L){
      std::cin >> b[i][j];
    }
  }

  memset(c,0,sizeof(c));
  rep(i,N){
    rep(j,M){
      rep(k,L){
        c[i][k] += a[i][j]*b[j][k];
      }
    }
  }
  rep(i,N){
    rep(j,L){
      if(j != L-1){
        std::cout << c[i][j] << " ";
      }else{
        std::cout << c[i][j] << std::endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1396
#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(){
    string s;
    cin >> s;
    if (s.size() == 3) swap(s[0], s[2]);
    cout << s;
}

Measured memory_bytes: 3612
from collections import deque
s=input()
money=int(input())
ans=deque()

d = dict(zip([chr(i) for i in range(97, 97+26)], range(0,26)))
d_r = dict(zip(range(0,26),[chr(i) for i in range(97, 97+26)]))

s_hash = deque([d[i] for i in s])

while len(s_hash)>0:
    #print(money,s_hash,ans)
    n = s_hash.popleft()
    if (money >= 26 - n) & (n != 0):
        ans.append(0)
        money -= 26 - n
    else:
        ans.append(n)
#print(money,s_hash,ans)
money = money % 26
while money>0:
    n = ans.pop()
    ans.append((n+money) % 26)
    money = 0

print("".join([d_r[i] for i in ans]))

Measured memory_bytes: 5220
package main

import (
  "fmt"
)

func main() {
  var A, B, C uint
  fmt.Scanf("%d %d %d", &A, &B, &C)
  
  diff := A - B
  var result uint
  
  switch {
  case diff >= C:
    result = 0
  case diff < C:
    result = C - diff
  }
  
  fmt.Println(result)
}

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

a = n // 15
c = a*(a-1)//2
b = n % 15

l = [1, 2, 0, 4, 0, 0, 7, 8, 0, 0, 11, 0, 13, 14]
for i in range(len(l)):
    if l[i] != 0:
        l[i] += 15*a

print(60*a + 120*c + sum(l[:b]) )

Measured memory_bytes: 9204
import sys
import math
n, m = map(int, input().split())
li = [0] * m
for i in range(n):
    tmp = list(map(int, input().split()))
    for j in range(len(tmp)):
        if j == 0:
            continue
        li[tmp[j] - 1] += 1
cnt = 0
for i in li:
    if (i == n):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;

int P, Q, R;
int a;
int c[2];

int main(){
  scanf("%d %d %d", &P, &Q, &R);
  c[0]=P+Q;
  c[1]=Q+R;
  c[2]=R+P;
  
  a = P + Q;
  if(a > Q + R)a = Q + R;
  if(a > R + P)a = R + P;
  printf("%d", a);
  
  return 0;
}

Measured memory_bytes: 128
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar_unlocked());)if(c-10)a[i]=a[i]*10+c-48;else ++i;
	for(b[i=s]=1;!b[s=a[s]]++&&s-2;i++);
	printf("%d",s-2?-1:i);
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    auto med = [&](int i) { return a[(i < n / 2 ? n / 2 : n / 2 - 1)].first;};
    sort(a.begin(), a.end());
    vector<int> ans(n);
    for (int j = 0; j < n; ++j) ans[a[j].second] = med(j);
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 4480
from collections import defaultdict

N = int(input())


"""
愚直解だと、Aを1~Nまで動かした時、各Aについて何個Bを取れるかを足し合わせると答えが出る。が、これはN<=2*10**5なのでO(N^2)は間に合わない。

事前に先頭がxで末尾がyの個数を、1~Nまで数え上げておくと、各Aについて先頭と末尾を抜き出して、それに対応するBの個数を足し合わせるとO(N)で求められる
"""
d = defaultdict(int)



for i in range(1,N+1):
    d[(int(str(i)[0]), int(str(i)[-1]))] += 1


ans = 0
for a in range(1,N+1):
    x = int(str(a)[0])
    y = int(str(a)[-1])
    ans += d[(y,x)]

print(ans)

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



int main(void)
{
    int n, r;
    cin >> n >> r;

    if(n >= 10){
        cout << r << endl;
    }
    else
    {
        cout << r + 100*(10 - n) << endl;
    }
    

    

    
    return 0;
}

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

using namespace std;

int A[100001];
int B[100001];
int main()
{
	int N;
	long long sum = 0;
	long long sum2 = 0;

	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];

	sort(A, A + N);

	if (N % 2 == 0) {
		for (int i = 0; i < N; ++i) {
			if (i < (N / 2 - 1)) {
				B[i] = -2;
			}
			else {
				if (i == N / 2 - 1) {
					B[i] = -1;
				}
				else {
					if (i == N / 2) {
						B[i] = 1;
					}
					else {
						B[i] = 2;
					}
				}
			}
		}
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (i < ((N - 1) / 2 - 1)) {
				B[i] = -2;
			}
			else {
				if (i == (N - 1) / 2 - 1) {
					B[i] = -1;
				}
				else {
					if (i == (N - 1) / 2) {
						B[i] = -1;
					}
					else {
						B[i] = 2;
					}
				}
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		sum = sum + A[i] * B[i];
	}

	if (N % 2 == 0) {
		for (int i = 0; i < N; ++i) {
			if (i < (N / 2 - 1)) {
				B[i] = -2;
			}
			else {
				if (i == N / 2 - 1) {
					B[i] = -1;
				}
				else {
					if (i == N / 2) {
						B[i] = 1;
					}
					else {
						B[i] = 2;
					}
				}
			}
		}
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (i < ((N - 1) / 2 )) {
				B[i] = -2;
			}
			else {
				if (i == (N - 1) / 2) {
					B[i] = 1;
				}
				else {
					if (i == (N - 1) / 2+1) {
						B[i] = 1;
					}
					else {
						B[i] = 2;
					}
				}
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		sum2 = sum2 + A[i] * B[i];
	}

	cout << max(sum,sum2) << endl;
	return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  deque<ll> lr;
  deque<ll> rl;
  ll cnt = 0;
  rep(i, n - 1) {
    if (s[i] == 'L' && s[i + 1] == 'L')
      cnt++;
    else if (s[i] == 'R' && s[i + 1] == 'R')
      cnt++;
    else if (s[i] == 'L' && s[i + 1] == 'R')
      lr.push_back(i);
    else if (s[i] == 'R' && s[i + 1] == 'L')
      rl.push_back(i);
  }
  // cout << cnt << endl;
  while ((lr.size() > 0 || rl.size() > 0) && k > 0) {
    k--;
    if (lr.size() == 0 || rl.size() == 0) {
      if (cnt > 0) {
        cnt++;
      }
      break;
    } else {
      ll lr0 = *lr.begin();
      ll lr1 = *(lr.end() - 1);
      ll rl0 = *rl.begin();
      ll rl1 = *(rl.end() - 1);
      // cout << lr0 << "," << lr1 << "," << rl0 << "," << rl1 << endl;
      if (abs(lr0 - rl1) > abs(lr1 - rl0)) {
        lr.pop_front();
        rl.pop_back();
        cnt += 2;
      } else {
        lr.pop_back();
        rl.pop_front();
        cnt += 2;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1088
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int a[110];
    int n;
    int ans[3];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            read a[i];
        }
        int pos = std::accumulate(a, a+n, 0) / n;
        for ( int p = -1; p <= 1; p++ ) {
            for ( int i = 0; i < n; i++ ) {
                int tmp = a[i] - pos + p;
                ans[p+1] += tmp*tmp;
            }
        }
        echo std::min( std::min ( ans[0], ans[1] ), ans[2] ) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
a,b,c,k = map(int,input().split())

cnt = 0
idx = 0

if k >= a :
  k -= a
  cnt += a
else:
  cnt += k
  k = 0

if k != 0:
  if k >= b:
    k -= b
  else:
    k = 0

if k != 0:
  if k >= c:
    cnt -= c
    k -= c
  else:
    cnt -= k
    k = 0

print(cnt)
  

Measured memory_bytes: 9196
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [k, x] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  const min = Math.max(x - (k - 1), -1000000)
  const max = Math.min(x + (k - 1), 1000000)

  let res = []

  for (let i = min; i <= max; i++) {
    res.push(i)
  }

  console.log(res.join(' '))
}

ans()


Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
using namespace std;
long long n, a, sum;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &a);
        sum ^= a;
    }
    if(sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

lint N, W;

int main()
{
    cin >> N >> W;
    vector<lint> dp(W + 1);

    REP(_, N)
    {
        int w, v;
        cin >> w >> v;
        IREP(wprv, W - w + 1) Max(dp[wprv + w], dp[wprv] + v);
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}


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


int main(){
    vector<int> v(3);
    rep(i,3) cin>>v[i];

    sort(v.begin(), v.end());

    cout<<v[0]+v[1]<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 45
int A[N];

int fibonacci(int n)
{
  if(n==0 || n==1) return 1;
  if(A[n] !=-1) return A[n];
  return A[n] = fibonacci(n-2)+fibonacci(n-1);
}
int main()
{
  int i,n;

  
  for(i=0; i<N; i++) A[i] =-1;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 2104
def main():
  s=input()
  n=len(s)
  a,b,M=0,1,10**9+7
  p=[1]
  for i in range(n-1):
    p.append(p[i]*3%M)
  for i,t in enumerate(map(int,s)):
    if t:
      a=(a+b*p[~i])%M
      b=b*2%M
  print((a+b)%M)
main()

Measured memory_bytes: 45552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int T,t,a[20];

    for(t=0;t<10;t++)
    {
       scanf("%d",&a[t]);
    }
        sort(a,a+10);

      cout<<a[10-1]<<endl;
      cout<<a[10-2]<<endl;
      cout<<a[10-3]<<endl;

      return 0;
}

Measured memory_bytes: 1224
// ProblemURL : https://atcoder.jp/contests/agc039/tasks/agc039_a
// ---------------------------------------------
package main

import "fmt"

func countAlphabet(s string) int {
	m := make(map[rune]int, 26)
	for _, ss := range s {
		m[ss]++
	}
	return len(m)
}

func calcCostNaive(s string) int {
	t := []byte(s)
	cost := 0
	for i := 1; i < len(t); i++ {
		if t[i-1] == t[i] {
			t[i] = '#'
			cost++
		}
	}
	return cost
}

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)

	if countAlphabet(s) == 1 {
		length := len(s) * k
		cost := length / 2
		fmt.Println(cost)
		return
	}

	if s[0] == s[len(s)-1] {
		ctHead := 0
		for i := 0; i < len(s); i++ {
			if s[i] != s[0] {
				break
			}
			ctHead++
		}
		ctTail := 0
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] != s[len(s)-1] {
				break
			}
			ctTail++
		}
		t := s[ctHead : len(s)-ctTail]
		cost := ctHead/2 + ctTail/2 + calcCostNaive(t)*k + (ctHead+ctTail)/2*(k-1)
		fmt.Println(cost)
	} else {
		cost := calcCostNaive(s)
		cost *= k
		fmt.Println(cost)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
typedef std::pair<ll, ll> P;

using namespace std;

bool pairCompare(const P& f, const P& s){
    return f.first < s.first;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll m;
    rep(i, n){
        if(i == 0) m = a[i];
        else m = gcd(m, a[i]);
    }
    cout << m;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;
const long double eps = 1e-12;

typedef long long ll;
typedef pair<int , int> pt;

#define sz(a) ((int) a.size() )
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)
#define For(i , a , b) for (int i = a ; i <= b ; i++)
#define Ford(i , a , b) for (int i = a ; i >= b ; i--)
#define Rep(i , n) for (int i = 0 ; i < n ; i++)

const int maxn = 1005;
int n , m , Q;
string a[maxn];
int s[maxn][maxn][3];
char pat[3] = {'J' , 'O' , 'I'};

void ReadData() {
    cin >> n >> m >> Q;
    For(i , 1 , n) cin >> a[i] , a[i] = ' ' + a[i];
    memset(s , 0 , sizeof(s));
    For(i , 1 , n) For(j , 1 , m) {
        Rep(k , 3) s[i][j][k] = s[i - 1][j][k] + s[i][j - 1][k] + (a[i][j] == pat[k]) - s[i - 1][j - 1][k];
    }
    while (Q--) {
        int x , y , u , v; cin >> x >> y >> u >> v;
        Rep(k , 3) {
            cout << s[u][v][k] - s[x - 1][v][k] - s[u][y - 1][k] + s[x - 1][y - 1][k];
            if (k < 2) cout << " ";
        }
        cout << "\n";
    }
}

void Process() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("/users/youaremysky/documents/workspace/input.inp" , "r" , stdin);
    ReadData();
    Process();
}

Measured memory_bytes: 14076
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

	int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust";
    else cout << "win";

}




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

int main()
{
  long long X, Y, cnt=0;
  cin >> X >> Y;
  while(X<=Y){
    X=X*2;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T;
    cin >>S  >>T;
    int a,b;
    cin >> a >> b;
    string U; cin >> U;
    if(S == U) a--;
    else b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
n=int(input())
main=[]
for i in range(n):
    main.append(list(map(int,input().split())))
flag=0
result=0
for i in range(n):
    if flag==3:
        result=1
        break
    elif main[i][0]==main[i][1]:
        flag+=1
    else:
        flag=0
if flag==3 or result==1:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 62392
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
string s;
int main()
{
	cin >> n >> s;
	for (int i = n - 1; i >= 1; i--)
	{
		if (s[i] == s[i - 1])
		{
			s[i] = 0;
			i++;
		}
	}
	int k = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] >= 'a' && s[i] <= 'z')
			k++;
	}
	cout << k;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  int l = *(L.rbegin());
  int r = *(R.begin());
  if (l <= r) {
    cout << r - l + 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000007;
typedef long long ll;
 int g[M],r[M],b[M];
 string p="RGB";
int main()
{

     ios::sync_with_stdio(false);
     cin.tie(0);
     int n;
     string s;
     cin>>n>>s;
     ll tot=0;
     int gg=0,rr=0,bb=0;
     for(int i=n-1;i>=0;i--)
     {
        if(s[i]=='R')rr++;
        if(s[i]=='G')gg++;
        if(s[i]=='B')bb++;
        g[i]=gg;
        r[i]=rr;
        b[i]=bb;
     }
     for(int i=0;i<n;i++)
     {

      for(int j=i+1;j<n-1;j++)
      {
        if(s[i]!=s[j]){
        int d=j-i;
        for(int k=0;k<3;k++)
        {
          if(s[i]==p[k]||s[j]==p[k])continue;
          else
          {
            if(p[k]=='G')tot+=g[j+1];
            if(p[k]=='R')tot+=r[j+1];
            if(p[k]=='B')tot+=b[j+1];
            if(d+j<n&&s[d+j]==p[k])tot--;
          }
        }
        
      }
      }
     }
     cout<<tot<<"\n";

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100010
int n;
int a[N];

void end(int x) {
	if (x == 1) puts ("First");
	else puts ("Second");
	exit(0);
}

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	int x = 1;
	while (true) {
		ll S = 0;
		int odd = 0;
		int F1 = 0;
		for (int i = 0; i < n; i ++) {
			if (a[i]&1) odd++;
			S += a[i];
			if (a[i] == 1) F1++;
		}
		if ((S-n)%2 == 1) end(x);
		if (odd >= 2 || F1 > 0) end(3-x);
		int g = 0;
		for (int i = 0; i < n; i ++)
			if (a[i]&1) g = gcd(g, a[i]-1);
			else g = gcd(g, a[i]);
		for (int i = 0; i < n; i ++) a[i] /= g;
		x = 3-x;
	}
	return 0;
}

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

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

    int n;
    cin >> n;

    int B[n-1];

    for(int i=0;i<n-1;++i) cin >> B[i];

    int A[n];

    A[0] = B[0];
    A[n-1] = B[n-2];

    for(int i=1;i<n-1;++i) A[i] = min(B[i],B[i-1]);

    //for(int i=0;i<n;++i) cout << A[i] << '\n';

    cout << accumulate(A,A+n,0) << '\n';

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long total = 0;
            long input = long.Parse(Console.ReadLine());
            for (int i = 1; i<= input; i++)
                for (int j = 1; j<= input; j++)
                    for (int k = 1; k<=input;k++)
                    {
                        total += Gcd(i, j, k);
                    }
            Console.WriteLine(total);
        }

        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        public static int Gcd(int a, int b, int c)
        {
            int Gcd_a_b = Gcd(a, b);
            if (Gcd_a_b < c)
                return Gcd(c, Gcd_a_b);
            while (c != 0)
            {
                var remainder = Gcd_a_b % c;
                Gcd_a_b = c;
                c = remainder;
            }
            return Gcd_a_b;
        }

    }
}


Measured memory_bytes: 27488
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int p[N];
int main(){
    int n,k; scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]), p[i] += p[i-1];
    int ans = 0;
    for(int i=k;i<=n;i++) ans = max(ans,p[i]-p[i-k]);
    printf("%.8f\n",(ans+k)/2.0);
}


Measured memory_bytes: 1152
#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;
typedef long long ll;

int main() {
	int n, m, R;
	cin >> n >> m >> R;
	vector<int> r(R);
	rep(i, R) {
		cin >> r[i];
		r[i]--;
	}
	const int INF = 1001001001;
	vector<vector<int>> d(n, vector<int>(n, INF));
	rep(i, n) d[i][i] = 0;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	
	for (int k = 0; k < n; k++){       // 経由する頂点
		for (int i = 0; i < n; i++) {    // 始点
			for (int j = 0; j < n; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	sort(all(r));
	int ans = INF;
	do {
		int now = 0;
		rep(i, R-1) {
			now += d[r[i]][r[i+1]];
		}
		ans = min(ans, now);
		// rep(i, R) cout << r[i] << " ";
		// cout << endl;
	} while (next_permutation(all(r)));
	cout << ans << endl;
	
	// rep(i, n) {
	// 	rep(j, n) {
	// 		cout << d[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	
	return 0;
}

Measured memory_bytes: 512
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let _ = readLine()
let arare = readStringSplit(by: " ")
print(arare.contains("Y") ? "Four" : "Three")


Measured memory_bytes: 4084
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
using pr  = pair<ll, ll>;

const ll MOD = 1000000007;

int main()
{
	int N, M, X;
	cin >> N >> M >> X;

	mat A(N, vec(M));
	vec C(N);
	for (int n = 0; n < N; ++n)
	{
		cin >> C[n];
		
		for (int m = 0; m < M; ++m)
		{
			cin >> A[n][m];
		}
	}

	int ans = -1;

	for (int i = 0; i < (1 << N); ++i)
	{
		int totalCost = 0;
		vec G(M,0);

		for (int n = 0; n < N; ++n)
		{
			if (!(i & (1 << n))) { continue; }

			totalCost += C[n];

			for (int m = 0; m < M; ++m)
			{
				G[m] += A[n][m];
			}
		}

		bool flag = true;

		for (int m = 0; m < M; ++m)
		{
			if (G[m] < X) { flag = false; }
		}

		if (flag)
		{
			if (ans == -1 || ans > totalCost)
			{
				ans = totalCost;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612