akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N = int(input())

DP = [0, 0, 0]

DP[0], DP[1], DP[2] = list(map(int, input().split()))

for _ in range(N-1):
    next = [0, 0, 0]
    W = list(map(int, input().split()))
    next[0] = W[0] + max(DP[1], DP[2])
    next[1] = W[1] + max(DP[0], DP[2])
    next[2] = W[2] + max(DP[0], DP[1])
    DP = next

print(max(DP))


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x, t; cin >> n >> x >> t;
    int ans = t;
    while(n > x)
    {
        n -= x;
        ans += t;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		long value1 = scan.nextLong();
		long value2 = (long) (scan.nextDouble() * 100 + 0.001);
		long sum = value1 * value2 / 100;

		scan.close();
		System.out.println(sum);
	}
}


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

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

  scanf("%d%d",&a,&b);
  if (a<1||b<1||a>1000000000||b>1000000000) {
    printf("atai yokunai\n");
    exit(1);
  }
  if (a<b){
    c=a;
    a=b;
    b=c;
  }

  while(b>0){
    c=a%b;
    a=b;
    b=c;
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	if(input.indexOf("a") != -1 && input.indexOf("b") != -1 && input.indexOf("c") != -1){
       console.log("Yes");
       }else{
       console.log("No");
       }
}

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


Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(8, D - i);
    vector<vector<int>> L(26, vector<int>(t, 0));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < t; k++){
        L[j][k] = c[j] * (i + k - last[j]);
      }
    }
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    vector<vector<int>> L2 = L;
    for (int j = 0; j < 33000; j++){
      vector<int> next(t, 0);
      if (j < 24000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 31000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L2[next[k]][l] - (l - k) * c[next[k]];
          L2[next[k]][l] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
      }
      for (int k = 0; k < t; k++){
        L2[next[k]] = L[next[k]];
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3664
x,n = map(int,input().split())

if n == 0:
  p = input()
  print(x)
  exit()

num_list = list(map(int,input().split()))
i = 0

while True:
  if (x-i) not in num_list:
    print(x-i)
    break
  elif (x+i) not in num_list:
    print(x+i)
    break
  i += 1

Measured memory_bytes: 9180
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 2000006
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

vector<bool> is_prime(maxn, true);
vector<int> primes;
void sieve() {
	for (int i = 2; i * i < maxn; i++) {
		if (is_prime[i] == true) {
			for (int j = i * i; j < maxn; j += i) is_prime[j] = false;
		}
	}
	is_prime[0] = false;
	is_prime[1] = false;

	for (int i = 2; i <= maxn - 1; i++) {
		if (is_prime[i]) primes.push_back(i);
	}
	return;
}

int main() {

	sieve();
	int x; cin >> x;
	cout << *lower_bound(primes.begin(), primes.end(), x);

	return 0;
}

Measured memory_bytes: 4408
#include <stdio.h>

int main() {
	
	int angka = 0;
	scanf("%d",&angka);
	angka %= 10;
	if(angka == 2 || angka == 4 || angka == 5 || angka == 7 || angka == 9){
		printf("hon\n");
	}else if(angka == 0 || angka == 1 || angka == 6 || angka == 8){
		printf("pon\n");
	}else if(angka == 3){
		printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 3152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    i, _ := strconv.Atoi(nextLine())
    return i
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    sc.Split(bufio.ScanWords)
    n := nextInt()
    x := []int{}
    pair := 0
    x = append(x, 0)
    for i := 1; i <= n; i++ {
        x = append(x, nextInt())
    }
    for i := 1; i <= n; i++ {
      if val := x[i]; x[val] == i && val != 0 {
        x[val] = 0
        pair++
      }
    }
    fmt.Println(pair)
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, P;
  cin >> A >> P;
  cout << (3 * A + P) / 2 << "\n";
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,N) for(i=0;i<N;++i)
#define fos(i,b,N) for(i=b;i<N;++i)
#define forr(i,N) for(i=N-1;i>=0;--i)
#define disp(n) cout<<n<<endl;
#define M 10000007
#define ll long long
#define vll vector <long long int>
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
using namespace std;
int main()
{
long a,n;
  cin>>a>>n;
  long N[n],max=0;
  int i;
  for(i=0;i<n;++i)
    cin>>N[i];
  for(i=1;i<n;++i)
  {
    if(N[i]-N[i-1]>max)
      max=N[i]-N[i-1];
  }
  if(a-N[n-1]+N[0]>max)
    max=a-N[n-1]+N[0];
  cout<<a-max;
return 0;
}

Measured memory_bytes: 1792
h = gets.split.map &:to_i
k = gets.split.map &:to_i
a, b, c, d = gets.split.map &:to_i
H = h[0]*a + h[1]*b + h[0].div(10)*c + h[1].div(20)*d
K = k[0]*a + k[1]*b + k[0].div(10)*c + k[1].div(20)*d
puts "even" if H == K
puts "hiroshi" if H > K
puts "kenjiro" if H < K

Measured memory_bytes: 8672
import bisect
s = int(input())
a = []
a.append(s)
tmp = s
m = 1

while True:
	if tmp % 2 == 0:
		tmp //= 2
	else:
		tmp = 3 * tmp + 1
		
	m += 1
	i = bisect.bisect_left(a, tmp)
	
	if i < (m - 1) and tmp == a[i]:
		break
	else:
		bisect.insort_left(a, tmp)

print(m)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
pair<int,int> P[101010];
int mi[101010];
vector<pair<int,int>> D;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		P[i]={A[i],i};
	}
	sort(P,P+N);
	int C[2]={};
	FOR(i,N) {
		if(P[i].first<0) mi[P[i].second]=1;
		C[mi[P[i].second]]++;
	}
	
	if(C[0]==N) {
		mi[P[0].second]=1;
	}
	if(C[1]==N) {
		mi[P[N-1].second]=0;
	}
	multiset<ll> S[2];
	FOR(i,N) S[mi[i]].insert(A[i]);
	
	vector<pair<ll,ll>> V;
	while(S[0].size()>1) {
		auto it=S[0].begin();
		auto it2=S[1].begin();
		ll a=*it;
		ll b=*it2;
		S[0].erase(it);
		S[1].erase(it2);
		V.push_back({b,a});
		S[1].insert(b-a);
	}
	while(S[1].size()) {
		auto it=S[0].begin();
		auto it2=S[1].begin();
		ll a=*it;
		ll b=*it2;
		S[0].erase(it);
		S[1].erase(it2);
		V.push_back({a,b});
		S[0].insert(a-b);
	}
	
	cout<<*S[0].begin()<<endl;
	FORR(d,V) cout<<d.first<<" "<<d.second<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9844
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int A[n],ans[n];
    for (int i=0; i<n; i++) cin >> A[i];
    for (int i=0; i<n; i++){
        ans[A[i]-1] = i+1;
    }
    for (int i=0; i<n; i++){
        if (i>0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    ll N, W, inf = 1e10;
    cin >> N >> W;
    vl w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    vvl dp(N + 1, vl(1e5 + 1, inf));
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, 1e5 + 1) {
            if (j < v[i])
                dp[i + 1][j] = dp[i][j];
            else
                dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i, 1e5 + 1) if (dp[N][i] <= W) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
            think(
                [
                    [84, 97, 66],
                    [79, 89, 11],
                    [61, 59, 7]
                ],
                [89, 7, 87, 79, 24, 84, 30]
            ),
            'Yes'
        )

    def test_2(self):
        self.assertEqual(
            think(
                [
                    [41, 7, 46],
                    [26, 89, 2],
                    [78, 92, 8]
                ],
                [6, 45, 16, 57, 17]
            ),
            'No'
        )

    def test_3(self):
        self.assertEqual(
            think(
                [
                    [60, 88, 34],
                    [92, 41, 43],
                    [65, 73, 48]
                ],
                [60, 43, 88, 11, 48, 73, 65, 41, 92, 34]
            ),
            'Yes'
        )


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    a = []
    for _ in range(3):
        a.append(read_int(3))
    b = []
    n = read_int(1)[0]
    for _ in range(n):
        b.append(read_int(1)[0])
    return a, b


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    check_mark = 0
    for q in b:
        for row in a:
            for i, cell in enumerate(row):
                if cell == q:
                    row[i] = check_mark
    return 'Yes' if is_bingo(a, check_mark) else 'No'


def write(result):
    print(result)


def is_bingo(a, check_mark):
    rows = len(a)
    cols = len(a[0])

    for y in range(rows):
        if is_bingo_found_in_row(a, y, check_mark):
            return True

    for x in range(cols):
        if is_bingo_found_in_col(a, x, check_mark):
            return True

    if is_bingo_found_in_diagonal(a, check_mark):
        return True
    return False


def is_bingo_found_in_row(a, y, check_mark):
    row = a[y]
    return all(map(lambda x: x == check_mark, row))


def is_bingo_found_in_col(a, x, check_mark):
    col = []
    for row in a:
        col.append(row[x])
    return all(map(lambda x: x == check_mark, col))


def is_bingo_found_in_diagonal(a, check_mark):
    rows = len(a)
    cols = len(a[0])
    if rows != cols:
        return False

    diagonal = []
    for i in range(rows):
        diagonal.append(a[i][i])
    if all(map(lambda x: x == check_mark, diagonal)):
        return True

    diagonal = []
    for i in range(rows):
        diagonal.append(a[i][rows - i - 1])
    if all(map(lambda x: x == check_mark, diagonal)):
        return True

    return False


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 49648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

double ky(double a,double b,double c,double d){
    double x=a-c;
    double y=b-d;
    x*=x;
    y*=y;
    return sqrt(x+y);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<double> x(n);
    vector<double> y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    double ans2=1010;
    if(n==2){
        cout<<ky(x[0],y[0],x[1],y[1])/2<<endl;
    }
    else{

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double a,b,c,d;
            a=x[i];b=y[i];c=x[j];d=y[j];
            double kari=ky(a,b,c,d)/2;
            int ng=0;
            rep(k,n){
                if(k==i||k==j) continue;
                if(ky(x[k],y[k],(a+c)/2,(b+d)/2)>kari) ng++;
            }
            if(ng==0) ans2=min(ans2,kari);
            // cout<<i<<" "<<j<<" "<<kari<<endl;
        }
    }
    
    double ans3=1010;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                double a,b,c,d,e,f;
                a=x[i];b=y[i];c=x[j];d=y[j];e=x[k];f=y[k];
                double aa,bb,cc,dd,ee,ff;
                aa=a*a;bb=b*b;cc=c*c;dd=d*d;ee=e*e;ff=f*f;
                double px,py;
                py=((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f));
                if(c==a){
                    px=(2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a));
                }
                else{
                    px=(2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a));
                }
                double kari=ky(px,py,x[i],y[i]);
                int ng=0;
                rep(l,n){
                    if(l==i||l==j||l==k) continue;
                    if(ky(px,py,x[l],y[l])>kari) ng++;
                }
                if(ng==0) ans3=min(ans3,kari);
            }
        }
    }
    cout<<min(ans2,ans3)<<endl;

    
    }
}

