akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N + 2);
  rep (i, N) cin >> A[i + 1];
  long original = 0;
  rep (i, N+1) original += abs(A[i+1] - A[i]);
  rep (i, N) {
    long foo = abs(A[i] - A[i+1]) + abs(A[i+1] - A[i+2]);
    long bar = abs(A[i] - A[i+2]);
    cout << original - foo + bar << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

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

	vector<int> vec2;
	vec2 = vec;
	sort(vec2.begin(), vec2.end());
	for (int i = 0; i < N; ++i) {
		if (vec[i] < vec2[N / 2] ) {
			cout << vec2[N / 2] << endl;
		}
		else {
			cout << vec2[N / 2 - 1] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
//#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int MAX = 2e5 + 10;
using namespace std;
ll a[MAX];
void solve() {
    ll n,sum=0,ans=0;
    cin>>n;
    for (int i = 0; i < n; ++i)
        cin>>a[i],sum+=a[i]%mod;
    for(int i=0;i<n;i++)
        ans=(((sum-a[i])%mod*a[i]%mod)+ans)%mod;
    cout<<(ans%2==0?ans/2:(ans+mod)/2)<<endl;
}

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

Measured memory_bytes: 5180
N = int(input())
High = list(map(int, input().split()))

DP = [0]*N
DP[1] = abs(High[0]-High[1])
for i in range(2, N):
    DP[i] = min(DP[i-2] + abs(High[i] - High[i - 2]), DP[i-1] + abs(High[i] - High[i - 1]))

print(DP[N-1])

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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w, m;
    cin >> h >> w >> m;
    
    vector<pair<int, int>> p(m);
    for(pair<int, int>& x : p)
        cin >> x.first >> x.second;
    
    map<int, vector<int>> x, y;
    for(auto point : p)
    {
        x[point.first].push_back(point.second);
        y[point.second].push_back(point.first);
    }
    
    int ans = 0;
    for(auto point : p)
    {
        ans = max(ans, (int)x[point.first].size() + (int)y[point.second].size() - 1);
    }

    int mx_x = 0;
    for(auto e : x)
    {
        mx_x = max(mx_x, (int)(e.second.size()));
    }

    map<int, int> ys;
    int cnt = 0;

    for(auto e : x)
    {
        if(e.second.size() == mx_x)
        {
            for(auto y : e.second)
                ys[y]++;
            cnt++;
        }
    }

    for(int i = 1; i <= max(w, h); i++)
    {
        if(ys[i] != cnt)
        {
            ans = max(ans, (int)y[i].size() + mx_x);
        }
    }

    cout << ans << '\n';

    return 0;
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int H, W; cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  vector<vector<int>> B(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> B.at(i).at(j);
    }
  }

  int lim = 161*81+10;
  vector<vector<vector<bool>>>
    cand(H, vector<vector<bool>>(W, vector<bool>(lim)));
  
  int xxx = abs(A.at(0).at(0) - B.at(0).at(0));
  cand.at(0).at(0).at(xxx) = true;
  for (int z = 0; z < W + H - 1; z++) {
    for (int x = 0; x < W; x++) {
      int y = z - x;
      if (y < 0) continue;
      if (y >= H) continue;
      for (int t = 0; t < lim; t++) {
	if (!cand.at(y).at(x).at(t)) continue;
	int y1 = y + 1;
	if (y1 < H) {
	  int w = abs(A.at(y1).at(x) - B.at(y1).at(x));
	  cand.at(y1).at(x).at(t + w) = true;
	  cand.at(y1).at(x).at(abs(t - w)) = true;
	}
	int x1 = x + 1;
	if (x1 < W) {
	  int w = abs(A.at(y).at(x1) - B.at(y).at(x1));
	  cand.at(y).at(x1).at(t + w) = true;
	  cand.at(y).at(x1).at(abs(t - w)) = true;
	}
      }
    }
  }
  for (int t = 0; t < lim; t++) {
    if (cand.at(H-1).at(W-1).at(t)) {
      cout << t << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 13056
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    ll ans = HIGHINF;
    for (ll i = 1; i < w; i++) {
        ll s1 = i * h, s2 = (w - i) * (h / 2), s3 = (w - i) * ((h + 1) / 2);
        chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        if (i < w - 1) {
            s2 = (w - i) / 2 * h, s3 = (w - i + 1) / 2 * h;
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
    }

    swap(h, w);
    for (ll i = 1; i < w; i++) {
        ll s1 = i * h, s2 = (w - i) * (h / 2), s3 = (w - i) * ((h + 1) / 2);
        chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        if (i < w - 1) {
            s2 = (w - i) / 2 * h, s3 = (w - i + 1) / 2 * h;
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


struct Edge {
    ll to;
    ll weight;
    Edge(ll t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;


typedef vector<vector<int> > Matrix;

const int INF = 100000000;
Matrix d;

void warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
            for (int k = 0; k < n; k++)  // 終端
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

ll modnum = 1e9+7;

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

    cout << (n+1)/2 << endl;

    return 0;
}



Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,m,now,ans
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    call merge_sort(a,1,n)
    ans=0
    do i=1,n-2
        do j=i+1,n-1
            now = a(i)+a(j)
            l=j+1
            r=n
            if (a(l) >= now) cycle
            if (a(r) < now)then
                ans=ans+r-j
                cycle
            end if

            do while (r-l > 1)
                m = (l+r)/2
                if (a(m) < now) then
                    l=m
                else
                    r=m
                end if
            end do
            ans=ans+l-j
        end do
    end do
    print'(i0)', ans
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	long pow(long a,long n){
		long ret=1;
		for(;n>0;n>>=1,a=a*a%m)if(n%2==1)ret=ret*a%m;
		return ret;
	}
	
	final long m=(long)(1e9+7);
	
	int MAX=(int)(3e5);
	long[] fac=new long[MAX];
	long[] ifac=new long[MAX];
	long[] inv=new long[MAX];
	{
		fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
		for(int i=2;i<MAX;++i){
			fac[i]=fac[i-1]*i%m;
			inv[i]=m-inv[(int)m%i]*(m/i)%m;
			ifac[i]=ifac[i-1]*inv[i]%m;
		}
	}
	
	long comb(int n,int k){
		if(n<k)return 0;
		return fac[n]*ifac[k]%m*ifac[n-k]%m;
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[] A=new long[N];
		for(int i=0;i<N;++i)A[i]=sc.nextLong();
		Arrays.sort(A);
		long ans=0;
		for(int i=0;i<N;++i){
			//int j=i;
			//while(j+1<A.length&&A[i]==A[j+1])++j;
			//int num=j-i+1;
			//ans+=A[i]*(pow(2,num)-1)*pow(2,i)%m;
			ans+=A[i]*comb(i,K-1)%m;//max
			ans%=m;
			//ans-=A[i]*(pow(2,num)-1)*pow(2,N-1-j)%m;
			ans-=A[i]*comb(N-1-i,K-1)%m;//min
			ans%=m;
			//i=j;
		}
		ans=(ans%m+m)%m;
		System.out.println(ans);
	}
	
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}
// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase
	

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

int main() {
    int a[3][3];
    for(int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(a[j][k] == b) {
                    a[j][k] = 0;
                }
            }
        }
    }
    string ans = "No";
    for(int i = 0; i < 3; i++) {
        if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0) {
            ans = "Yes";
        }
    }
    for(int i = 0; i < 3; i++) {
        if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0) {
            ans = "Yes";
        }
    }
    if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0) {
        ans = "Yes";
    } else if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0) {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const fib = n => {
    const memo = [];
    const helper = x => {
        if (x <= 1) return 1;
        if (memo[x] !== undefined) return memo[x];
        memo[x] = helper(x-1) + helper(x-2);
        return memo[x];
    }

    return helper(n);
};

console.log(fib(parseInt(line[0])));



Measured memory_bytes: 15136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

vi to[100100];
vi flag(100100);

int n, m;
int bfs(int u, int count)
{
    if(flag[u]==1) return 0;
    if(count ==n) return 1;

    flag[u]=1;
    int ans = 0;
    for(int v : to[u]){
        ans += bfs(v,count+1);
    }
    flag[u]=-1;
    return ans;
}

int main()
{
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a); 
        flag[i] = -1;       
    }
    ;
    cout << bfs(0,1) <<endl;
}

Measured memory_bytes: 2944
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = b % a;
        if (c == 0)
            System.out.println(a+b);
        else
            System.out.println(b-a);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;

const int maxe = 100005;
vector< vector<int> > adj(maxe+1);
vector<int> dist(maxe+1, 0);
vector<int> indeg(maxe+1, 0);

void dfs(int x){
    // vis[x] == true;
    for(auto y : adj[x]){
        indeg[y]--;
        dist[y] = max(dist[y], dist[x] + 1);
        if(indeg[y] == 0){
            dfs(y);
        }
    }
}

int main() {
    fastio
    int n, m;
    cin>> n >> m;
    
    rng(i,1,n+1){
        adj[0].push_back(i);
        indeg[i]++;
    }
    
    rng(i,0,m){
        int u,v;
        cin>> u >> v;
        adj[u].push_back(v);
        indeg[v]++;
    }
    dfs(0);
    LL res = 0;
    rng(i,1,n+1){
        res = max(res, (LL)dist[i]-1);
    }
    cout<<res<<endl;
    return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,c,d,e,i,j,k,x,y,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>a>>b;
    n=2*b+1;
    cout<<ceil(a*1.0/n)<<endl;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3740
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n, sum_len int
  fmt.Scan(&n)

  // make関数による動的サイズsliceの生成
  L := make([]int, n)

  for i := 0; i < n; i++ {
    fmt.Scan(&L[i])
    sum_len += L[i]
  }

  // 降順にソート
  sort.Sort(sort.Reverse(sort.IntSlice(L)))

  if L[0] < sum_len - L[0] {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
n = gets.to_i

ar = Array.new(100010, 0)

n.times do
    inp = gets.chomp.split
    a = inp[0].to_i
    b = inp[1].to_i
    ar[a] = ar[a] + 1
    ar[b+1] = ar[b+1] - 1
end

100009.times do |i|
    ar[i] = ar[i-1] + ar[i]
end

max = 1
100009.times do |i|
    if(ar[i] >= i-1)
        max = i
    end
end

puts max - 1

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

int dp[100002];

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = INF;
    for (int j = 1; j <= min(i, K); j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]));
    }
  }
  cout << dp[N - 1] << endl;
}

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

  solve();

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 3000 + 7;
const int INF = (int) 1e9;
int n, t;
int a[N];
int b[N];
int ord[N];
int best[N];
int ans = 0;

