akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	lmax := make([]int, n+1)
	rmax := make([]int, n+1)
	for i := 0; i < len(as); i++ {
		lmax[i+1] = max(lmax[i], as[i])
		rmax[len(as)-i-1] = max(rmax[len(as)-i], as[len(as)-i-1])
	}
	for i := 0; i < len(as); i++ {
		fmt.Println(max(lmax[i], rmax[i+1]))
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 9188
#include<iostream>

using namespace std;

int money(int num){
	int sum = 0;
	if(num > 30){
		sum = (num - 30) * 160 + 3800;
	}else if(num > 20){
		sum = (num - 20) * 140 + 2400;
	}else if(num > 10){
		sum = (num - 10) * 125 + 1150;
	}else{
		sum = 1150;
	}
	return sum;
}

int main(){
	int w;
	int last = 4280,now;
	
	while(cin >> w,w!=-1){
		now = money(w);
		cout << last - now << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use std::cmp::{max, min};
fn main() {
    let s = read::<String>();

    let mut a: i32 = 0;
    let mut b: i32 = 0;
    let mut c: i32 = 0;
    let mut ans: i32 = 1000;

    for (i, v) in s.chars().enumerate() {
        if (i == 0) {
            a = v.to_string().parse::<i32>().unwrap();
        } else if (i == 1) {
            b = v.to_string().parse::<i32>().unwrap();
        } else {
            c = v.to_string().parse::<i32>().unwrap();
            ans = min(ans, (753 - (a * 100 + b * 10 + c)).abs());
            a = b;
            b = c;
        }
    }

    println!("{}", ans);
}


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

int main(void)
{
    int N, K;
    int ret = 1;

    cin >> N;
    cin >> K;

    for(int i = 0;i < N;i++)
    {
        if(ret * 2 < ret + K)
        {
            ret = ret * 2;
        }
        else
        {
            ret = ret + K;
        }
    }

    cout << ret << endl;
    return 0;
}

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

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    vector<pair<long long,long long>>store(n);
    for(int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        store[i] = make_pair(a, b);
    }
    sort(store.begin(), store.end());

    long long cost = 0;
    long long now = m;
    for(int i = 0; i < n; i++) {
        if(now > store[i].second){
            cost += store[i].first * store[i].second;
            now -= store[i].second;
        }
        else if (now <= store[i].second){
            cost += store[i].first * now;
            break;
        }
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <vector>

int main()
{
  int a,b,c;
  std::cin >> a>>b>>c;
  
  int v;
       if (a <= b && b <= c) v = c*10+b+a;
  else if (a <= c && c <= b) v = b*10+c+a;
  else if (b <= a && a <= c) v = c*10+b+a;
  else if (b <= c && c <= a) v = a*10+c+b;
  else if (c <= a && a <= b) v = b*10+c+a;
  else /*if (c <= b && b <= a)*/ v = a*10+b+c;

  std::cout << v << std::endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int n, m;
int main() {
	while (cin >> n >> m, n) {
		int s = m;
		vector<int> v(n, 0);
		for (int i = 0; ; i = (i + 1) % n) {
			if (m != 0) v[i]++, m--;
			else m = v[i], v[i] = 0;
			if (m == 0 && s - m - v[i] == 0) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3032
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

acc_all = [0]
acc_pos = [0]

for ai in a:
    if ai > 0:
        acc_all.append(acc_all[-1] + ai)
        acc_pos.append(acc_pos[-1] + ai)
    else:
        acc_all.append(acc_all[-1] + ai)
        acc_pos.append(acc_pos[-1])

ans = 0    
for st in range(n-k+1):
    black = (acc_all[st+k] - acc_all[st])\
            + (acc_pos[n] - acc_pos[st+k])\
            + (acc_pos[st] - acc_pos[0])
    white = (acc_pos[n] - acc_pos[st+k])\
            + (acc_pos[st] - acc_pos[0])

    ans = max(ans, black, white)
    
print(ans)
    

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

int main(void) {
  string s;
  cin >> s;
  int i, j;

  for (i = 0; ; i++) {
    if (s[i] == 'A') {
      break;
    }
  }
  for (j = s.length() - 1; ; j--) {
    if (s[j] == 'Z') {
      break;
    }
  }

  cout <<  j - i + 1 << endl;

  return 0;
}

Measured memory_bytes: 640
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

n = inp()
Wlist = inpl()
Wnplist = np.array(Wlist)

fullsum = Wnplist.sum()
halfsum = Wnplist.sum()//2
tempsum = 0
i= 0
while tempsum <= halfsum:
    tempsum += Wnplist[i]
    i += 1

i -= 1

ans1 = abs((fullsum - tempsum)-tempsum)
tempsum -= Wnplist[i]
ans2 = abs((fullsum - tempsum)-tempsum)

print(min(ans1,ans2))

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 1;
  rep(i,n){
    ans = min(ans*2,ans+k);
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
using System;
using System.Linq;

namespace _7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] s = new int[a[0],a[1]];
            int zan = 0;
            for (int i = 0; i < a[0]; i++)
            {
                int gyokotae = 0;
                string gh = Console.ReadLine();
                int[] d = gh.Split().Select(int.Parse).ToArray();
                Console.Write(gh + " ");
                for (int k = 0; k < a[1]; k++)
                {
                    s[i, k] = d[k];
                    gyokotae += d[k];
                }
                zan += gyokotae;
                Console.WriteLine(gyokotae);
            }
            for(int i = 0; i < a[1]; i++)
            {
                int iti = 0;
                for (int k = 0; k < a[0]; k++)
                {
                    iti += s[k, i];
                }Console.Write(iti + " ");
            }Console.WriteLine(zan);

        }
    }
}

Measured memory_bytes: 9748
N = int(input())
A, B = map(int, input().split())

counts = [0, 0, 0]

P = map(int, input().split())

for p in P:
    if p <= A:
        counts[0] += 1
    elif p <= B:
        counts[1] += 1
    else:
        counts[2] += 1

print(min(counts))


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  if(n>=1000) cout << "ABD" << endl;
  else cout << "ABC" << endl;
  
  return 0;
}


Measured memory_bytes: 3420
// abc158_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  cin>>s;
  if (s == "AAA" || s == "BBB") {
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,i,j,a;
	char s[10001];
	scanf("%d",&n);
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a;i++){
		for(j=0;j<n;j++){
			s[i]++;
			if(s[i]=='Z'+1)	s[i]='A';
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
mod = 10**9+7
fact = [1]*(4*10**5+1)
for i in range(4*10**5):
    fact[i+1] = (i+1)*fact[i]%mod

factinv = [1]*(4*10**5+1)
for i in range(4*10**5+1):
    factinv[i] = pow(fact[i],mod-2,mod)

def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod
n,k = map(int,input().split())
ans = comb(2*n-1,n)
for i in range(k+1,n):
    ans -= comb(n-1,i)*comb(n,i)
    ans %= mod
print(ans)

Measured memory_bytes: 47456
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
int N;
int a[MAX_N];

bool solve() {
    int oddCnt = 0;
    int evenCnt = 0; // not multiple of 4
    int multi4Cnt = 0;
    REP(i, 0, N){
        if(a[i] % 4 == 0){
            multi4Cnt++;
        }else if(a[i] % 2 == 0){
            evenCnt++;
        }else{
            oddCnt++;
        }
    }
    return (oddCnt <= multi4Cnt || oddCnt == multi4Cnt + 1 && evenCnt == 0);
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i, 0, N) cin >> a[i];
    cout << (solve() ? "Yes" : "No") << "\n";
    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6 1");
            WillReturn.Add("3");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10 2");
            WillReturn.Add("4");
            WillReturn.Add("5");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("100 5");
            WillReturn.Add("1");
            WillReturn.Add("23");
            WillReturn.Add("45");
            WillReturn.Add("67");
            WillReturn.Add("89");
            //608200469
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        var ASet = new HashSet<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            ASet.Add(int.Parse(EachStr));
        }

        //場合の数[現在位置]なDP表
        int[] DPArr = new int[N + 1];
        DPArr[0] = 1;
        int UB = N;

        for (int I = 0; I <= UB; I++) {
            Action<int> wkAct = (pNextDan) =>
            {
                if (pNextDan <= UB && ASet.Contains(pNextDan) == false) {
                    DPArr[pNextDan] = DPArr[pNextDan] + DPArr[I];
                    DPArr[pNextDan] %= 1000000007;
                }
            };
            wkAct(I + 1);//1段あがる場合
            wkAct(I + 2);//2段あがる場合
        }
        Console.WriteLine(DPArr[UB]);
    }
}


Measured memory_bytes: 29024
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 2e5+5;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)

int n, m, dp[N], ans;
vector <int> g[N];

int solve(int v){
    if(dp[v] != -1) return dp[v];
    dp[v] = 1;
    for(auto c : g[v]){
        dp[v] = max(dp[v], solve(c) + 1);
    }
    return dp[v];
}

int32_t main(){
    FIO;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; ++i){
        ans = max(ans, solve(i));
    }
    ans--;
    cout << ans;
}


Measured memory_bytes: 11008
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,m;cin>>n>>m;
  vl x(n);
  rep(i,n)cin>>x[i];
  map<ll,ll>M;
  vl finished(m);
  vl all(m);
  rep(i,n)M[x[i]]++;
  for(auto p:M){
    finished[p.first%m]+=p.second/2;
    all[p.first%m]+=p.second;
  }
  ll ans=0;
  ans+=all[0]/2;
  if(m%2==0)ans+=all[m/2]/2;
  for(ll i=1;i<=(m-1)/2;i++){
    if(all[i]>=all[m-i]){
      ans+=min((all[i]-all[m-i])/2,finished[i]);
      ans+=all[m-i];
    }
    else {
      ans+=min((all[m-i]-all[i])/2,finished[m-i]);
      ans+=all[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  int C;
  if( A > K ){
    C = A-K;
     K = 0;
  }else{
    C = 0;
    K -= A;
  }
  int D;
  if( B > K ) D = B-K;
  else{
    D = 0;
  }
  cout << C << " " << D << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
// [gcd]
template<class T> T gcd(T a,T b)
{if (a < b) swap(a,b);return b ? gcd(b, a % b) : a;}
template<class T> T lcm(const T a, const T b)
{return (a * b / gcd(a, b));}

void Main(){
  int n;
  cin>>n;
  vl a(n);
  cin>>a;
  ll ans = a[0];
  rep(i,n){
    ans = gcd(ans,a[i]);
  }
  cout<<ans<<endl;
} int main(int argc,char** argv)
{fastio; myio; Main();}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int num = 1; num <= N; num++) {
		if (num % 2 == 0) continue;
		int count = 0;
		for (int i = 1; i <= N; i++) {
			if (num % i == 0) count++;
		}
		if (count == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3544
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;

    if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else if (N == 1 || M == 1) {
        cout << max(N, M) - 2 << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, a, b;
// main solution goes here:
void execute(int test_number)
{
    cin>>n>>a>>b;
    int q = n/(a+b), r = n%(a+b);
    cout<<q*a + min(r, a);
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 3660
#include <cstdio>

using namespace std;

int s[100][100];
int main(void){
  int w,h;
  int ans;
  
  scanf("%d%d", &h, &w);
  for (int i=1; i<=h; i++){
    char buf[100];
    scanf("%s",buf);
    for (int j=1; j<=w; j++){
      s[j][i] = (buf[j-1]=='#');
    }
  }
  ans = true;
  for (int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      s[j][i]&&(ans&=s[j-1][i]||s[j+1][i]||s[j][i-1]||s[j][i+1]);
    }
  }
  puts(ans?"Yes":"No");
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

class UnionFindTree {
 private:
  int nodeSize;
  vector<int> parent;
  vector<int> rank;
  vector<int> treeSize;

 public:
  UnionFindTree(int ns) {
    nodeSize = ns;
    parent = vector<int>(nodeSize);
    rank = vector<int>(nodeSize, 0);
    treeSize = vector<int>(nodeSize, 1);

    for (int i = 0; i < nodeSize; i++) {
      parent[i] = i;
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) {
      return false;
    }

    if (rank[x] < rank[y]) {
      parent[x] = y;
      treeSize[y] += treeSize[x];
    } else {
      parent[y] = x;
      treeSize[x] += treeSize[y];
      if (rank[x] == rank[y]) {
        rank[x]++;
      }
    }

    return true;
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int getSize(int x) { return treeSize[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> L(m, vector<int>());
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int l;
      cin >> l;
      L[l - 1].eb(i);
    }
  }

  UnionFindTree uf(n);
  rep(i, m) {
    rep(j, L[i].size()) { uf.unite(L[i][0], L[i][j]); }
  }

  cout << (uf.getSize(0) == n ? "YES" : "NO") << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;

using Edge = pair<ll,ll>;  //　1つ目は結んでいるノード、2つ目はその辺の重みを指す
using Graph = vector<vector<Edge> >;  //隣接リスト

void dijkstra(const Graph &G, vl &dist, ll s){  // sを始点とする最短経路
  priority_queue<Pair, vector<Pair>, greater<Pair> > que; //secondが頂点、firstがその頂点への暫定最小コストを表す
  dist[s] = 0;  //sへの距離は0
  
  que.emplace(0, s);
  
  while(!que.empty()){
    Pair p = que.top(); //キューから辺を取り出す
    que.pop(); //取り出した辺は破棄
    ll v = p.second;  
    if(dist[v] < p.first) continue; //辺の行き先の距離が辺のコスト未満なら、そのまま
    for(auto e : G[v]){  //頂点vから出る各辺について
      if(dist[e.first] > dist[v] + e.second){  //辺Eを通るとコストが改善される場合
        dist[e.first] = dist[v] + e.second;  //更新
        que.emplace(Pair(dist[e.first], e.first));  //キューにその頂点を格納
      }
    }
  }
}
 
int main() {
  ll h,w;
  cin >> h >> w;
  Graph G(10);
  rep(i,10){
    rep(j,10){
      ll c;
      cin >> c;
      G[j].push_back(Edge(i,c));
    }
  }
  vl dist(10,INF);
  dijkstra(G,dist,1);
  ll ans = 0;
  rep(i,h){
    rep(j,w){
      ll x;
      cin >> x;
      if(x == -1) continue;
      ans += dist[x];
    }
  }
  cout << ans;
      
 return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100100;

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

	int ans = (t / a) * b;
	cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N (5010*5010)
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a[2][3];
ll f[N];
ll solve(int x,int y,int n)
{
	for (int i=0;i<=n;i++) f[i]=i;
	for (int i=0;i<3;i++)
		for (int j=a[x][i];j<=n;j++)
		f[j]=max(f[j],f[j-a[x][i]]+a[y][i]);
	return f[n];
}//有n元钱 从x买入 y卖出 最后最多能剩多少 
signed main()
{
	n=read();
	for (int i=0;i<2;i++)
		for (int j=0;j<3;j++)
		a[i][j]=read();
	cout<<solve(1,0,solve(0,1,n));
	return 0;
	//NOTICE LONG LONG!!!!!
}
 

Measured memory_bytes: 195584
program main
    implicit none
    integer :: n, w(100), s1, s2, i, j, k, ms
    

    read(*,*)n
    read(*,*)(w(i),i = 1, n)
    ms = 1000000
    
    do j = 1, n-1
      s1 = 0
      s2 = 0
      do i = 1, j
        s1 = s1 + w(i)
      end do
      do i = j+1, n
        s2 = s2 + w(i)
      end do
      if (ms > abs(s1 -s2)) then
        ms = abs(s1-s2)
      end if
    end do

    write(*,*)ms
end program main

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> i64
where
    F: Fn(i64) -> bool,
{
    let mut lb = lb;
    let mut ub = ub;
    while ub - lb > 1 {
        let mid = (ub + lb) / 2;
        if criterion(mid) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    lb
}

fn main() {
    let v = read_vec::<i64>();
    let (n, a, b, c, d) = (v[0], v[1], v[2], v[3], v[4]);
    let b = b - a;
    let b = b.abs();

    let calc_max = |i: i64| d * i - c * (n - 1 - i);
    let calc_min = |i: i64| c * i - d * (n - 1 - i);
    let criterion = |i: i64| b > calc_max(i);
    let x = binary_search(0, n, criterion) + 1;
    /*
    println!("{:?}", x);
    println!("{:?}", calc_max(x));
    println!("{:?}", calc_min(x));
    */

    if x > n - 1 {
        println!("NO");
        return;
    }
    if b >= calc_min(x) {
        println!("YES");
        return;
    } else {
        println!("NO");
        return;
    }
}


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

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;


int main()
{
    fastio;
    
    int n;
    cin>>n;
    if(n%1000)
    cout<<1000-(n%1000)<<nl;
    else cout<<0<<nl;
}

Measured memory_bytes: 3632
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val rad = PI * 2 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0)
    val rsq = (a * a + b * b) - (2 * a * b) * cos(rad)
    println(sqrt(rsq))
}

Measured memory_bytes: 36608
package main

import (
        "fmt"
)

func solution(n, d, x int, a []int) int {
        eat := 0
        for i := range a {
                for j := 0; j*a[i]+1 <= d; j++ {
                        eat++
                }
        }
        return eat + x
}

func main() {
        var n, d, x int
        fmt.Scan(&n, &d, &x)
        a := make([]int, 0, n)
        for i := 0; i < n; i++ {
                t := 0
                fmt.Scan(&t)
                a = append(a, t)
        }
        fmt.Println(solution(n, d, x, a))
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int a[4];
    for(int i = 0; i < 4; i++){
        cin >> a[i];
    }
    string s1, s2, s3, s4;
    s3 += "L";
    s4 += "R";
    for(int i = 0; i < a[3] - a[1]; i++){
        s1 += "U";
        s3 += "U";
        s2 += "D";
        s4 += "D";
    }
    s3 += "U";
    s4 += "D";
    s3 += "R";
    s4 += "L";
    
    for(int i = 0; i < a[2] - a[0]; i++){
        s1 += "R";
        s3 += "R";
        s2 += "L";
        s4 += "L";
    }
    s3 += "D";
    s4 += "U";
    cout << s1;
    cout << s2;
    cout << s3;
    cout << s4;
}

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

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

        BigInteger gc = BigInteger.ZERO;
        BigInteger prev = BigInteger.valueOf(sc.nextInt());
        for (int i = 1; i < n; i++) {
            BigInteger cur = BigInteger.valueOf(sc.nextInt());
            prev = cur.gcd(prev);
        }
        System.out.println(prev);
    }
}

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

using namespace std;

int n;
vector <pair<int, int>> tree[100010];
vector <int> visited;
vector <int> ans;
int k;

void dfs(int u, int p, int pc)
{
    int c = 1;

    for (auto v: tree[u])
    {
        if (v.first == p)
            continue;

        if (c == pc)
            c++;

        k = max(k, c);
        ans[v.second] = c;
        dfs(v.first, u, c);
        c++;
    }
}

int main()
{
    cin >> n;

    vector <pair<int, int>> edges;

    for (int i = 1; i < n; i++)
    {
        int u, v;

        cin >> u >> v;

        edges.push_back({u, v});

        tree[u].push_back({v, i-1});
        tree[v].push_back({u, i-1});
    }

    ans.assign(n-1, 0);
    dfs(1, 0, 0);

    cout << k << "\n";
    for (int c: ans)
    {
        cout << c << "\n";
    }

    return 0;
}

Measured memory_bytes: 9720
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

#from collections import defaultdict,deque
n = inn()
pr = [[ [] for i in range(n+1) ] for j in range(n+1)]
ch = [[ [] for i in range(n+1) ] for j in range(n+1)]
for i in range(1,n+1):
    a = inl()
    for j in range(n-2):
        x1 = x2 = i
        y1 = a[j]
        y2 = a[j+1]
        if x1>y1:
            x1,y1 = y1,x1
        if x2>y2:
            x2,y2 = y2,x2
        ch[x1][y1].append((x2,y2))
        pr[x2][y2].append((x1,y1))
g = [ [0]*(n+1) for i in range(n+1) ]
q = []
for i in range(1,n):
    for j in range(i+1,n+1):
        if len(pr[i][j])==0:
            q.append((i,j))
            g[i][j] = 1
        else:
            g[i][j] = 0
ddprint(ch)
ddprint("pr")
ddprint(pr)
ddprint(g)
while len(q)>0:
    z = q.pop()
    i,j = z
    for u,v in ch[i][j]:
        g[u][v] = max(g[u][v], g[i][j]+1)
        #ddprint("y {} z {}".format(y,z))
        pr[u][v].remove(z)
        if len(pr[u][v])==0:
            #del pr[y]
            q.append((u,v))
ddprint("newg")
ddprint(g)
#gmn = [min(r[1:]) for r in g[1:]]
gmn = BIG
for i in range(1,n):
    for j in range(i+1,n+1):
        gmn = min(gmn,g[i][j])
if gmn==0:
    print(-1)
else:
    print(max([max(r) for r in g]))


Measured memory_bytes: 219856
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	
	map<string, ll> ans;
	string s, t,u;
	ll a, b;

	std::cin >> s >> t;
	std::cin >> a >> b;
	ans[s] = a;
	ans[t] = b;
	std::cin >> u;
	ans[u]--;
	std::cout << ans[s] << " " << ans[t] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<vector<ll>> g;
bool use[1010];
ll nx[1010];

ll dfs(ll at){
	if(use[at]){return at;}
	
	use[at] = true;
	ll res = -1;
	zep(i, 0, g[at].size()){
		nx[at] = g[at][i];
		res = dfs(g[at][i]);
		if(res >= 0){break;}
	}
	use[at] = false;
	return res;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m, a, b;
	cin >> n >> m;
	g.resize(n);
	zep(i, 0, m){
		cin >> a >> b;
		g[a-1].push_back(b-1);
	}
	
	memset(use, 0, sizeof(use));
	ll s;
	//bool loop = false;
	zep(i, 0, n){
		s = i;
		s = dfs(s);
		if(s >= 0){break;}
	}
	
	if(s == -1){
		print(-1)
	}
	else{
		memset(use, 0, sizeof(use));
		ll cnt = 0;
		ll at = s;
		while(!use[at]){
			use[at] = true;
			cnt++;
			at = nx[at];
		}
		
		bool update = true;
		while(update){
			update = false;
			at = s;
			zep(i, 0, cnt){
				zep(i, 0, g[at].size()){
					if(g[at][i] != nx[at] && use[g[at][i]]){
						 nx[at] = g[at][i];
						 s = at;
						 update = true;
						 break;
					}
				}
				if(update){break;}
				at = nx[at];
			}
			
			if(update){
				memset(use, 0, sizeof(use));
				cnt = 0;
				at = s;
				while(!use[at]){
					use[at] = true;
					cnt++;
					at = nx[at];
				}
			}
		}
		
		print(cnt)
		at = s;
		zep(i, 0, cnt){
			print(at+1)
			at = nx[at];
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (abs(a - b) <= t * (v - w))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a==c){cout<<"No";}
  else if(a!=b&&b!=c&&c!=a){cout<<"No";}
  else{cout<<"Yes";}
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    int res=0;
    for(int i=0;i<(int)s.size();i++) res+=(s[i]!=t[i]);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3788
fun main(args: Array<String>) {
    abc079b()
}

fun abc079b() {
    val n = readLine()!!.toInt()

    val lucas = mutableListOf(2L, 1L)
    (2..n).map {
        lucas.add(lucas[it - 2] + lucas[it - 1])
    }

    println(lucas[n])
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

int f(int i) {
    return i * 2;
}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<pii> B(N);
    for (int i = 0; i < N; i++) {
        ll s, k;
        cin >> s >> k;
        k--;
        B[i] = {k, s};
    }
    sort(all(B), [](pii a, pii b){
        if (a.first == b.first) return a.second > b.second;
        return a.first < b.first;
    });

    vector<int> offset(10, -1);
    for (int i = 0; i < N; i++) {
        if (offset[B[i].first] == -1) offset[B[i].first] = i;
    }

    vector<vector<int>> dp(K + 1, vector<int>(2, -1));

    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        vector<vector<int>> ndp(K + 1, vector<int>(2, -1));
        for(int j = 0; j <= K; j++) {
            if (j + 1 <= K && dp[j][0] != -1) {
                chmax(ndp[j + 1][0], dp[j][0] + B[i].second + f(i - offset[B[i].first]));
            }
            // 切り替わるタイミングで0, そうでないとき1
            int nextf = 1 - ((i == N - 1) || ((i < N - 1) && B[i].first != B[i + 1].first));
            if (dp[j][0] != -1) chmax(ndp[j][nextf], dp[j][0]);
            if (dp[j][1] != -1) chmax(ndp[j][nextf], dp[j][1]);
        }
        dp = ndp;
    }

    cout << max(dp[K][0], dp[K][1]) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int n,k;
long long T[100000];

int P(long long p)
{
	int i=0,j;
	long long s;
	for(j=0;j<=k-1;j++)
	{
		s=0;
		while(s+T[i]<=p)
		{
			s+=T[i];
			i++;
			if(i==n) return n;
		}
	}
	return i;
}


int main()
{
	int i;
	int max_T=0;
	long long left=0;
	long long right;
	long long mid;
	int v;
	
	scanf("%d%d",&n,&k);
	for(i=0;i<=n-1;i++)
	  {
	    scanf("%d",&T[i]);
	    if(max_T<T[i]) max_T=T[i];
	  }
	right=max_T*n;
	while(right-left>1)
	{
		mid=(right+left)/2;
		v=P(mid);
		if(v>=n) right=mid;
		else left=mid;
	}
	printf("%d\n",right);
	return 0;
}

Measured memory_bytes: 3988
#include <cstdio>

int main() {
 	int N, A;
  	scanf(" %d", &N);
  	scanf(" %d", &A);
  
  	N = N%500;
  	if (N <= A) {
      	printf("Yes\n");
    } else {
      	printf("No\n");
    }
}

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

int main() {
	long long n,i,j,k,sum=0,count=0,ans=0;
	cin>>n;
	long long a[32]={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};
	cout<<a[n-1];
	return 0;
}

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

#define M 108
#define MAXX 999999999999999
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   
//   freopen("input.txt","rt",stdin);

   int d,t,s;
   cin>>d>>t>>s;
   
   int D = s*t;
   
   if(d<=D)
      cout<<"Yes\n";
   else
      cout<<"No\n";


}


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

using namespace std;

signed main(){
  const int BTIME = 6, TIME = 22-6;
  
  while(true){
    int N, M, L;
    int S, E, maximum = 0;
    vector<pair<int,int> > guys;
    vector<int> dp(1<<TIME,0);

    // cout<<TIME<<" "<<(1<<TIME)<<endl;
    
    cin>>N;

    if(!N) break;

    // guys.resize(N);

    // cout<<"size "<<guys.size()<<endl;
    
    for(int i = 0; i < N; i++){
      int tguy = 0;
      cin>>M>>L;
      
      for(int j = 0; j < M; j++){
	cin>>S>>E;
	S -= BTIME; E -= BTIME;

	for(int k = S; k < E; k++){
	  //cout<<"k = "<<k<<endl;
	  tguy |= 1<<k;
	}
      }
      // cout<<"guy "<<tguy<<" L "<<L<<endl;
      guys.push_back(make_pair(tguy,L));
      // cout<<"i = "<<i<<" "<<guys[i].first<<" "<<guys[i].second<<endl;
    }

    // for(int j = 0; j < N; j++){
    //   cout<<"j = "<<j<<" "<<guys[j].first<<" "<<guys[j].second<<endl;
    // }

    for(int i = 0; i < (1<<TIME); i++){// cout<<i<<" "<<dp.size()<<endl;
      int temp = 0;
      for(int j = 0; j < N; j++){
	if((guys[j].first | i) != i) continue;
	//	cout<<"i = "<<i<<"j  = "<<j<<" guy "<<guys[j].first<<endl;
	dp[i] = max(dp[i], dp[i&(~guys[j].first)] + guys[j].second);
	//	if(dp[i]){
	  // cout<<"i = "<<i<<endl;
	  //cout<<"dp "<<dp[i]<<endl;
	  
	//	}
      }
      maximum = max(dp[i], maximum);
    }

    cout<<dp[(1<<TIME)-1]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3292