Measured memory_bytes: 256
a=input()
b=map(int,raw_input().split())
b.sort()
c=[]
d=[]
max=0
loc=-1
for i in b:
    if max!=i:
        c.append(i)
        d.append(1)
        max=i
        loc+=1
    else:
        d[loc]+=1
ans=0
for i in range(len(c)):
    if c[i]>d[i]:
        ans+=d[i]
    elif c[i]<d[i]:
        ans+=d[i]-c[i]

print ans

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

typedef long long ll;


int main(int argc, char const *argv[])
{
	int k;
	cin >> k;

	string s;
	cin >> s;


	if(s.size() <= k){
		cout << s << "\n";
	}
	else{
		cout << s.substr(0,k) << "..." << "\n";
	}
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int S,h,m,s;
  scanf("%d",&S);
  if(0<=S && S<=86400){
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);
  }
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return ans;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

int n;
signed main() {
	cin >> n;
	for (int i = 1;; i++) {
		if (i * (i + 1) / 2 >= n) {
			for (int j = 1; j <= i; j++) {
				if (i * (i + 1) / 2 - n != j) cout << j << endl;
			}
			break;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

void  bubbleSort(int number[], int length);



int main() {

	int N, A[102], B[102];

	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		scanf("%d", &B[i]);
	}

	int ans = 0;

	for (int i = 0; i < N - 2; i++) {
		ans += min(B[i], B[i + 1]);
	}

	printf("%d", ans + B[N-2] + B[0]);








}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
n = int(input())
*A, = map(int, input().split())
# n = 4
# A = [10, 20, 30, 40]
DP = [[None for r in range(n+1)] for l in range(n)]
S = [0]
for i in range(n):
    S.append(S[-1]+A[i])


def dp(l, r):
    # 区間[l,r)での最小コスト
    if r <= l+1:
        DP[l][r] = 0
    if DP[l][r] != None:
        return DP[l][r]
    # S[r]-S[l]=sum(A[l:r])
    DP[l][r] = S[r]-S[l]+min([dp(l, i)+dp(i, r) for i in range(l+1, r)])
    return DP[l][r]


print(dp(0, n))


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

class point {
public:
	int x, y;
	point() {}
	point( int x_, int y_ ) :x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); } 
};