bool cmp(int i, int j)
{
    return a[i] < a[j];
}

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

    for (int i = 1; i < N; i++)
    {
        best[i] = -INF;
    }
    cin >> n >> t;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        ord[i] = i;
    }
    sort(ord + 1, ord + n + 1, cmp);
    for (int it = 1; it <= n; it++)
    {
        int i = ord[it];
        for (int j = t - 1; j >= 0; j--)
        {
            ans = max(ans, best[j] + b[i]);
            if (j + a[i] < t)
            {
                best[j + a[i]] = max(best[j + a[i]], best[j] + b[i]);
            }
        }
    }
    for (int j = 0; j <= t - 1; j++)
    {
        ans = max(ans, best[j]);
    }
    cout << ans << "\n";

}


Measured memory_bytes: 256
#include<stdio.h>
void juge(int *f,int *g);

void juge(int *f,int *g){
	if(*f>*g){
		printf("a > b\n");
	}
	else if(*f<*g){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	
}
int main(){
	int a,b;
	int *c,*d;
	
	scanf("%d%d",&a,&b);
	c = &a;
	d = &b;
	
	juge(c,d);


return 0;
}


	

Measured memory_bytes: 580
import numpy as np
#N,M=2,5
#AB=np.array([[4,9],[2,4]])
N,M=map(int,input().split())
AB=np.zeros((N,2))
for i in range(N):
    AB[i,0],AB[i,1]=map(int,input().split())
AB = AB[np.argsort(AB[:, 0])]
numd=0
ans=0
for i in range(len(AB)):
    if numd==M:
        break
    else:
        if AB[i][1] < M-numd:
            ans+=AB[i][0]*AB[i][1]
            numd+=AB[i][1]
        else:
            ans+=AB[i][0]*(M-numd)
            numd+=M-numd
print(int(ans))

Measured memory_bytes: 16360
from fractions import gcd
N, M = map(int, input().split(" "))
S = input()
T = input()
G = gcd(N, M)
L = N * M // G
for i in range(G):
  if S[i*N//G] != T[i*M//G]:
    print(-1)
    exit(0)
print(L)



Measured memory_bytes: 5688
//Multiple of 9 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    int ans=0;
    rep(i,0,s.size()){
        ans+=s[i]-'0';
    }
    bool flag = false;
    if(ans%9==0)flag=true;
    cout<<YN(flag)<<nnn;
    return 0;
}

Measured memory_bytes: 3724
S = input()

ans = 0
cnt = 0
flg = 0

for i in range(len(S)-1) :
    if S[i] == "A" :
        cnt += 1
    elif S[i]+S[i+1] == "BC" :
        ans += cnt
        flg = 1
    elif flg :
        flg = 0
    else :
        cnt = 0

print(ans)


Measured memory_bytes: 3500
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 約数列挙
template <typename T>
std::vector<T> divisor(T n) {
	std::vector<T> divisors;
	for(T i = 1; i * i <= n; i++) {
		if(n % i != 0) {
			continue;
		}
		divisors.push_back(i);
		if(i * i != n) {
			divisors.push_back(n / i);
		}
	}
	return divisors;
}

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

	VLL divisors = divisor<ll>(n);
	transform(
		ALL(divisors), divisors.begin(), [=](ll x) { return n / x - 1LL; });
	VLL result;
	copy_if(ALL(divisors), back_inserter(result), [=](ll x) {
		return x > 0 && n / x == n % x;
	});
	cout << accumulate(ALL(result), 0LL) << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int64_t N, L, Q;
    cin >> N;

    vector<int64_t> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    cin >> L >> Q;

    vector<vector<int64_t>> next(21, vector<int64_t>(N));
    for(int i = 0; i < N; ++i){
        next[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
    }
    for(int i = 1; i < 20; ++i){
        for(int j = 0; j < N; ++j){
            next[i][j] = next[i-1][next[i-1][j]];
        }
    }

    for(int t = 0; t < Q; ++t){
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(a == b){
            cout << 0 << endl;
            continue;
        }
        if(a > b) swap(a, b);
        int now = a;
        int ans = 1;
        for(int i = 19; i >= 0; --i){
            if(next[i][now] < b){
                now = next[i][now];
                ans += 1 << i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 19568
N = int(input())
L = list(map(int,input().split()))

ans = 0
while len(L) :
    if not L[0] :
        L.pop(0)
    else :
        ans += 1
        for i in range(len(L)) :
            if L[i] :
                L[i] -= 1
            else :
                break      
print(ans)


Measured memory_bytes: 2940
n,m,p = map(int, input().split())
edge = []
inv_link = [[] for _ in range(n)]
link = [[] for _ in range(n)]

for i in range(m):
    a,b,cost = list(map(int,input().split()))
    edge.append([a-1,b-1,p-cost])
    link[a-1].append(b-1)
    inv_link[b-1].append(a-1)

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return False,cost
    return True,cost

from collections import deque
Q = deque()
Q.append([n-1,0])
visited=[-1]*n
visited[n-1]=0
while Q:
    now,cnt = Q.popleft()
    for nxt in inv_link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=cnt+1
        Q.append([nxt,cnt+1])

new_edge=[]
for a,b,c in edge:
    if visited[a]==-1 or visited[b]==-1:
        continue
    new_edge.append([a,b,c])
ret,cost = bell(new_edge,0,n)
if ret:
    print(max(0,-cost[-1]))
else:
    print(-1)


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

int main() {
  vector<int> cnt(4);
  rep(i, 6) {
    int t;
    cin >> t;
    cnt[t-1]++;
  }
  if (*min_element(cnt.begin(), cnt.end()) == 1 &&
      *max_element(cnt.begin(), cnt.end()) == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long H=gl();
	    long W=gl();
	    long m=H*W;
        //System.out.print(min);
	    if (H==1 || W==1) {
	    	System.out.println(1);
	    	return;
	    }
        if (m%2==0) {
        	System.out.println(m/2);
        }else{
        	System.out.println((m+1)/2);
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35540
n = int(input())
a = input()
b = input()
c = input()
x = 0
for i in range(n):
    if (not (a[i]==b[i] and a[i]==c[i])):
        if (a[i]==b[i] or a[i]==c[i] or b[i]==c[i]):
            x += 1
        else:
            x += 2
print(x)

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
    long int K,A,B,C,a=0;
    cin >> A >> B >> C >> K; 
if(K>=A){
    if(K-A-B>0){
        cout << A-(K-A-B) << "\n";
    }
else{cout << A << "\n";}
}
else{
    cout << K << "\n";
}

  return 0;
}

Measured memory_bytes: 3624
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

namespace atcoder_past_problem
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var a = input.Read;
            var b = input.Read;
            Console.WriteLine($"{b}{a}");
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public int[] ReadIntArray => Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>

using namespace std;

int main() {
	char S[27];
	char prevc;
	int alphabet[26] = { 0 };
	int list[26] = { 0 };
	int len, flag = 0;
	cin >> S;
	for (len = 0; len < 27; len++) {
		if (S[len] == '\0')break;
	}

	if (len < 26) {
		flag = 1;
		for (int i = 0; i < len; i++)
			alphabet[S[i] - 'a'] = 1;
		for (int i = 0; i < 26; i++)
			if (alphabet[i] != 1) {
				S[len] = 'a' + i;
				S[len + 1] = '\0';
				break;
			}
	}
	else {
		for (int i = len-2; i >= 0; i--) {
			if (S[i] - S[i + 1] < 0) {
				prevc = S[i];
				for (int j = len - 1; j > i; j--) {
					if (prevc < S[j]){
						list[S[j] - 'a'] = 1;
					}
					S[j] = 0;
				}
				for (int k = 0; k < 26; k++) {
					if (list[k] == 1) {
						S[i] = 'a' + k;
						S[i + 1] = '\0';
						break;
					}
				}
				flag = 1;
			}
			if (flag)break;
		}
	}
	if (!flag)cout << -1 << endl;
	else cout << S  << endl;
	return 0;
}

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

int main(){
    string s;
    cin >>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3588
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)] )

P = [-1] * (N+1)
P[0] = 1
P[1] = 1
flg=False
MOD = 10**9 + 7
for i in range(2, N+1):
    if i in a:
        continue
    if (i-1 not in a) and (i-2 not in a):
        P[i] = (P[i-1] + P[i-2]) % MOD
    elif i-1 not in a:
        P[i] = P[i-1] % MOD
    elif i-2 not in a:
        P[i] = P[i-2] % MOD
    else:
        flg=True
if flg:
    print(0)
else:
    print(P[N] % MOD)

Measured memory_bytes: 13216
from bisect import bisect_left, bisect_right
# import random


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# N = 10 ** 5
# A = [random.randint(1, 10**9) for _ in range(N)]
# B = [random.randint(1, 10**9) for _ in range(N)]
# C = [random.randint(1, 10**9) for _ in range(N)]

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect_left(A, b)
    c = N-bisect_right(C, b)
    ans += a * c

print(ans)


Measured memory_bytes: 99176
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int h, w; cin >> h>>w;
	vector<string>a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	int count = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (a[j][i] == '.') {
				count++;
			}
			if (count == h) {
				for (int n = 0; n < h; n++) {
					a[n].erase(i, 1);
				}
				i--; w--;
			}
		}
		count = 0;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '.') {
				count++;
			}
			if (count == w) {
				a[i].erase(0, a[i].length());
			}
		}
		count = 0;
	}

	for (int i = 0; i < h; i++) {
		if (a[i].length() != 0) {
			cout << a[i] << endl;
		}
	}
}




