akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
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;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N, W; cin >> N >> W;
  int w[N], v[N]; rep(i,N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(N+1,vector<ll>(200000,0));
  
  rep(i,N) rep(j,W+1){  // 貰うDP
    if (j-w[i]>=0) chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);  // 選ぶ場合
    chmax(dp[i+1][j], dp[i][j]);  // 選ばない場合
  }
  cout << dp[N][W] << endl;


 

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 162676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {

  int N; cin >> N;

  string S,T,U; cin >> S >> T;

  rep(i,N){
    U.push_back(S[i]);
    U.push_back(T[i]);
  }
  
  cout << U << endl;

  return 0;
}

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

void solve(void){
  ll n, k; cin >> n >> k;
  vector<ll> h(n, 0);
  rep(n, i) cin >> h[i];

  vector<ll> dp(n+1, INF);
  dp[0] = 0;
  for(ll i = 1; i < n; ++i) {
    for(ll j = 1; j <= k; ++j) {
      if (i >= j) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }

  cout << dp[n-1] << endl;
} 

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


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    map<char,int> m2;
    rep(i,N){
        string S; cin >> S;
        map<char,int> m;
        rep(j,S.size()){
            m[S[j]]++;
        }
        if(i==0){
            m2=m;
        }
        else{
            for(char c='a';c<='z';c++){
                m2[c]=min(m[c],m2[c]);
            }
        }
    } 
    for(char c='a';c<='z';c++){
        for(int i=0;i<m2[c];i++){
            cout << c;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[4] = {0,-1,0,1};
int ny[4] = {1,0,-1,0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin >> x >> a >> b;
    PRINT((x-a)%b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

//ここから書き始める

int main(){
	ll n; cin >> n; 
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	SORT(a);
	vector<ll> b(n);//かける数
	vector<ll> c(n);
	rep(i,n){
		if(i == 0){
			c[i] = 1;
		}
		else if(i == n-1 ){
			if(n % 2 ==0){
				c[i] = -1;
			}
			else{
				c[i] = 1;
			}
		}
		else if(i%2 == 1){ 
			c[i] = -2;
		}
		else c[i] =2;
	}
	SORT(c);
//	rep(i,n){
//		cout<<c[i]<<" ";
//	}
	if(n % 2 == 0){
		rep(i,n){
			if(i==0) b[i] = -1;
			else if(i == n - 1) b[i] = 1;
			else{
				if(i%2 ==0) {
					b[i] =-2;
				}
				else{
					b[i] = 2;
				}
			}
		}
	}

	else if( n % 2 == 1){
		rep(i,n){
			if(i == 0 || i == n-1 ){
				b[i] = -1;
			}
			else if ( i%2 == 0 ){
				b[i] =-2;
			}
			else if( i % 2 == 1){
				b[i] = 2;
			}
		}
	}
	SORT(b);
//	rep(i,n){
//		cout<<b[i]<<" ";
//	}
	ll ans = 0 ;
	ll ans1 = 0;
	rep(i,n){
		ans += a[i] * b[i];
		ans1+= a[i] * c[i];
	}
	chmax(ans,ans1);
	cout<<ans<<endl;


}


Measured memory_bytes: 2688
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double T = sc.nextInt();

		double A = sc.nextInt();
		double min = 999999999;
		int ans = 0;

		for (int i = 0; i < N; i++) {
			int H = sc.nextInt();

			double AverageTemperature = T - H * 0.006;

			double difference = Math.abs(A - AverageTemperature);
			if (min > difference) {
				min = difference;
				ans = i + 1;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 22356
N = int(input())
a = N // 100
b = N % 100
if 1 <= a <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 61812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

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

    ll a, b, c;
    int x, y;
    cin >> a >> b >> c >> x >> y;
    ll res = 1e+18;
    for(int i = 0; i <= max(x, y); ++i){
        ll hoge = c * 2 * i;
        hoge += a * max(0, x - i);
        hoge += b * max(0, y - i);
        chmin(res, hoge);
    }
    cout << res << endl;
}

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

int main() {
 int a, b, c;
cin >> a >> b >> c;
  int listen = 0;
  while(true){
    if(b<a) break;
   if(a <= b) {
     ++listen;
     b -= a;
   }
    if(listen == c) break;
    
  }
  cout << listen << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll total1=0,total2=0,total;
  if(a>b)
  {
    total1 = b*c;
    total2 = (a-b)*d;
    total = total1+total2;
  }
  else if(a==b)
  {
    total1 = b*c;
    total = total1;
  }
  else
  {
    total1 = a*c;
    total = total1;
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
A = tuple(map(int,input().split()))

import sys

sys.setrecursionlimit(1000000000)
from collections import deque


seen = [0 for i in range(n)]

hist = deque([])  # 頂点の訪問履歴
pos = -1  # サイクルの1成分 -1はサイクル未発見


def dfs(x, p):  # pはxの親
    global pos  # global!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    seen[x] = 1
    hist.append(x)  # 訪れたらhistにappend
    if seen[A[x]-1] == 1:
        pos = A[x]-1
        return  # サイクルを発見したら、即すべてのdfsを終える
    # 残りはseen[x]=0のみ
    dfs(A[x]-1, x)
    if pos != -1: return  # 帰りがけ、サイクルが検出済みなら何もしない

    hist.pop()  # stackの末尾を消す
    # ループなく平和に終わったらpopできる
    return  # まあなくてもいいけどreturnは終了であることを強調


dfs(0, -1)

# この状態だと、サイクルに入る前に通った枝葉がhistに入ってる。
# 枝葉が終わったら、posからループの順番に頂点番号が入ってる。
cycle = []
while hist:
    qwe = hist.pop()
    cycle.append(qwe)
    if qwe == pos: break

roop = len(cycle)
sen = seen.count(1)

if k<=n:
    no = 0
    for i in range(k):
        no = A[no]-1
    print(no+1)
else:
    tmp = k-sen+roop
    tmp%=roop
    print(cycle[-tmp-1]+1)


Measured memory_bytes: 248688
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;

signed main(){
    int n;
    cin>>n;
    int b[100];
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    int a[100];
    for(int i=0;i<n;i++){
        if(i==0)a[i]=b[i];
        else if(i==n-1)a[n-1]=b[n-2];
        else a[i]=min(b[i-1],b[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace B___Postal_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var S = Console.ReadLine().Split('-').ToArray();
            var A = A_B[0];
            var B = A_B[1];

            Console.WriteLine(S[0].Length == A && S[1].Length == B ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        s: chars,
    }
    let (mut A, mut Z) = (0, s.len());
    for i in 0..s.len() {
        if s[i] == 'A' {
            A = i;
            break;
        }
    }
    for i in (0..s.len()).rev() {
        if s[i] == 'Z' {
            Z = i;
            break;
        }
    }
    println!("{}", Z - A + 1);
}

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

using namespace std;

int main(){
  int n,x;
  vector<int> li;
  cin >> n >> x;
  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    li.push_back(temp);
  }
  int ans = 0;
  int count = 0;
  while(ans <= x){
    ans += li[count];
    count++;
    if( ans > x ){
      count--;
      break;
    }
    if( count >= li.size() ) break;
  }

  cout << count + 1;
  return 0;
}


Measured memory_bytes: 256
def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    sum = 0
    for i in range(N):
        sum += A[i]

    cnt = 0
    tmp = sum/(4*M)
    for i in range(N):
        if A[i] >= tmp:
            cnt += 1

    if cnt >= M:
        print('Yes')
    else:
        print('No')

main()


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

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

    vector<pair<long long, long long>> AB(N);
    for (int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB.begin(), AB.end());
    long long cnt = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (cnt + AB[i].second >= M) {
            ans += AB[i].first * (M - cnt);
            break;
        }
        else {
            ans += AB[i].first * AB[i].second;
            cnt += AB[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int gcd2(int a, int b){
	int t;
	if(a>b) t=a, a=b, b=t;
	t = b % a;
	while(t!=0){
		b = a;
		a = t;
		t = b % a;
	}
	return a;
}


int main(void){
	int n, i;
	int a[100000], k;
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++){
		scanf("%d", a+i);
	}
	int g=a[0];
	for(i=1; i<n; i++){
		g=gcd2(g, a[i]);
	}
	for(i=0; i<n; i++){
		if(a[i]>=k && k%g==0){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string s;
    string per="CODEFESTIVAL2016";
    cin >> s;
    int count=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=per[i])count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};

int main(){
  int H,W; cin >> H >> W;
  char g[H][W];
  int s[H][W];
  int cnt = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> g[i][j];
      s[i][j] = 0;
      if(g[i][j] == '#') cnt++;
    }
  }
  queue<P> q;
  q.push(P(0,0));
  while(!q.empty()){
    P p = q.front(); q.pop();
    int y = p.first, x = p.second;
    for(int i = 0; i < 4; i++){
      int dy = y+ny[i], dx = x+nx[i];
      if(s[dy][dx] || g[dy][dx] == '#') continue;
      if(0 > dy || dy >= H || 0 > dx || dx >= W) continue;
      s[dy][dx] = s[y][x]+1;
      q.push(P(dy,dx));
    }
  }
  int ans = H*W;
  cnt += s[H-1][W-1] + 1;
  ans -= cnt;
  if(s[H-1][W-1] == 0) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	bool ok=0;
	for(int c=0;c<=x;++c){
		int t=x-c;
		if(t*4+c*2==y){
			ok=1;
			break;
		}
	} 
	if(ok){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	return 0;
} 

Measured memory_bytes: 3596
n = int(input())
A = list(map(int, input().split()))
mydict = {}
total = 0
for a in A:
    mydict[a] = mydict[a] + 1 if a in mydict else 1
    total += a

q = int(input())
for i in range(0, q):
    b, c = map(int, input().split())
    if b in mydict:
        if not c in mydict:
            mydict[c] = 0
        total += (c - b) * mydict[b]
        mydict[c] += mydict[b]
        mydict[b] = 0
    print(total)

Measured memory_bytes: 20880
#!/usr/bin/env python3
import sys
import numpy as np

MOD = 1000000007  # type: int


def solve(N: int, S: str):
    abc = "abcdefghijklmnopqrstuvwxyz"
    # ans = 2**N % MOD
    # n = N
    # pre = 1
    # for c in abc:
    #     count = S.count(c)
    #     kaburi = ((2 ** count)-1-count)
    #     ans -= pre * kaburi * (2 ** (n - count))
    #     pre *= (1 + count) % MOD
    #     n -= count
    #     ans = ans % MOD
    # print(int(ans-1))

    seki = 1
    for c in abc:
        seki *= 1+S.count(c)
    print((seki-1) % MOD)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20864
#include <iostream>
 
#define N 100001
#define DIV 1000000007
#define llint long long int
 
llint pow(llint a, int n){
  if(n<1) return 1;
  if(n==1) return a;
  llint res = a;
  for(int i=2; i<=n; i++){
    res = (res*a)%DIV;
  }
  return res;
}
 
   int A[N];
  int count[N];

int main(void){
  int n;
 
  std::cin >> n;
  bool isEven = n%2==0;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
 
    if(!isEven and A[i]%2==1){
      std::cout << 0 << std::endl;
      return 0;
    }else if(isEven and A[i]%2==0){
      std::cout << 0 << std::endl;
      return 0;
    }else if(A[i]>n-1){
      std::cout << 0 << std::endl;
      return 0;
    }
 
    
    count[A[i]]++;
    if(count[A[i]] == 3){
      std::cout << 0 << std::endl;
      return 0;
    }else if(A[i] == 0 and count[A[i]] == 2){
      std::cout << 0 << std::endl;
      return 0;
    }
  }
 
  std::cout << (isEven?pow(2, (n-2)/2+1):pow(2, (n-1)/2)) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
from math import sqrt
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
if N == 1:
    ans = 0
else:
    A = factorization(N)
    B = []
    for a in A:
        B.append(a[1])
        ans = 0
    for b in B:
        n = int((-1 + sqrt(8*b + 1)) / 2)
        ans += n
print(ans)  

Measured memory_bytes: 63720
console.log((args=>{
  const [[N,M],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0));
  const a = Array(N).fill(NaN);
  for ( let i = 0; i < M; i++ ) {
    const [s,c] = tmp[i];
    if ( N > 1 && s === 1 && c === 0 ) return '-1';
    if ( isNaN(a[s-1]) ) a[s-1] = c;
    else if ( a[s-1] !== c ) return '-1';
  }
  if ( isNaN(a[0]) && N > 1 ) a[0] = 1;
  return a.map(v=>v|0).join``;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29584
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

string moji[10];

int main(void) {
    int n;
    moji[1] = ".,!? ";
    moji[2] = "abc";
    moji[3] = "def";
    moji[4] = "ghi";
    moji[5] = "jkl";
    moji[6] = "mno";
    moji[7] = "pqrs";
    moji[8] = "tuv";
    moji[9] = "wxyz";
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        string ans;
        for (int i = 0; i < s.size(); i++) {
            int num = 0;
            while (s[i] != '0') {
                i++;
                num++;
            }
            if (num == 0) continue;
            int tmp = s[i-1] - '0';
            if (tmp == 1) num = (num-1) % 5;
            else if (tmp == 7 || tmp == 9) num = (num-1) % 4;
            else num = (num-1) % 3;
            ans += moji[tmp][num];
        }
        cout << ans << endl;
    }
    return 0;
}

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

using ld = long double;
using ll = int64_t;
using Str = std::string;
template <class T> using Vec = std::vector<T>;
template <class K, class V> using UM = std::unordered_map<K, V>;

namespace io {

    template <class ...As> auto &read(As &...as)
    { return (std::cin >> ... >> as); }

} // namespace io

#define PB push_back

#define A(xs) xs.begin(), xs.end()
#define R(...) __VA_ARGS__; io::read(__VA_ARGS__)
#define FOR(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int main() {
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    ll R(a, v, b, w, t);
    if (v <= w) {
        cout << "NO";
        return 0;
    }
    int dist = abs(a - b);
    if ((v - w) * t < dist) {
        cout << "NO";
    } else
        cout << "YES";
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void dfs(vector<vector<int>> &gr, int now, vector<bool> chk, int ct, int &ans){
  chk.at(now) = true;
  ct++;
  bool f = false;
  for(auto i : gr.at(now)){
    if(chk.at(i) == true) continue;
    f = true;
    dfs(gr, i, chk, ct, ans);
  }
  if(f == false){
    if(ct == gr.size()) ans++;
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n, vector<int>());
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    gr.at(a).push_back(b);
    gr.at(b).push_back(a);
  }
  vector<bool> chk(n, false);
  int ans = 0;
  dfs(gr, 0, chk, 0, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
use io::*;
use std::*;

fn solve(N: i64, A: Vec<i64>) {
    let max = A.iter().cloned().fold(i64::MIN, cmp::max);
    let min = A.iter().cloned().fold(i64::MAX, cmp::min);
    println!("{}", max - min);
}

fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: i64;
    N = scanner.next();
    let mut A: Vec<i64> = vec![0i64; (N) as usize];
    for i in 0..(N) as usize {
        A[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(N, A)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	if (S[1] == 'R') cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

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

using namespace std;

int main(){
	int i,o,t,j,l,s,z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	long long ans=0;
	ans += o;
	int xi,xj,xl;
	xi = i%2;
	xj = j%2;
	xl = l%2;
	ans += 2*(i/2);
	ans += 2*(j/2);
	ans += 2*(l/2);
	if(xi==1&&xj==1&&xl==1){
		ans +=3;
	}else if(xi==1 && xj==1&&l>0){
		ans +=1;
	}else if(xi==1 && xl==1&&j>0){
		ans +=1;
	}else if(xj==1 && xl==1&&i>0){
		ans +=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations as 敬語使うべきじゃん
N, C = map(int, input().split())
D = [[0] * (C + 1)] + [[0] + list(map(int, input().split())) for _ in range(C)]
c = [[0] * (N + 1)] + [[0] + list(map(int, input().split())) for _ in range(N)]
#print(D, c)

group = [[] for _ in range(3)]
for i in range(1, N + 1):
  for j in range(1, N + 1):
    m = (i + j) % 3
    group[m].append(c[i][j])
#print(group)

#色変えるだで
#色変えたときにかかるコストを先に計算しますよーしますしますし
costs = [[0] * (C + 1) for _ in range(3)]
for i in range(3):
  for color in range(1, C + 1):
    temp = 0
    for j in range(len(group[i])):
      temp += D[group[i][j]][color]
    costs[i][color] = temp
#print(costs)
res = 10 ** 10
for per in list(敬語使うべきじゃん(list(range(1, C + 1)), 3)):
  #print(per)
  #色はグループごとにちがう
  i, j, k = per[0], per[1], per[2]
  res = min(res, costs[0][i] + costs[1][j] + costs[2][k])
print(res)
  


Measured memory_bytes: 56668
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,m;
  cin >> n >> m;
  auto G = vector<vector<int>>(n);
  for(int i = 0;i < m;++i){
    int a,b;
    cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
  }
  int s,t;
  cin >> s >> t;
  --s;--t;
  
  ll dist[100010][3];
  fill(dist[0],dist[0] + 100010 * 3,inf);
  priority_queue<T,vector<T>,greater<T>> que;
  que.push(make_tuple(0LL,s,0));
  while(!que.empty()){
    ll d;
    int node,step;
    tie(d,node,step) = que.top();
    que.pop();
    if(d < dist[node][step]){
      dist[node][step] = d;
      int nstep = (step + 1) % 3;
      for(int i : G[node]){
        if(d + 1 < dist[i][nstep]){
          que.push(make_tuple(d+1,i,nstep));
        }
      }
    }
  }
  /*
  for(int i = 0;i < n;++i){
    for(int j = 0;j < 3;++j){
      cout << dist[i][j] << " ";
    }
    cout << endl;
  }
  */
  
  if(dist[t][0] == inf){
    cout << -1 << endl;
  }else{
    cout << dist[t][0] / 3 << endl;
  }
  return 0;
}


Measured memory_bytes: 8820
H, W = map(int, input().split())
A = []
for i in range(H):
  A.append(input())
dis = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
for i in range(H):
  s = ""
  for j in range(W):
    if A[i][j] == "#":
      s += "#"
    else:
      count = 0
      for d in dis:
        if 0 <= i + d[0] < H and 0 <= j + d[1] < W:
          if A[i+d[0]][j+d[1]] == "#":
            count += 1
      s += str(count)
  print(s)

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

const int maxn = 100009;
LL f[maxn*35][2], val[maxn*35], ans;
int T[maxn*35][2], n, K, tmp, A, B, size = 1;

void insert(int A, int B){
	int o = 1;
	for (int i=30; i>=0; i--){
		if (!T[o][A>>i&1]) T[o][A>>i&1] = ++size;
		o = T[o][A>>i&1];
	}
	val[o] += B;
}

LL dfs(int a, int b, int dep){
	if (dep == -1) return val[a];
	if (~f[a][b]) return f[a][b];
	LL &ans = f[a][b];
	if (b == 0) ans = dfs(T[a][0], 0, dep-1) + dfs(T[a][1], 0, dep-1);
	else if (K>>dep&1) ans = dfs(T[a][0], 1, dep-1) + dfs(T[a][1], 1, dep-1);
	else ans = dfs(T[a][0], 1, dep-1);
	return ans;
}

int main(){
	scanf("%d%d", &n, &K);
	for (int i=1; i<=n; i++){
		scanf("%d%d", &A, &B);
		insert(A, B);
	}
	memset(f, -1, sizeof f);
	ans = dfs(1, 2, 30);
	tmp = K;
	for (int i=29; i>=0; i--){
		if (!(tmp>>i&1)) continue;
		K = (((tmp >> i) - 1) << i) + ((1 << i) - 1);
		memset(f, -1, sizeof f);
		ans = max(ans, dfs(1, 2, 30));
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

template<typename T = int>
vector<T> dijkstra(vector<pair<int, T>> G[], int size, int st, const T inf) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
    pq.push({0, st});
    vector<T> dist(size, inf);
    dist[st] = 0;
    while (!pq.empty()) {
        const auto now = pq.top();
        pq.pop();
        for (auto nxt : G[now.second]) {
            const T nextCost = now.first + nxt.second;
            if (dist[nxt.first] <= nextCost) {
                continue;
            }
            dist[nxt.first] = nextCost;
            pq.push(make_pair(nextCost, nxt.first));
        }
    }
    return dist;
}

const int MAX = 1e5 + 10;
vector<pair<int, long long>> Graph[MAX];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--;
        b--;
        Graph[a].emplace_back(make_pair(b, c));
        Graph[b].emplace_back(make_pair(a, c));
    }
    int q, k;
    cin >> q >> k;
    k--;
    auto dist = dijkstra(Graph, n, k, (long long) 1e18);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--;y--;
        cout << dist[x] + dist[y] << endl;
    }
}


Measured memory_bytes: 11120
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

void check(int hands[3],vector<int>& candidates){
  for(int h=0;h<12;h++){
    for(int m=0;m<60;m++){
      for(int s=0;s<60;s++){
	int h_angle = h*30 + (m/12)*6;
	int m_angle = m*6;
	int s_angle = s*6;

	int idx[] = {0,1,2};
	do{
	  int a = hands[idx[0]];
	  int b = hands[idx[1]];
	  int c = hands[idx[2]];

	  for(int offset=0;offset<360;offset+=6){
	    int next_a = ((a*6 + offset) % 360);
	    int next_b = ((b*6 + offset) % 360);
	    int next_c = ((c*6 + offset) % 360);

	    if(next_a == h_angle 
	       && next_b == m_angle 
	       && next_c == s_angle){
	      candidates.push_back(h*60*60+m*60+s);
	    }
	  }
	}while(next_permutation(idx,idx+3));
      }
    }
  }
}

int main(){
  int total_watches;
  while(~scanf("%d",&total_watches)){
    if(total_watches == 0) break;
    vector<int> watches[total_watches];
    vector<int> all_times;
    for(int watch_idx = 0; watch_idx < total_watches; watch_idx++){
      int hands[3];
      for(int hand_idx = 0; hand_idx < 3; hand_idx++){
	scanf("%d",hands + hand_idx);
      }
      vector<int> candidates;
      check(hands,candidates);
      watches[watch_idx] = candidates;

      for(int candidate_idx=0;candidate_idx < candidates.size(); candidate_idx++){
	all_times.push_back(candidates[candidate_idx]);
      }
    }
    sort(all_times.begin(),all_times.end());
    all_times.erase( unique(all_times.begin(), all_times.end()), all_times.end() );

    int min_diff = INF;
    string res = "";
    for(int first_idx = 0; first_idx < all_times.size(); first_idx++){
      for(int last_idx = first_idx; last_idx < all_times.size(); last_idx++){
	int first_time = all_times[first_idx];
	int last_time = all_times[last_idx];

	bool isok = true;

	int diff = all_times[last_idx] - all_times[first_idx];
	for(int watch_idx=0;watch_idx < total_watches;watch_idx++){
	  const vector<int>& candidates = watches[watch_idx]; 

	  int first_time_idx = lower_bound(candidates.begin(),candidates.end(),first_time) - candidates.begin();

	  if(first_time_idx >= candidates.size()
	     || candidates[first_time_idx] > last_time){
	    isok = false;
	    break;
	  }
	}

	if(isok
	   && min_diff > diff){
	  min_diff = diff;
	  char buf[64];
	  sprintf(buf,"%02d:%02d:%02d %02d:%02d:%02d",
		  first_time/3600,(first_time%3600)/60,first_time%60,
		  last_time/3600,(last_time%3600)/60,last_time%60);
	  res = buf;
	}
      }
    }

    printf("%s\n",res.c_str());
  }
}

Measured memory_bytes: 1268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    int n;
    cin>>n;
    vi d(n);
    rep(i,n)cin>>d[i];
    int m;
    cin>>m;
    vi t(m);
    rep(i,m)cin>>t[i];
    map<int,int> s;
    rep(i,n)s[d[i]]++;
    rep(i,m){
        if(s[t[i]]<=0){
            fin("NO");
            return 0;
        } else {
            s[t[i]]--;
        }
    }
    fin("YES");
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if (B <= C || D <= A) {
			System.out.println(0);
		} else if(C <= A && D <= B){
			System.out.println(D - A);
		} else if(C >= A && D <= B){
			System.out.println(D - C);
		} else if(C >= A && D >= B) {
			System.out.println(B - C);
		} else if(C <= A && D >= B) {
			System.out.println(B - A);
		}
	}
}


Measured memory_bytes: 21844
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <bitset>
#include <list>
#include <utility>
#include <cassert>
using namespace std;

const int MAXN = 200000 + 5;
const int MAXM = MAXN;

struct PATH{
    int a, b;
};

struct PATH P[MAXM];
bool REACH[MAXN];

int main()
{

    int N, M;
    scanf("%d%d", &N, &M);
    for (int i = 0; i < M; ++i)
        scanf("%d%d", &P[i].a, &P[i].b);

    fill(&REACH[0], &REACH[N]+1, false);
    for (int i = 0; i < M; ++i) {
        if (P[i].a == 1)
            REACH[ P[i].b ] = true;
    }
    bool reach = false;
    for (int i = 0; i < M && (!reach); ++i) {
        if (!REACH[ P[i].a ])
            continue;
        if (P[i].b == N)
            reach = true;
    }

    if (reach)
        cout <<"POSSIBLE"<<endl;
    else
        cout <<"IMPOSSIBLE"<<endl;

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll x, y;
    cin >> x >> y;

    set<ll> a({1,3,5,7,8,10,12});
    set<ll> b({4,6,9,11});
    set<ll> c({2});

    if (a.find(x) != a.end() && a.find(y) != a.end())
        cout << "Yes" << endl;

    else if (b.find(x) != b.end() && b.find(y) != b.end())
        cout << "Yes" << endl;

    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    for(int i = 1; i <= 3000; i++)
    {
        int x,y;

        std::cin >> x >> y;
    
        if(x==0 && y==0)
        {
            break;
        }
        else if(x < y)
        {
            std::cout << x << " " << y << std::endl;
        }
        else if(x >= y)
        {
            std::cout << y << " " << x << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	ll n,val,val1,h,n1;
	cin>>n;
	if(n%2==0){
		cout<<n/2<<" "<<n<<" "<<n<<endl;

	}
	else{
		f(h,1LL,3501LL){
			f(n1,1LL,3501LL){
				val=n;
				val*=h;
				val*=n1;
				val1=4LL*h*n1;
				val1-=n*(h+n1);
				//val1=3*n*h-n*n;
				if(val1>0&&(val%val1)==0){
					//cout<<val<<" "<<val1<<" "<<n1<<endl;
					//cout<<4LL*h*n1*(val/val1)<<" "<<n*(h*n1+n1*(val/val1)+(val/val1)*h)<<endl;

					cout<<h<<" "<<n1<<" "<<val/val1<<endl;
					return 0;
				}
			}
		}
	}
	
} 


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int mouth = 1;
        int counter = 0;
        while (mouth < b) {
            mouth += a - 1;
            counter++;
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 


void mod_build(int n=101010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}

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

  sort(a.rbegin(),a.rend());
  ll ans=0;
  for(ll i=0; i<n-k+1; i++){
    ans += (a[i]*comb(n-i-1,k-1))%mod;
    ans %= mod;
  }

  sort(a.begin(),a.end());
  ll ansb=0;
  for(ll i=0; i<n-k+1; i++){
    ansb += (a[i]*comb(n-i-1,k-1))%mod;
    ansb %= mod;
  }

  ans = ans-ansb;
  while(ans<mod){ ans += mod;}
  ans %= mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

int main() {
  int n;
  cin>>n;
  rrep(i,9){
    int ja=i*100+i*10+i;
    if(n<=ja){
      cout<<ja<<endl;
      return 0;
    }
  }
}


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

int main()
{
    unsigned long size;
    std::string str;
    std::cin >> str;
    size = str.size()-1;
    for (unsigned long i = 0; i <= size/2; i++) {
        std::swap(str[i], str[size-i]);
    }
    std::cout << str << std::endl;
    return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>
#define max(a, b) ((a)>(b) ? (a) : (b))

int main(void){
  int n, w_max, w[101], v[101];
  long int dp[100001] = {0};
  scanf("%d %d", &n, &w_max);
  for(int i=0; i<n; i++) scanf("%d %d", &w[i], &v[i]);

  for(int i=0; i<n; i++){
    for(int j=w_max; j>=w[i]; j--){
      dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
    }
  }

  printf("%ld\n", dp[w_max]);

  return 0;
}
  


Measured memory_bytes: 896
#include<stdio.h>
#define NIL -1
#define MAX 10000
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n,D[MAX],H[MAX];
void setDepth(int, int);
int setHeight(int);
int getSibling(int);
int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,getSibling(i));
    int deg=0;
    if(T[i].l!=NIL)deg++;
    if(T[i].r!=NIL)deg++;
    printf("degree = %d, depth = %d, height = %d, ",deg,D[i],H[i]);
    if(T[i].p==NIL) printf("root\n");
    else if(T[i].l==NIL && T[i].r==NIL)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}
void setDepth(int u, int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL)h1=setHeight(T[u].l)+1;
  if(T[u].r!=NIL)h2=setHeight(T[u].r)+1;
  if(h1>h2)return H[u]=h1;
  else return H[u]=h2;
}
int getSibling(int u){
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL)return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL)return T[T[u].p].r;
  return NIL;
}

Measured memory_bytes: 624
import bisect

n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))

minA = A[0]
maxA = A[-1]

answer = False
for i in range(m):
    if (B[i] < minA) or (maxA < B[i]):
        answer = False
        break
    else:
        if A[bisect.bisect_left(A, B[i])] == B[i]:
            answer = True
        else:
            answer = False
            break

if answer:
    print(1)
else:
    print(0)


Measured memory_bytes: 36676