int main()
{
	point vp[2];
	cin >> vp[0].x >> vp[0].y >> vp[1].x >> vp[1].y;
	point base = vp[1] - vp[0];
	double norm = base.x * base.x + base.y * base.y;
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		point p;
		cin >> p.x >> p.y;

		p = p - vp[0];
		double dot = p.x * base.x + p.y * base.y;
		double x = vp[0].x + base.x * dot / norm;
		double y = vp[0].y + base.y * dot / norm;
		cout << fixed << setprecision(10) << x << " " << y << endl;
	}
}



Measured memory_bytes: 3288
object Main extends App {
  val (n, k) = scala.io.StdIn.readLine.split(' ').map(_.toInt) match { case Array(in, ik) => (in, ik) }
  val s      = scala.io.StdIn.readLine

  println(
    s.zipWithIndex
      .map {
        case (value, index) =>
          if (index == k - 1) value.toLower
          else value
      }
      .mkString("")
  )
}


Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;



int main(void){
    // Your code here!
    vector<int> nums;
    int N;
    cin >> N;
    
    for(int i = 0 ; i < N; i++){
        int tmp; 
        cin >> tmp;
        nums.push_back(tmp);
    }

    sort(nums.begin(), nums.end());
    int stack = 0;
    int bottom = 0;
    for(int i = 0; i < nums.size(); i++){
        if(bottom < nums[i]){
            stack += 1;
            bottom = nums[i];
        }
    }
    cout << stack;
}