Measured memory_bytes: 256
import Data.List as List
import Control.Monad


data State =
  State
    { head :: String -- [tail, ... ,head]
    , tail :: String -- [head, ... ,tail]
    }
  deriving (Show)


main = do
  s <- (\h -> State h "") <$> getLine
  q <- readLn :: IO Int
  qs <- getQueries q
  let res = executeQueries qs s
  putStrLn $ stateToString res


stateToString :: State -> String
stateToString (State { Main.head = h, Main.tail = t }) =
  h ++ (reverse t)

executeQueries :: [Query] -> State -> State
executeQueries queries initialState =
  let 
      help [] state = state
      help (q:qs) state = help qs (executeQuery q state)
  in
    help queries initialState
  

executeQuery :: Query -> State -> State
executeQuery query (State { Main.head = h, Main.tail = t }) =
  case query of
    Reverse ->
       State t h
    PushHead c ->
       State (c:h) t
    PushTail c ->
       State h (c:t)


data Query
  = Reverse
  | PushHead Char
  | PushTail Char
  deriving (Show)

getQueries :: Int -> IO [Query]
getQueries n =
  replicateM n (stringToQuery <$> getLine)
  where
    stringToQuery s =
        let xs = words s
        in
          if List.head xs == "1" then
             Reverse
          else
              let [_, f, c] = xs
              in
                if f == "1" then
                  PushHead (List.head c)
                else
                  PushTail (List.head c)


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

