akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e5+5;

int n;
struct node {
	int num,pos;
}a[N];

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
bool cmp(node x,node y) {return x.num<y.num;}

signed main()
{
	n=read();
	Rf(i,1,n) {
		a[i].num=read();a[i].pos=i;
	}
	sort(a+1,a+1+n,cmp);
	Rf(i,1,n) {
		write(a[i].pos);putchar(' ');
	}

    return 0;
}


Measured memory_bytes: 4408
//https://atcoder.jp/contests/abc162/tasks/abc162_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
//o(1)
int main() {
  ll N; cin>>N;
#if 0
  auto sum_func = [&](ll d){
    ll f=d;
    ll l=(N/d)*d;
    ll num=N/d;
    return (f+l)*num/2;
  };
  ll ans=sum_func(1)-sum_func(3)-sum_func(5)+sum_func(15);
#else
  auto sumf = [&](ll n){
    return (1+n)*n/2;
  };
  ll ans=sumf(N)-sumf(N/3)*3-sumf(N/5)*5+sumf(N/15)*15;
#endif
  cout<<ans<<endl;
  return 0;
}
int main_() {
  ll N;cin>>N;
  ll ans=0;
  FOR(i,1,N+1){
    if(i%3==0||i%5==0){
    }else{
      ans += i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int N;
    long long C;
    cin >> N >> C;
    long long xi, vi;
    vector<long long> x(N+2, 0);
    vector<long long> v(N+2, 0);
    for(int i=0;i<N;i++){
        cin >> x[i+1] >> v[i+1];
    }
    x[N+1] = C;
    vector<long long> xsumc(N, 0);
    vector<long long> xsumr(N, 0);
    for(int i=0;i<N;i++){
        xsumc[i] = (i==0? 0:xsumc[i-1]) + v[i+1] - (x[i+1] - x[i]);
        xsumr[i] = (i==0? 0:xsumr[i-1]) + v[N-i] - (x[N-i+1] - x[N-i]);
    }
    vector<long long> xsumc2(N, 0);
    vector<long long> xsumr2(N, 0);
    for(int i=0;i<N;i++){
        xsumc2[i] = xsumc[i] - x[i+1];
        xsumr2[i] = xsumr[i] - (C - x[N-i]);
    }
    for(int i=1;i<N;i++){
        xsumc[i] = max(xsumc[i-1], xsumc[i]);
        xsumr[i] = max(xsumr[i-1], xsumr[i]);
        xsumc2[i] = max(xsumc2[i-1], xsumc2[i]);
        xsumr2[i] = max(xsumr2[i-1], xsumr2[i]);
    }
    auto res = max(xsumc[N-1], xsumr[N-1]);
    for(int i=0;i<N-1;i++){
        res = max(res, xsumc[i] + xsumr2[N-i-2]);
        res = max(res, xsumc2[i] + xsumr[N-i-2]);
    }
    res = max(res, (ll)0);

    cout << res <<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
// ll nCr[2010][2010];
// void binomialCoeff() 
// { 
//     int i, j; 
//     for (i = 0; i <= 2000; i++) 
//     { 
//         for (j = 0; j <= min(i, 2000); j++) 
//         { 
//             if (j == 0 || j == i) 
//                 nCr[i][j] = 1; 
//             else
//                 nCr[i][j] = (nCr[i - 1][j - 1]%mod + nCr[i - 1][j]%mod)%mod; 
//         }
//     } 
//     return;
// }
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll modinv(ll a,ll p){// GIVEN THAT p is prime 
    return power(a,p-2,p);
}
 
int modInverse(int a, int m) // just a and m need to be coprime, m need not be prime
{ 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        int q = a / m; 
        int t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) 
       x += m0; 
    return x; 
} 
vll input(ll n,ll type=0){
    if(type==0){
        vll ret(n);
        f(i,0,n){
            cin>>ret[i];
        }
        return ret;
    }
    else if(type==1){
        vll ret(n+1);
        ret[0]  = -1;
        f(i,0,n){
            cin>>ret[i+1];
        }
        return ret;
    }
}
template< class U = string>
void print(U s){
    cout<<s<<endl;
}
ll dp[MAXN];
int solve(){
    // ll k,l,n,m;
    // 
    ll n;
    cin>>n;
    vector<ll> a(n);
    a = input(n);
    fo(i,0,n+2){
        dp[i] = INF;
    }
    dp[1] = 0;
    fo(i,1,n-1){
        dp[i+1] = min(dp[i+1], dp[i]+abs(a[i]-a[i-1]));
        if(i-2>=0)
        dp[i+1] = min(dp[i+1], dp[i-1]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // tests(){solve();}
    solve();
    return 0;
}/*int x = 5328; // 00000000000000000001010011010000
cout << __builtin_clz(x) << "\n"; // 19
cout << __builtin_ctz(x) << "\n"; // 4
cout << __builtin_popcount(x) << "\n"; // 5
cout << __builtin_parity(x) << "\n"; // 1
*/

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

using namespace std;

int N, M;
vector<int> vec;

bool solve(const int n, const int m)
{
  if(m == 0)    
    return true;
  if( n >= N)
    return false;
    
  int rval = solve(n+1, m) || solve(n+1, m - vec[n]);
  
  return rval;
    
}


int main()
{
    cin >> N;
 
    for(int i = 0; i < N; ++i)
    {
      int tmp; cin >> tmp;
      vec.push_back(tmp);
    }
    
    cin >> M;
    for(int i = 0; i < M; ++i)
    {
        int ques; cin >> ques;
        if(solve(0, ques))
          cout << "yes" << endl;
        else   
          cout << "no" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3168
p=lambda x,y,z:print(x,y,z);L=int(input());S=bin(L);N=len(S)-2;print(N,N+N+S.count("1")-3)
for i in range(1,N):
 p(i,-~i,0);p(i,-~i,1<<~-i)
 if int(S[-i]):L^=1<<~-i;p(i,N,L)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int n,k,s;

int main()
{
    while(cin >> n >> k >> s) {
        if(n == 0 || k == 0 || s == 0) break;
        
        int ans = 0;
        rep(i,1<<n) {
            bitset<20> bit(i);
            if(bit.count() == k) {
                int sum = 0;
                rep(i,20) {
                    if(bit[i]) {
                        sum += i+1;
                    } 
                }

                if(sum == s) {
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    string X;
    cin>>X;
    
    
    
    
    
    
    
    //計算
    int ans=X.size(),s=0,t=0;
    for(int i=0;i<X.size();i++){
        if(X.at(i)=='S'){
            s++;
        }else if(s>0){
            s--;
            ans-=2;
        }
    }
    
    //出力
    cout <<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
const int MAX_N=200000;
ll n,dat[2*MAX_N-1];
vector<ll> lazy;
void init(int n_){
    n=1;
    while(n<n_) n*=2;
    fill(dat,dat+2*n-1,0);
    lazy.resize(2*n-1,0);
}
void eval(int k,int l,int r) {
    if(lazy[k]!=0){
        dat[k]+=lazy[k];
        if(r-l>1){
            lazy[2*k+1]+=lazy[k]/2;
            lazy[2*k+2]+=lazy[k]/2;
        }
        lazy[k]=0;
    }
}
void add(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
        lazy[k]+=(r-l)*x;
        eval(k,l,r);
    }
    else{
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        dat[k]=dat[2*k+1]+dat[2*k+2];
    }
}
ll sum(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return 0;
    eval(k,l,r);
    if(a<=l&&r<=b) return dat[k];
    ll vl=sum(a,b,2*k+1,l,(l+r)/2);
    ll vr=sum(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
}
int main(){
    int N,Q;
    cin>>N>>Q;
    init(N);
    rep(i,Q){
        int c,s,t,x;
        cin>>c;
        if(c==0) cin>>s>>t>>x,add(s-1,t,x,0,0,n);
        else cin>>s>>t,cout<<sum(s-1,t,0,0,n)<<"\n";
    }
}



Measured memory_bytes: 7056
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val ans = if (N == 1 && M == 1)
            1
        else if (N == 1)
            M - 2
        else if (M == 1)
            N - 2
        else if (N == 2 || M == 2)
            0
        else
            (N - 2).toLong() * (M - 2).toLong()

        pw.println(ans)
    }
}


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

using namespace std;

const long long MOD = 1e9 + 7; // have to be a prime

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

long long nCr(int n, int r) {
    long long ret = 1;
    r = max(r , n - r);
    for (int i = 1; i <= n - r; ++i) {
        ret = mul(ret , r + i);
        ret = mul(ret , mod_inv(i));
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    int n , k;
    cin >> n >> k;

    int blue = k , red = n - k;

    for (int i = 1 ;i <= k ;i++) {
        if (i > red + 1) {
            cout << 0 << '\n';
            continue;
        }

        int boxes = i;
        int balls = blue;
        int ways = nCr(balls - 1 , boxes - 1);

        boxes = i + 1;
        balls = red - i + 1;

        if (balls)
            ways = mul(ways , nCr(balls - 1 + boxes , boxes - 1));

        cout << ways << '\n';
    }
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

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

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let mut time = parse_line_vec::<usize>();
    time.sort();

    println(time[0] + time[1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 
 
int n,m,ans=0,ma=-1,mb=-1;
long long k,a[200050],b[200050];

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<m;i++)
		scanf("%d",b+i);
	for(int i=0;i<n;i++)
		if(k >= a[i])
		{
			ma++;
			k -= a[i];
			ans++;
		} 
		else
			break;
	for(int i=0;i<m;i++)
		if(k >= b[i])
		{
			mb++;
			k -= b[i];
			ans++;
		}
		else
			break;
	while(ma >= 0)
	{
		k += a[ma];
		ma--;
		for(int i=mb+1;i<m;i++)
			if(k >= b[i])
			{
				mb++;
				k -= b[i];
			}
			else
				break;
		ans=max(ans,ma+mb+2);
	} 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6924
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    large a, bnum, bfrac;
    char period;
    cin >> a >> bnum >> period >> bfrac;

    auto x = a * bnum;
    x += (a * bfrac / 100);

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3636
x = int(input())
if 400 <= x <= 599:
  print('8')
elif 600 <= x <= 799:
  print('7')
elif 800 <= x <= 999:
  print('6')
elif 1000 <= x <= 1199:
  print('5')
elif 1200 <= x <= 1399:
  print('4')
elif 1400 <= x <= 1599:
  print('3')
elif 1600 <= x <= 1799:
  print('2')
else : 
  print('1')

Measured memory_bytes: 9184
n,m=gets.split.map(&:to_i)
l_max=0
r_min=n+1
m.times{
  l,r=gets.split.map(&:to_i)
  l_max=l if l_max<l
  r_min=r if r<r_min
}

puts [r_min-l_max+1,0].max

Measured memory_bytes: 3836
S = gets.chomp.split("")
T = gets.chomp.split("")
h = Hash.new
ans = true
S.zip(T).each do |s, t|
    if h[s].nil?
        h[s] = t
    elsif h[s] == t
        next
    else
        ans = false
        break
    end
end

def return_to_self(h, k, v, count = 0)
    if count > 27
        false
    elsif h[v].nil? || k == h[v]
        true
    else
        return_to_self(h, k, h[v], count + 1)
    end
end

def only_me(h, v)
    h.select{|key, val| val == v}.size == 1
end

h.each do |k, v|
    ans &&= return_to_self(h, k, v) && only_me(h, v)
end
puts ans ? "Yes" : "No"

Measured memory_bytes: 33148
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;


int main(){
	int n,cnt=0;
	while(cin>>n,n){
		cnt=0;
		for(int i=2;i<=n;i++){
			for(int j=1;j+i-1<=n;j++){
				int sum=0;
				for(int k=0;k<i;k++){
					sum+=(j+k);
				}
				if(sum==n){
					cnt++;
					break;
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

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

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1,0);
    repA(i,1,k)
    {
        int d;
        cin>>d;
        rep(i,d)
        {
            int val;
            cin>>val;
            a[val]=1;
        }
    }
    int ans=0;
    repA(i,1,n)
    {
        if(a[i]==0) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    ll p=1,q=1;
    ll m;
    rep(i,n){
        ll t,a; cin>>t>>a;
        m=max((p+t-1)/t,(q+a-1)/a);
        p=t*m; q=a*m;
    }
    cout<<p+q<<endl;
}

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

class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var row = input[0];
		var column = input[1];

		var matrix = new int[row, column];
		for (var h = 0; h < row; h++)
		{
			var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			for (var i = 0; i < a.Length; i++)
			{
				matrix[h, i] = a[i];
			}
		}

		var matrix2 = new List<int>();

		for (var i = 0; i < column; i++)
		{
			var a = int.Parse(Console.ReadLine());
			matrix2.Add(a);
		}

		var ans = new int[row];
		for (var r = 0; r < row; r++)
		{
			for (var c = 0; c < column; c++)
			{
				ans[r] += matrix[r, c] * matrix2[c];
			}
		}

		foreach (var a in ans)
		{
			System.Console.WriteLine(a);
		}
	}
}


Measured memory_bytes: 18464
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t, sum;
	
	while(cin >> n, n){
		sum = 0;
		REP(i, n*(n-1)/2){
			cin >> t;
			sum += t;
		}
		cout << sum / (n - 1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
n = input()

def f(s):
    if int(s) > int(n):
        return 0
    if all(['3' in s,'5' in s,'7' in s]):
        ans.append(1)
    for t in '3','5','7':
        f(s+t)

ans=[]
f('0')
print(sum(ans))


Measured memory_bytes: 53724
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int main(){
	int N,ans=0;
	vector<int>A;
	cin>>N;
	rep(i,N){
		int t;
		cin>>t;
		A.push_back(t);
	}
	ans=A.size();
	sort(A.begin(),A.end());
//	A.erase(unique(A.begin(),A.end()),A.end());
//	int ans2=A.size();
	//ans2-=(ans-ans2)
	int c=0;
	REP(i,1,N+1){
		if(A[i]==A[i-1])
			c++;
		else{
			if(c==0)continue;
			if(c%2==1)
				ans-=c+1;
			else
				ans-=(c);
			c=0;
		}
	}
 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

// edges
template<typename T>
struct edge {
  int u, v; T cost;
  edge(int u, int v, T cost) : u(u), v(v), cost(cost) {}
};
template<typename T>
using Edges = vector<edge<T>>;

// union-find
struct UnionFind {
  vector<int> data;
  UnionFind(int sz) {data.assign(sz, -1);}
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int find(int k) {
    if (data[k] < 0) return k;
    return data[k] = find(data[k]);
  }
  int size(int k) {
    return -data[find(k)];
  }
};

// main algorithm
template<typename T>
T kruskal(Edges<T> &edges, int V) {
  sort(begin(edges), end(edges), [](const edge<T> &a, const edge< T > &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for (auto &e : edges) {
    if (tree.unite(e.u, e.v)) ret += e.cost;
  }
  return ret;
}

int main() {
  ll n; cin >> n;
  vector<P> x, y;
  rep(i, n) {
    int a, b; cin >> a >> b;
    x.push_back(P(a, i));
    y.push_back(P(b, i));
  }

  sort(all(x));
  sort(all(y));

  Edges<int> E;
  rep(i, n-1) E.push_back(edge<int>(x[i].second, x[i+1].second, x[i+1].first - x[i].first));
  rep(i, n-1) E.push_back(edge<int>(y[i].second, y[i+1].second, y[i+1].first - y[i].first));

  cout << kruskal(E, n) << endl;
  return 0;
}


Measured memory_bytes: 7144
object Main extends App {
  import scala.io.StdIn.readLine;
  val comp:(Int, Int) => String = (a:Int, b:Int) =>{
    (a > b) match{
      case true => "a > b"
      case _ => (a == b) match{
        case true => "a == b"
        case _ => "a < b"
      }
    }
  }
  val in = readLine.split(" ").map(_.toInt)
  println(comp(in(0), in(1)))
}

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

//#define int long long
#define X first
#define Y second
#define mp make_pair
#define pr pair
#define vc vector
#define sz(v) (int) v.size()

using namespace std;

typedef long long ll;
typedef long double ld;

signed main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vc<int> a(n);
    for (auto &x : a) cin >> x;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            sum += a[i] * a[j];
        }
    }
    cout << sum << "\n";

    return 0;
}


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

int n;
char fld[1010][1010];
int dp[2][1010];
void solve(){
    for(int i=0;i<n;i++)scanf("%s",fld[i]);
    fill_n(*dp,2*1010,0);
    int ma=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(fld[i][j]=='*')dp[(i+1)&1][j+1]=0;
            else{
                dp[(i+1)&1][j+1]=min(dp[i&1][j],min(dp[(i+1)&1][j],dp[i&1][j+1]))+1;
                ma=max(ma,dp[(i+1)&1][j+1]);
            }
        }
    }

    printf("%d\n",ma);
}
int main(){
    while(scanf("%d",&n),n)solve();
}

Measured memory_bytes: 2192
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n ;
    cin >> n ;
    int a[n];
    rep(i , n) cin >> a[i];
    int cur = 1 , g = 0;
    for(int i = 1 ; i < n ; ++i){
        if(a[i] == a[i-1]) continue ;
        int ng = (a[i] > a[i-1] ? 1 : -1);
        if(g == 0) g = ng ;
        if(ng == g) continue ;
        else cur++ , g = 0 ;
    }
    cout << cur ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 4404
N,M=map(int, raw_input().split())
A=[ 1 for i in range(M+1) ] 

for i in range(N):
	X=map(int, raw_input().split())
	for j in range(1,M+1):
		if j not in X[1:]:
			A[j]&=0

print sum(A[1:])

Measured memory_bytes: 29548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    
    cout <<"ABC"<< N << endl;


    return 0;
    

}

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

using namespace std;

typedef long ll;


bool ps[9][9];

ll n, m;

// #define DB

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
#ifdef DB
		cerr << i << "," << n << "=" << (n / i) << endl;
#endif // DB
        ret.push_back(i);
    }
  }
  // sort(begin(ret), end(ret));
  return (ret);
}

int keta(ll n)
{
	int ans = 1;

	while (n >= 10) {
		n /= 10;
		ans++;
	}

	return ans;
}


int main(int, char**)
{
	cin >> n;

#ifdef DB
		cerr << n << endl;
#endif // DB
	int ans = keta(n);

	for (ll i = 1; i * i <= n; ++i) {
#ifdef DB
		cerr << i << ":" << (n/i) << keta(n/i) << endl;
#endif // DB

		if (n%i ==0)
			ans = min(ans, keta(n/i));
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

for i in range(100):
    for j in range(100):
        if i == 0 and j == 0:
            continue
        if N == i * 4 + j * 7:
            print("Yes")
            exit()

print("No")

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

int main(){
	int n, x;
	cin >>n >>x;
	vector<int> m(n);
	for(auto& k:m){
		cin >> k;
		x -= k;
	}
	sort(m.begin(),m.end());
	int a = m.at(0);
	int c = x/a;
	cout << n+c << endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/

int main() {
  ll h,n;
  cin >> h >> n;
  vector<pll> mag(n); 

  vl dp(h+1,1e15);
  dp[0] = 0;
  REP(i,n){
    ll ai,bi;
    cin >> ai >> bi;
    REP(j,h+1){
      ll next = min(j+ai,h);
      dp[next] = min(dp[next],dp[j]+bi);
    }
  }
  
  //cout << fixed << setprecision(10);
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 384
AC = 0
WA = 0
TLE = 0
RE = 0

n = int(input())

for i in range(n):
    s = input()
    
    if s == 'AC':
        AC += 1
    elif s == 'WA':
        WA += 1
    elif s == 'TLE':
        TLE += 1
    else:
        RE += 1


print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))
    



Measured memory_bytes: 9192
#include <iostream>
using namespace std ;
int main()
{
  int num ;
  
  cin >> num ;
  
  int num1 , num2 , num3 ;
  
  num1 = num/100 ;
  num2 = (num - num1*100)/10  ;
  num3 = num - num1*100 -num2*10  ;
  
  cout <<num1+num2+num3 <<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const ll maxn = 3005;
int sg[maxn],a[maxn],n;
vector<int> edge[maxn];

void dfs(int u){
	sg[u] = 0;
	for(auto v : edge[u]){
		if(sg[v] == -1){
			dfs(v);
			if(a[u] > a[v] && sg[v] == 0){
				sg[u] = 1;
				break;
			}
		}
	}
}

int main(){
	n = rd();
	Rep(i,1,n) a[i] = rd();
	rep(i,1,n){
		int a = rd(),b = rd();
		edge[a] . push_back(b);
		edge[b] . push_back(a);
	}
    Rep(i,1,n){
		memset(sg,-1,sizeof sg);
		dfs(i);
		if(sg[i])write(i),pc(' ');
    }
	return 0;
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    char X,Y; cin >> X >> Y;
    if(X-'a'>Y-'a') cout << ">" << endl;
    else if(X-'a'<Y-'a') cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}

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

int main(){
  long long n, a, sum = 0, minvalue = 1000000, maxvalue = -1000000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if(a < minvalue){minvalue = a;}
    if(a > maxvalue){maxvalue = a;}
    sum += a;
  }
  printf("%lld %lld %lld\n",minvalue, maxvalue, sum);
  return 0;
}

Measured memory_bytes: 3224
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
$h = explode(" ",trim(fgets(STDIN)));

$dp[0]=0;
for($i=1;$i<(int)$N;++$i) {
  $dp[$i]=PHP_INT_MAX;
  $limit = min($i,(int)$K);
  for($j=1;$j<=$limit;++$j) {
    $dp[$i]=min($dp[$i],$dp[$i-$j]+abs((int)$h[$i]-(int)$h[$i-$j]));
  }
}
printf("%d\n",$dp[$N-1]);


Measured memory_bytes: 18932
#include<stdio.h>

int N;
int tempL;

int main(void){

    int temp = 0;
    int sum = 0;

    scanf("%d",&N);
    for(int i=0; i<N; i++){
        scanf("%d",&tempL);
        temp = temp>=tempL ? temp: tempL;
        sum += tempL;
    }

    sum - temp > temp ? printf("Yes\n"): printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
 
using namespace std;
 
struct dice{
    int q1,q2,q3,q4,q5,q6;
};
 
void mN(dice &d){
    int tmp=d.q1;
    d.q1=d.q2;
    d.q2=d.q6;
    d.q6=d.q5;
    d.q5=tmp;
}
 
void mE(dice &d){
    int tmp=d.q1;
    d.q1=d.q4;
    d.q4=d.q6;
    d.q6=d.q3;
    d.q3=tmp;
}
 
void spin(dice &d){
    int tmp=d.q2;
    d.q2=d.q3;
    d.q3=d.q5;
    d.q5=d.q4;
    d.q4=tmp;
}
 
bool isSame(dice y, dice z){
    bool flag = false;
 
    for(int i=0; i<4; ++i){
        for(int j=0; j<4; ++j){
            if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
                flag = true;
                break;
            }
            spin(y);    
        }
        if(flag) break;
        mN(y);
    }
     
    mE(y);
     
    for(int i=0; i<4; ++i){
        for(int j=0; j<4; ++j){      
            if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
                flag = true;
                break;
            }
            spin(y);    
        }
        if(flag) break;
        mN(y);
    }   
             
    return flag;
}
 
int main(){
    dice a[100];
    int n;
    bool ans=false;
     
    scanf(" %d", &n);
     
    for(int i=0; i<n; ++i)
        scanf(" %d %d %d %d %d %d", &a[i].q1, &a[i].q2, &a[i].q3, &a[i].q4, &a[i].q5, &a[i].q6);
         
    for(int i=0; i<n-1; ++i){
        for(int j=i+1; j<n; ++j){
            ans=isSame(a[i], a[j]);
            if(ans) break;
        }
        if(ans) break;
    }
     
    if(ans) printf("No\n");
    else printf("Yes\n");
         
    return 0;
}


Measured memory_bytes: 3168
#include<stdio.h>
#include<string.h>

typedef struct pp {
	int time;
	char name[100];
} P;

P Q[100001];
int head, tail;


void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % 100001;
}

P dequeue() {
	P x;
	x = Q[head];
	head = (head + 1) % 100001;
	return x;
}

int min(int a, int b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
}

int main(void) {
	
	int i, n, q;
	int runtime = 0;
	P u;
	int mintime;
	
	scanf("%d%d", &n, &q);

	for (i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}

	head = 1; tail = n + 1;

	while (head != tail) {
		u = dequeue();
		mintime = min(u.time, q);
		u.time -= mintime;
		runtime += mintime;
		
		if (u.time > 0) {
			enqueue(u);
		}
		else {
			printf("%s %d\n", u.name, runtime);
		}


	}
	return 0;
}


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

for i in range(3, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    else:
        x = i
        while x != 0:
            if x % 10 == 3:
                print(" {}".format(i), end="")
                break
            else:
                x = x // 10
print()



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

int main(){
    int N, M, A[100000];
    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]--;
    }

    int64_t no_skip_cost = 0;
    int64_t imos[200002] = {0};

    for(int i=0; i<N-1; i++){
        int s = A[i], t = A[i+1];
        if(s > t) t += M;
        int d = t-s;
        no_skip_cost += d;
        imos[s+2] += 1;
        imos[t+1] += -d;
        imos[t+2] += d-1;
    }
    for(int t=0; t<2; t++) for(int i=1; i<2*M; i++) imos[i] += imos[i-1];

    int64_t save_cost = 0;
    for(int i=0; i<M; i++) save_cost = max(save_cost, imos[i] + imos[M+i]);
    int64_t ans = no_skip_cost - save_cost;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  int ans = 0;
  rep(i,1,n+1){
    if(i<10) ans++;
    else if(100<=i && i<1000) ans++;
    else if(10000<=i && i<100000) ans++;
    else if(1000000<=i && i<10000000) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  for (int i = 0; i < T; ++i) cin >> a[i];
  int mx = *max_element(a.begin(), a.end()),
      sum = accumulate(a.begin(), a.end(), 0);
  cout << max(0, mx * 2 - 1 - sum) << endl;
  return 0;
}

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

#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[(MAX/2)+2], R[(MAX/2)+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0; i < n1; i++)
    L[i] = A[left + i];
  for(i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k = left; k < right; k++){
    if(L[i].value <= R[j].value)
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;

  x = A[r];
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }

  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p < r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d",&n);
  if(n < 1 || n > 100000)
    exit(1);

  for(i = 0; i < n; i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for(i = 0; i < n; i++){
    if(A[i].suit != B[i].suit)
      stable = 0;
  }

  if(stable == 1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for(i = 0; i < n; i++)
    printf("%c %d\n",B[i].suit,B[i].value);

  return 0;
}


Measured memory_bytes: 4004
let inf = 10101010101010
let () =
  Scanf.scanf "%d %d" @@ fun d g ->
  let pc = Array.init d (fun i -> Scanf.scanf " %d %d" (fun x y -> i, x, y))
    |> Array.to_list |> List.rev in

  Array.init (1 lsl d) (fun b ->
    let s', n' =
      List.fold_left (fun (s, n) (i, p, c) ->
        if b land (1 lsl i) <> 0 then begin
          (s + p * 100 * (i+1) + c, n + p)
        end else (s, n)) (0, 0) pc
    in
    let s, n =
      List.fold_left (fun (s, n) (i, p, c) ->
      if b land (1 lsl i) <> 0 then (s, n) else begin
        let u = 100 * (i+1) in
        let m = (g - s + u - 1) / u |> min (p-1) |> max 0 in
        (s + m * u, n + m)
      end) (s', n') pc in
    if s >= g then n else inf
  ) |> Array.fold_left min inf |> Printf.printf "%d\n"

Measured memory_bytes: 1024
import math
N, M = map(int, input().split())
sqrtM = round(math.sqrt(M))+1

if N < sqrtM:
  for i in range(N,sqrtM+1):
    if M % i == 0:
      print(M//i)
      exit()
  for i in range(N-1,0,-1):
    if M % i == 0:
      print(i)
      exit()
else:
  for i in range(M//N,0,-1):
    if M % i == 0:
      print(i)
      exit()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt(); //学生数
		int M = sc.nextInt(); //チェックポイント数
		
		int[] a = new int[N]; //学生N人のx座標
		int[] b = new int[N]; //学生N人のy座標
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		int[] c = new int[M];
		int[] d = new int[M];
		
		for(int i = 0; i < M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		
		
		for(int i = 0; i < N; i++) {
			int min = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			int near_cp = 0;
			
			for(int j = 0; j < M; j++) {
				int dist = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(dist < min) {
					min = dist;				
					near_cp = j;				
				}
			}
			System.out.println(near_cp + 1);
		}
	}
}



Measured memory_bytes: 36184
#include <stdio.h>

void a()
{


}

int main()
{
  int n=0, max=0, i;
  
  for (i=0; i<3; i++)
  {
    if (getchar() == 'R')
      n++;
    else
    {
      if (n > max)
        max = n;
      n = 0;
    }
  }
  
  printf("%d", (n > max) ? n : max);
  return 0;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int>a(N-1);
    vector<int>b(N-1);
    vector<int>p(Q);
    vector<int>x(Q);
    for (int i = 0; i < N - 1; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < Q; ++i) {
        cin >> p[i] >> x[i];
    }
    vector<int>ans(N+1, 0);
    vector<int>plus(N+1, 0);
    for (int i = 0; i < Q; ++i) {
        plus[p[i]] += x[i];
    }
    vector<vector<int>> graph(N+1, vector<int>());
    for (int i = 0; i < N - 1; ++i) {
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }
    queue<int> que;
    vector<int>flag(N+1, 0);
    que.push(1);
    flag[1] = 1;
    ans[1] = plus[1];
    while (! que.empty()){
        int t = que.front();
        que.pop();
        for (int s : graph[t]){
            if(flag[s] == 0){
                flag[s] = 1;
                que.push(s);
                ans[s] = ans[t] + plus[s];
            }
        }
    }

    for (int i = 1; i <= N; ++i) {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 20212
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
namespace Fast_Read {
	inline void read(int &res) {
		res = 0;int tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
	inline void read(long long &res) {
		res = 0;long long tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
}
using namespace Fast_Read;
const int maxn = 1e5+10;
int f[maxn],cost[maxn],val[maxn];
int H,n,ans = 1e9+7;
int main() {
	read(H);read(n);
	for (register int i = 1;i <= n;++i)read(cost[i]),read(val[i]);
	for (register int i = 0;i < H;++i)f[i] = 1e9+7;
	for(register int i = 1;i <= n;++i)
		for(register int j = H-cost[i];j >= 0;--j)
			f[j] = min(f[j],f[j+cost[i]]+val[i]);
	for(register int i = 1;i <= n;++i)
		for(register int j = 1;j <= cost[i];++j)
			ans = min(ans,f[j]+val[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = N = int(input())
S = [input() for i in range(N)]

ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(N):
  ans[S[i]] += 1
  
print('AC x ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x ' + str(ans['TLE']))
print('RE x ' + str(ans['RE']))

Measured memory_bytes: 16296
n = int(input())
d = [0 for _ in range(100)]
for i in range(1, n+1):
    s = str(i)
    d[int(s[0])*10+int(s[-1])] += 1
result = 0
for i in range(1, 10):
    for j in range(1, 10):
        result += d[i*10+j]*d[j*10+i]
print(result)

Measured memory_bytes: 3060