Measured memory_bytes: 256
//   /$$$$           /$$                 /$$$$  /$$$$$$            /$$
//  | $$_/          | $$                |_  $$ /$$__  $$          | $$
//  | $$    /$$$$$$$| $$$$$$$   /$$$$$$   | $$|__/  \ $$ /$$$$$$$ | $$   /$$
//  | $$   /$$_____/| $$__  $$ |____  $$  | $$  /$$$$$$/| $$__  $$| $$  /$$/
//  | $$  |  $$$$$$ | $$  \ $$  /$$$$$$$  | $$ /$$____/ | $$  \ $$| $$$$$$/
//  | $$   \____  $$| $$  | $$ /$$__  $$  | $$| $$      | $$  | $$| $$_  $$
//  | $$$$ /$$$$$$$/| $$  | $$|  $$$$$$$ /$$$$| $$$$$$$$| $$  | $$| $$ \  $$
//  |____/|_______/ |__/  |__/ \_______/|____/|________/|__/  |__/|__/  \__/
//
//
//






#include <bits/stdc++.h>
using namespace std;


#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005
#define Vii  vector<ll>
#define pb  push_back
#define pii pair<ll,ll>
#define ff  first
#define ss second
#define vpii vector<pii >
#define endl '\n'

 ll n;
 ll arr[100005][4];
 ll dp[100005][4];