using namespace std;
const int maxn=5e6+5;
char s[maxn],t[maxn];
int nex[maxn];
int len,n,m;
void kmpnex()
{
    int i=1,k=0;
    while(i<=len*m)
    {
        if(k==0 || t[i]==t[k])
            nex[++i]=++k;
        else
            k=nex[k];
        }
}
int main()
{
    scanf("%s",s+1);
    scanf("%s",t+1);
    n=strlen(s+1),m=strlen(t+1);
    len=5000000/m;
    for(int i=1;i<len;i++)
    {
        for(int j=1;j<=m;j++)
        {
            t[j+m*i]=t[j];
        }
    }
    kmpnex();
    int p=m*len/n;
    m*=len;
    int ans=0,pos=0;
    for(int l=1;l<=p;l++)
    {
        for(int i=1;i<=n;i++)
        {
            pos++;
            while(pos&&t[pos]!=s[i])
                pos=nex[pos];
            ans=max(ans,pos);
        }
    }
    m/=len;
    if(ans>=n*(p-1))printf("-1\n");
    else
        printf("%d\n",ans/m);
    return 0;
}


Measured memory_bytes: 27008
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;}
	if(b>c){
		d=b;
		b=c;
		c=d;}
	if(a>b){
		d=a;
		a=b;
		b=d;}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2108
S = input()
n = 3

for i in range(1<<n):
    tmp = int(S[0])
    ans = S[0]
    for j in range(n):
        if i & (1<<j):
            tmp += int(S[j+1])
            ans += "+"
        else:
            tmp -= int(S[j+1])
            ans += "-"
        ans += S[j+1]
    if tmp == 7:
        ans += "=7"
        print(ans)
        exit()

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k;
	cin >>n >>k;
	
	int mx = n -(k -1) -1;
	if(k==1) cout<<0 <<"\n";
	else cout << mx <<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll gcd(ll n,ll m){
  if(m==0) return n;
  return gcd(m,n%m);
}

bool is_prime(ll n){
  if(n==1) return false;
  bool ans=true;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0) ans=false;
  }
  return ans;
}

int main(){
  ll a,b;
  cin >> a >> b;
  ll n=gcd(a,b);
  ll ans=1;
  for(int i=2;i<=1000000;i++){
    if(n%i==0) ans++;
    while(n%i==0) n/=i;
  }
  if(n>1) ans++;
  cout << ans << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++) {
        cin >> D.at(i);
    }

    int M;
    cin >> M;
    vector<int> T(M);
    for (int i = 0; i < M; i++) {
        cin >> T.at(i);
    }

    sort(D.begin(), D.end());
    sort(T.begin(), T.end());

    int j = 0;
    bool flag;
    for (int i = 0; i < M; i++) {
        int m = T.at(i);
        // cout << m << endl;
        flag = false;
        while (j < N) {
            if (m == D.at(j)) {
                flag = true;
                j++;
                break;
            }
            j++;
        }
        if (not flag) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 


const int M = 2e5;
const int MX=4*M;
const int MD=1e9+7;
int main() {
	int a,b;
	cin>>a>>b;
	ll c=1LL*a*b;
	if(a==1 ||  b==1){
		cout<<1;
		return 0;
	}
	if(c&1)
	cout<<(c+1)/2;
	else
	cout<<c/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        int n;
        cin >> n;
        int x[n];
        int c[n];
        for(int i=0; i<n; i++) {
                cin >> x[i];
                c[i]=x[i];
        }
        sort(x,x+n);
        int a=((n/2)-1);
        int b=a+1;
        for(int i=0; i<n; i++) {
                if(c[i]<=x[a]) cout << x[b]<< endl;
                else cout << x[a]<< endl;
        }
}


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

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

int a[200000];
ll h[200000];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        a[i]=1;
    }
    for(int i=0;i<n;i++){
        ll hhh;
        cin>>hhh;
        h[i]=hhh;
    }
    for(int i=0;i<m;i++){
        int aa,bb;
        cin>>aa>>bb;
        aa--;bb--;
        if(h[aa]>h[bb]){
            a[bb]=0;
        }else if(h[aa]<h[bb]){
            a[aa]=0;
        }else{
            a[aa]=a[bb]=0;
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        count+=a[i];
    }
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 4804
#include <iostream>
using namespace std;
 
int mod = 1000000007;
int main() {
	// your code goes here
	long long N,M;
	cin >> M >> N;
	if(N/2 > M){
		cout << M+(N-2*M)/4 << endl;
	}
	else{
		cout << N/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
k = 1
while True:
  if k*(k+1)//2 >= n:
    ans = k
    break
  k += 1
if n == ans*(ans+1)//2:
  i = 1
  while i <= ans:
    print(i)
    i += 1
else:
  i = 1
  l = []
  cnt = 1
  while i < ans:
    if cnt <= (ans-1)*(ans+2)//2 - n:
      print(i)
      cnt += 1
    else:
      print(i+1)
    i += 1
    



Measured memory_bytes: 3316
s=input()
n=len(s)
ans=0

if n==1:
    ans=int(s)
else:
    for b in range(0, 1<<n-1):
        bits=[((b>>i)&1)!=0 for i in range(n-1)]
        t=s[0]
        for i in range(n-1):
            if bits[i]:
                t+='+'
            t+=s[i+1]
        ans+=eval(t)
print(ans)

Measured memory_bytes: 3064
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	long n, m;
	{
		long[] tmp = readln.chomp.split.map!(to!long).array;
		n = tmp[0], m = tmp[1];
		}
	
	long ans;
	
	/*
	long x = n * 2 + m;
	
	long y = x / 4;
	
	if(y > n) ans = y;
	else ans = m / 2;
	
	*/
	
	if(n < m / 2) ans = n + (m - n * 2) / 4;
	else ans = m / 2;
	
	
	ans.writeln;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;

signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3]={0};
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int n, m; cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i,m){
        cin >> l[i] >> r[i];
    }
    int maxL = 1;
    int minR = n;
    rep(i,m){
        maxL = max(maxL, l[i]);
        minR = min(minR, r[i]);
    }
    int ans = minR - maxL;
    ans++;
    ans = max(ans, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
int main()
{
	int a,b,c,flag=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5 && b==7 && c==5) flag=1;
	if(a==5 && b==5 && c==7) flag=1;
	if(a==7 && b==5 && c==5) flag=1;
	if(flag==1)
		printf("YES\n");
		else printf("NO\n");
	return 0;
}




Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int S[] = new int[n];
		int i;
		for(i=0; i<n; i++){
			S[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int T[] = new int[n];
		int j;
		for(j=0; j<q; j++){
			T[j] = sc.nextInt();
		}
		int C=0;
		int left, right, mid;
		for(j=0; j<q; j++){
			left = 0;
			right = n;
			while(left < right){
				mid = (left + right) / 2;
				if(T[j] == S[mid]){
					C++;
					break;
				} else if(T[j] < S[mid]){
					right = mid;
				} else{
					left = mid + 1;
				}
			}
		}
		System.out.println(C);
	}
}

Measured memory_bytes: 74812
import sys 
import heapq

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

A.sort(reverse=True)
q = []
heapq.heappush(q, (-A[0], (A[0], A[0])))

ans = 0
for i in range(1, N):
    v, (left, right) = heapq.heappop(q)
    # print(-v, left, right)
    ans += -v
    heapq.heappush(q, (-1 * min(left, A[i]), (left, A[i])))
    heapq.heappush(q, (-1 * min(right, A[i]), (right, A[i])))

print(ans)

Measured memory_bytes: 122940
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
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; }