//--------------------------------------------------//

ll fun(ll day,ll flag ){
	
	if(day==n) return 0;
	
	if(dp[day][flag]!=-1) return dp[day][flag];
	
	ll maxi=0;
	
	if(flag==0){
		maxi=max(maxi,arr[day][1]+fun(day+1,1));
		maxi=max(maxi,arr[day][2]+fun(day+1,2));
		maxi=max(maxi,arr[day][3]+fun(day+1,3));	
	}else if(flag==1){
        maxi=max(maxi,arr[day][2]+fun(day+1,2));
        maxi=max(maxi,arr[day][3]+fun(day+1,3));
	}else if(flag==2){
        maxi=max(maxi,arr[day][1]+fun(day+1,1));
        maxi=max(maxi,arr[day][3]+fun(day+1,3));
	}else{
        maxi=max(maxi,arr[day][1]+fun(day+1,1));
        maxi=max(maxi,arr[day][2]+fun(day+1,2));
	}
	
	return dp[day][flag]=maxi;
}
	
	


//--------------------------------------------------//


int main(){
  ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
  cin>>n;
  for(ll i=0;i<n;i++){
  	for(ll j=1;j<=3;j++){
  		cin>>arr[i][j];
	  }
  }
  
  memset(dp,-1,sizeof(dp));
  
  ll ans=fun(0,0);
	cout<<ans;
	
	return 0;
}


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

#define C 26
#define L 160000

struct samNode{
    samNode *prv,*nxt[C];
    int val,res;

    void clear(){ prv=0;val=0;res=0;memset(nxt,0,sizeof(nxt)); }

    int calc(){
        if(prv==0)return 0;
        return val-prv->val;
    }
} *head, *tail;

samNode samNodePool[L<<1], *cur;

void init(){
    cur=samNodePool;
    head=tail=cur++;
    head->clear();
}

void extend(const int &c){
    samNode *p=tail, *q=cur++;
    q->clear();q->val=p->val+1;
    for(;p && !p->nxt[c];p=p->prv)p->nxt[c]=q;

    if(!p){
        q->prv=head;
    }else{
        samNode *x=p->nxt[c];
        if(p->val+1==x->val){
            q->prv=x;
        }else{
            samNode *y=cur++;
            y->clear();
            memcpy(y->nxt,x->nxt,sizeof(x->nxt));
            y->val=p->val+1;y->prv=x->prv;
            x->prv=q->prv=y;
            for(;p && p->nxt[c]==x;p=p->prv)p->nxt[c]=y;
        }
    }
    tail=q;
}

char a[L];
int n,m,k;

int rnk[L],num,len;
samNode *que[L<<1], *p;

int cnt[L<<1],acc[L<<1][C];

char ans[L];

int main(){
    //while(scanf("%s",a)!=EOF){
        scanf("%s",a);
        //gets(a);
        init();n=strlen(a);
        for(int i=0;a[i];i++)extend(a[i]-'a');

        memset(rnk,0,sizeof(rnk));num=0;
        for(samNode *p=head;p!=cur;p++){ rnk[p->val]++;num++; }
        for(int i=1;i<=n;i++)rnk[i]+=rnk[i-1];
        for(samNode *p=head;p!=cur;p++)que[--rnk[p->val]]=p;

        for(int i=num-1;i>=0;i--){samNode *p=que[i];
            p->res++;int k=p-samNodePool;
            cnt[k]=0;
            for(int j=0;j<C;j++){
                if(!p->nxt[j])continue;
                p->res+=p->nxt[j]->res;
                acc[k][cnt[k]++]=j;
            }
        }

        //scanf("%d",&m);
        m=1;
        for(int i=0;i<m;i++){
            scanf("%d",&k);len=0;
            samNode *p=head;
            for(;k;k--){
                int x=p-samNodePool;
                for(int _i=0;_i<cnt[x];_i++){int i=acc[x][_i];
                    //if(!p->nxt[i])continue;
                    if(p->nxt[i]->res>=k){
                        //printf("%c",'a'+i);
                        ans[len++]='a'+i;
                        p=p->nxt[i];
                        break;
                    }
                    k-=p->nxt[i]->res;
                }
            }
            ans[len++]=0;
            puts(ans);
            //printf("\n");
        }
    //}
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define dump(a) cout << #a << "=" << a << endl
using namespace std;


int main() {
	int E;
	while(cin >> E) {
		if (E == 0) { break; }

		int min_m = INT_MAX;
		for(int z = 0; z <= 100; z++) {
			for(int y = 0; y <= 1000; y++) {
				int x = E - y*y - z*z*z;
				if (x >= 0) {
					int m = x + y + z;
					min_m = min(m,min_m);
				}
			}
		}
		cout << min_m << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;

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

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

	cin >> a >> b >> c;

	cout << a * b / 2 << endl;

}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

before = H[0]
for i in range(1, N):
    if H[i]-1 >= before:
        H[i] = H[i] - 1

    if H[i] < before:
        print("No")
        exit()

    before = H[i]

print("Yes")


Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    long long n, k;
    long long temp;
    long long max;
    long long index;
    bool wild_flag;

    while(1){
        cin >> n;
        cin >> k;
        if(n == k && n == 0){
            break;
        }
        wild_flag = false;
        vector<short> check_list(n+1);
        for(long long i = 0; i < k; i++){
            cin >> temp;
            if(temp == 0){
                wild_flag = true;
            } else {
                check_list[temp] = 1;
            }
        }

        index = 0;
        vector<long long> start;
        vector<long long> finish;
        bool free_flag = true;
        while(index <= n){
            if(check_list[index] && free_flag){
                start.push_back(index);
                free_flag = false;
            }
            if(!free_flag && check_list[index] == 0){
                finish.push_back(index-1);
                free_flag = true;
            }
            if(!free_flag && index == n){
                finish.push_back(index);
                free_flag = true;
            }
            index++;
        }

        max = 0;
        vector <long long> length(start.size());
        for(long long i = 0; i < start.size(); i++){
            length[i] = finish[i] - start[i] + 1;
            if(max < length[i]){
                max = length[i];
            }
        }

        long long mix = 0;
        if(wild_flag){
            for(long long i = 1; i < start.size(); i++){
                if(start[i] - finish[i-1] == 2){
                    mix = length[i-1] + length[i] + 1;
                    if(max < mix){
                        max = mix;
                    }
                }
            }
        }
        cout << max << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    long long L;
    float ans;
    cin >> L;
    ans = 1.0;
    if (L % 3 == 0){
        cout << (L/3) * (L/3) * (L/3) << endl; 
        return 0;
    }

    ans *= (L / 3.0);
    ans *= (L / 3.0);
    ans *= (L / 3.0);

    printf("%.12lf\n", ans);
    return 0;
}



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

int main(int argc, char const *argv[]) {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[0] == a[1] || a[1] == a[2]) {
    if (a[0] == a[1] && a[1] == a[2])
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict


dct = defaultdict(lambda:0)

N = int(input())
for _ in range(N):
  s = "".join(sorted(str(input())))
  dct[s] += 1

ans = 0
for k in dct:
  if dct[k] > 1:
    ans += dct[k]*(dct[k]-1)//2
print(ans)

Measured memory_bytes: 62168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[200001];
vector<int> vec;
signed main(){
  int n, k;
  scanf("%lld%lld", &n, &k);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n);a[n] = -1;
  int tmp = -1, cnt = 0;

  rep(i,n+1){
    if(tmp != a[i]){
      vec.push_back(cnt);cnt = 0;
      tmp = a[i];
    }cnt++;
  }
  int m = vec.size(), ans = 0;
  sort(all(vec), greater<int>());
  //vec.pop_back();
  //rep(i,vec.size())printf("%lld ", vec[i]);
  //printf("%lld\n", vec.back());
  rep(i,m-k){
    ans += vec.back();
    //printf("%lld %lld\n", vec.back(), ans);
    vec.pop_back();
  }
  printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int ans = (N+1) / 2;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<vector<ll> > v;

ll f(ll p){
  if(v[p].sz==0){
    return 0;
  }
  vector<ll> v1;
  rep(i,0,v[p].sz){
    v1.pb(f(v[p][i])+1);
  }
  sort(all(v1));
  reverse(all(v1));
  ll mx = 0;
  rep(i,0,v1.sz){
    mx = max(mx,i+v1[i]);
  }
  return mx;
}

int main() {
  ll n;
  cin>>n;
  vector<vector<ll> > v_(n,vector<ll>());
  v = v_;
  rep(i,1,n){
    ll a;
    cin>>a;
    a--;
    v[a].pb(i);
  }
  cout << f(0) << endl;
  return 0;
}





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

typedef long long int ll;

int main(){
  ll n,x,y;
  cin>>n>>x>>y;
  ll i,j;
  vector <ll> dist(n);
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      ll ans=min(j-i,abs(i-x)+1+abs(j-y));
      dist[ans]++;
  }
}
  for(i=1;i<n;i++){
    cout<<dist[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    x, y, z = map(int, input().split())
    c += [x]
    s += [y]
    f += [z]

for i in range(n - 1):
    ans = s[i] + c[i]
    for j in range(i + 1, n-1):
        if ans < s[j]:
            ans = s[j] + c[j]
        else:
            ans = f[j] * math.ceil(ans / f[j]) + c[j]
    print(ans)
print(0)

Measured memory_bytes: 42076
import sys

N = int(sys.stdin.readline())
S = ["", ""]
S[0] = sys.stdin.readline().strip()
S[1] = sys.stdin.readline().strip()

mod = 10**9 + 7

pre = [S[0][0], S[1][0]]
ans = 3
if S[0][0] != S[1][0]:
    ans *= 2
# print(0, 1, ans)

for i in range(1, N):
    # 一つ前と同じ場合
    if pre[0] == S[0][i] and pre[1] == S[1][i]:
        continue

    if pre[0] == pre[1]:
        ans *= 2
        ans %= mod
        # 縦詰が連続
        # if S[0][i] == S[1][i]:
        #     ans *= 2
        #     ans %= mod
        # else:
        #     ans *= 2
        #     ans %= mod
    else:
        # 1パターンしかない
        if S[0][i] == S[1][i]:
            ans *= 1
        else:
            ans *= 3
            ans %= mod

    # print(ans)

    pre[0] = S[0][i]
    pre[1] = S[1][i]

print(ans)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n,k;cin>>n>>k;
        vi a(n);
        inputarr(a,n);
        sort(all(a));
        vi div;
        int sum=0;
        rep0(n) sum+=a[i];
        for(int i=1;i*i<=sum;i++){
            if(sum%i==0){
                div.pb(i);
                if(sum!=i*i) div.pb(sum/i);
            }
        }

        sort(all(div));
      //FORE(it,div) cout<<*it<<" ";cout<<endl;
        int z=div.size();
        rep0(z){
            int num=div[z-i-1],temp=0,count=0;
            vi x;
            repi(j,0,n) x.pb(a[j]%num);
            sort(all(x));
            vi suffx(n+1,0),prefix(n+1,0);
            rep(1,n+1)
            {suffx[i]=suffx[i-1]+x[i-1];}
            FORD(j,n-1,0){
                int i=n-j,k=n-j-1;
                prefix[i]=prefix[i-1]+num-x[j];
            }
            int ans=0;
            
            repi(j,0,n+1){
                if(suffx[j]==prefix[n-j]&&suffx[j]<=k){
                    return cout<<num,0;
                }
            }

        }
        

        r0

     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        mp[a] ++;
        if(mp[a] > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12952
import sys
A, B, C, D = map(int, input())

for i in range(2):
  for j in range(2):
    for k in range(2):
      answer = A
      answer = answer + B if i == 0 else answer - B
      answer = answer + C if j == 0 else answer - C
      answer = answer + D if k == 0 else answer - D
      if answer == 7:
        o1 = '+' if i == 0 else '-'
        o2 = '+' if j == 0 else '-'
        o3 = '+' if k == 0 else '-'
        print('{}{}{}{}{}{}{}=7'.format(A,o1,B,o2,C,o3,D))
        sys.exit()
      

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

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

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
    string S, T;
    cin >> S >> T;

    int ans = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) ans += 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3920
function Main(input) {
  input=input.split("\n");
  const N=input[0].split(' ')[0]-0;
  const X=input[0].split(' ')[1]-0;
  const T=input[0].split(' ')[2]-0;
  console.log(Math.ceil(N/X)*T);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 30304
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:

    int N, Q;

    vector<vector<int>> tree;
    vector<Int> val;

    void dfs(int v, Int a = 0, int p = -1) {
        val[v] += a;
        for (auto e : tree[v]) {
            if (e != p) {
                dfs(e, val[v], v);
            }
        }
    }

    void solve() {
        cin >> N >> Q;
        tree.resize(N);
        val.resize(N);

        for (int i = 0; i + 1 < N; ++i) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            tree[a].push_back(b);
            tree[b].push_back(a);
        }

        for (int j = 0; j < Q; ++j) {
            int p;
            Int x;
            cin >> p >> x;
            p--;
            val[p] += x;
        }

        dfs(0);

        for (int i = 0; i < N; ++i) {
            cout << val[i] << " ";
        }
        cout << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

const int MOD=1000000007;
string S;
void add(long long &a,long long b){
    a+=b;
    if(a>=MOD)a-=MOD;
}
long long dp[210000][5];
int main(){
    cin>>S;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<S.size();i++){
        for(int j=0;j<5;j++){
            if(S[i]!='?')add(dp[i+1][j],dp[i][j]);
            else add(dp[i+1][j],dp[i][j]*3%MOD);

        }
        if(S[i]=='A'||S[i]=='?')add(dp[i+1][1],dp[i][0]);
        if(S[i]=='B'||S[i]=='?')add(dp[i+1][2],dp[i][1]);
        if(S[i]=='C'||S[i]=='?')add(dp[i+1][3],dp[i][2]);
    }
    cout<<dp[S.size()][3]<<endl;
    }

Measured memory_bytes: 8704
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
 
    int n,m,count,tmp;
 
    while(true){
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0)break;
 
        count = n;
        int array[n];
        for(int i=0; i < n; i++)array[i] = 1;
 
        tmp = 0;
        for(int i=0;count > 1;){
            if(array[i] == 1){
                tmp++;
                if(tmp == m){
                    array[i] = 0;
                    count--;
                    tmp = 0;
                    i = (i+1)%n;
                }else{
                    i = (i+1)%n;
                }
            }else{
                i = (i+1)%n;
            }
        }
 
        for(int i=0; i < n; i++){
            if(array[i] == 1)printf("%d\n",i+1);
        }
 
    }
 
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B; cin>>A>>B;
  string ans="Impossible";
  if(A%3==0||B%3==0||(A+B)%3==0)
    ans="Possible";
  cout<<ans<<endl;
  }


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    bool flg=true;
    ll pretime;
    ll pre;
    for (int i = 0; i < n; ++i) {
        ll t,x,y;
        cin >>t>>x>>y;
        ll sum=x+y;
        if(t%2!=sum%2)flg=false;
        if(t<sum)flg=false;
        if(i!=0) {
            if (abs(pre - sum) > t - pretime)flg=false;
        }
        pretime=t;
        pre=sum;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256