int x, n;

int main() {
    cin >> x >> n;
    vector<int> pvec(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> pvec.at(i);
    }

    sort(pvec.begin(), pvec.end());
    pvec.push_back(1000);
    int now = 0;
    int minx = 1e9;
    int ans = 0;
    for(int i = -100; i <= 110; ++i) {
        if(pvec.at(now) == i) {
            now++;
        }else {
            int ch = abs(i-x);
            if(ch < minx) {
                ans = i;
                minx = ch;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
function main(input: string[]): void {
    const h = parseInt(input.shift(), 10);
    const w = parseInt(input.shift(), 10);
    const k = parseInt(input.shift(), 10);
    const s = [];
    let last = 1;
    let sr = [];
    let empties = 0;
    for (let y = 0; y < h; y++) {
        const row = input[y];
        sr = [];
        let empty = true;
        for (let x = 0; x < w; x++) {
            const cell = row[x];
            if (cell === '#') {
                if (!empty) {
                    last += 1;
                }
                empty = false;
                sr.push(last);
            } else {
                sr.push(last);
            }
        }
        if (empty) {
            empties += 1;
        } else {
            last += 1;
            for (var i = 0; i < empties + 1; i++)
                s.push(sr.join(' '));
            empties = 0;
        }
    }
    for (var i = 0; i < empties; i++)
        s.push(s[s.length - 1]);
    console.log(s.join('\n'));
}

import { readFileSync } from 'fs';
if (process.argv[1] == __filename) {
    const path = process.argv[2] || '/dev/stdin';
    const input = readFileSync(path, 'utf-8');
    main(input.split(/\s+/));
}

Measured memory_bytes: 15692
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,R;
  cin >> N >> R;
  while(N != 0){
    string S = "";
    for(int i=N; i>=1; i--){
      S += i + '0';
    }
    for(int i=0; i<R; i++){
      int p,c;
      cin >> p >> c;
      p--;
      S = S.substr(p,c) + S.substr(0,p) + S.substr(p+c);
    }
    cout << S[0]-'0' << endl;
    cin >> N >> R;
  }
  return 0;
}


Measured memory_bytes: 3144
from sys import stdin
#入力
readline=stdin.readline
N,K=map(int,readline().split())

mod=10**9+7
fact=[1]*(2*N)
finv=[1]*(2*N)
inv=[1]*(2*N)
inv[0]=0
for i in range(2,2*N):
    fact[i]=(fact[i-1]*i%mod)
    inv[i]=(-inv[mod%i]*(mod//i))%mod
    finv[i]=(finv[i-1]*inv[i])%mod

def com(N,K,mod):
    if (K<0) or (N<K):
        return 0
    return fact[N]*finv[K]*finv[N-K]%mod

if N-1<=K:
    print(com(2*N-1,N,mod))

else:
    res=0
    for m in range(K+1):
        res+=com(N,m,mod)*com(N-1,m,mod)
        res%=mod
    print(res)

Measured memory_bytes: 52468