akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/
int n,a,b;
int h[114514];
P max_h(){
    P re=P(h[0],0);
    for(int i=1;i<n;i++){
        if(re.first<h[i]){
            re=P(h[i],i);
        }
    }
    return re;
}

signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.substr(0,s.size()/2)+s.substr(0,s.size()/2)==s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{

    int a, b;
    scanf("%i %i", &a, &b);

    if (a < 10) {
        printf("%i\n", b + (100 * (10 - a)));
    } else {
        printf("%i\n", b );
    }

    return 0;
}

Measured memory_bytes: 256
using System;
namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split();
            int n = int.Parse(S[0]);
            int m = int.Parse(S[1]);
            int[,] A = new int[n, m];
            int[] b = new int[m];

            for (int i = 0; i < n; i++)
            {
                string[] data = Console.ReadLine().Split();
                for (int j = 0; j < m; j++)
                {
                    A[i, j] = int.Parse(data[j]);
                }
            }
            for (int i = 0; i < m; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }
            
            for (int i = 0; i < n; i++)
            {
                int result = 0;
                for (int j = 0; j < m; j++)
                {
                    result = result + A[i, j] * b[j];
                }
                Console.WriteLine(result);
            }
        } 
    }
}



Measured memory_bytes: 18048
import java.io.IOException;
import java.util.Scanner;

public class Main {
    private static StringBuilder sb = new StringBuilder();

    public static void main(String... args) throws IOException {
        final int[] targetAry = load();

        insertionSort(targetAry);

        System.out.print(sb.toString());
    }

    public static int[] load() throws IOException {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] nums = new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = scanner.nextInt();
        }

        return nums;
    }

    public static void insertionSort(final int[] targetAry) {
        for (int i = 0; i < targetAry.length; i++) {
            for (int j = i; 0 < j; j--) {
                if (targetAry[j - 1] > targetAry[j]) {
                    swap(targetAry, j - 1, j);
                }
                if ((1 < j) && (targetAry[j - 1] > targetAry[j - 2])) {
                    break;
                }
            }

            append(targetAry);
        }
    }

    public static void swap(final int[] targetAry, final int from, final int to) {
        final int tmp = targetAry[to];
        targetAry[to] = targetAry[from];
        targetAry[from] = tmp;
    }

    public static void append(final int[] targetAry) {
        for (int j = 0; j < targetAry.length; j++) {
            sb.append(targetAry[j]).append(j != targetAry.length - 1 ? ' ' : '\n');
        }
    }
}

Measured memory_bytes: 20792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
vector<pair<int,int> >g[maxn];
int ans[maxn];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    s = " " + s;
    int dp[s.size() + 5][2];
    memset(dp, 0x3f, sizeof(dp));
    dp[0][1] = 1;//多付1张
    dp[0][0] = 0;//正好
    f1(s.size() - 1) {
        int x = s[i] - '0';
        if (x != 90) {
            dp[i][1] = min(dp[i][1], dp[i-1][0] + x + 1);
        }
        dp[i][1] = min(dp[i][1], dp[i-1][1] + 9 - x);//找钱
        dp[i][0] = min(dp[i][0], dp[i-1][1] + 10 - x);//找钱
        dp[i][0] = min(dp[i][0], dp[i-1][0] + x);//直接用x张
    }
    cout << dp[s.size()-1][0] << '\n';
}

Measured memory_bytes: 34504
#include <stdio.h>
#include <math.h>

int main(int argc, char**argv){
  int a;
  int b;
  int i;
  int num;  
  int div;
  int mod;

  scanf("%d %d", &a, &b);
  //---------
  div = b;
  i = 0;
  while(div > 0){
    div = div / 10;
    i++;
  }
  //----------
  num = a;
  for(; i>0; i--){
  	num = num * 10;  
  }  
  num = num + b;
//  printf("%d\n", num);
  //----------
  i = 2;
  while(i <= num/2){
    div = num / i;
    mod = num % i;
    if(mod == 0){
      if(div == i){
      	printf("Yes");
        return 0;
      }
    }
    i++;
  }
  printf("No");
  return 0;
}  

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};

int main(){
  long double A, B, N;

  cin >> A >> B >> N;

  if(N < B){
    cout << (ll)(floor((A*N)/B) - A*floor(N/B)) << endl;
  }else{
    cout << (ll)(floor((A*(B-1))/B) - A*floor((B-1)/B)) << endl;
  }

  return 0;
}


Measured memory_bytes: 3752
#include<stdio.h>

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj])minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if (i != minj)sw++;
	}
	return sw;
}

int main(void) {
	int A[100], N, i, sw;

	scanf("%d", &N);
	for (i = 0; i < N; i++)scanf("%d", &A[i]);

	sw = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);


	return 0;
}

Measured memory_bytes: 604
import math
n=int(input())
flag=0
def sosuu(m):
    h=int(math.sqrt(m))
    for i in range(2,h+1):
        if m%i==0:
            return False
    return True

while flag==0:
    
    if sosuu(n):
        flag=1
        break
    n+=1
print(n)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#define white 0
#define gray 1
#define black 2
#define N 100
int n; int INF = (int)INFINITY;
int A[N][N], d[N], p[N], color[N];

int prim(void) {
  int mincost, u, sum = 0;
  for ( int i = 0; i < n; ++i ) {
    color[i] = white;
    d[i] = INF;
    p[i] = -1;
  }

  d[0] = 0;
  while ( 1 ) {
    mincost = INF;
    for ( int i = 0; i < n; ++i ) {
      if ( color[i] != black && d[i] < mincost ) {
        mincost = d[i];
        u = i;
      }
    }

    if ( mincost == INF ) break;
    color[u] = black;

    for ( int v = 0; v < n; ++v ) {
      if ( color[v] != black && A[u][v] != INF ) {
        if ( A[u][v] < d[v] ) {
          d[v] = A[u][v];
          p[v] = u;
          color[v] = gray;
        }
      }
    }
  }

  for ( int i = 0; i < n; ++i ) {
    if ( p[i] != -1 ) {
      sum += A[i][p[i]];
    }
  }

  return sum;
}

int main(void) {
  int c;
  scanf("%d", &n);
  for ( int i = 0; i < n; ++i ) {
    for ( int j = 0; j < n; ++j ) {
      scanf("%d", &c);
      A[i][j] = (c == -1) ? INF : c;
    }
  }
  printf("%d\n", prim());

  return 0;
}



Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pint = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool keta(int d) {
    int i = 0;
    while(d > 0) {
        d /= 10;
        i++;
    }
    if(i % 2 == 1) return true;
    else return false;
}

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

    int ans = 0;
    rep(i, n+1) {
        if(keta(i)) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
	if (n == 3) {
		cout << "2 5 63";
		return 0;
	}
	for (int x = 3; x + 6 < 30000 && n >= 4; x += 12, n -= 2) {
		cout << x << ' ' << x + 6 << ' ';
	}
	int x = 2;
	for (; n >= 3; x += 6, n -= 3) {
		cout << x + 2 << ' ' << x << ' ' << x+ 4 << endl;
	}
	if (n == 1) {
		cout << x + 4;
	} else if (n == 2) {
		cout << x << ' ' << x + 2;
	}
    return 0;   
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(){
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=1;i<=10;i++){
        x=r*x-d;
        cout<<x<<endl;
    }
   
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int h, w;

int counter (int x, int y, int vert, int horz, string rows[]) {
  int cnt = 0;
  while(1) {
    x += horz;
    y += vert;
    if (x < 0 || y < 0 || x >= w || y >= h) break;

    if (rows[y][x] == '.') cnt ++;
    else break;
  }

  return cnt;
}

int main(void){
  cin >> h >> w;

  string rows[h];
  pair<pair<int, int>, pair<int, int> > mat[h][w];

  for (int i = 0; i < h; i ++) {
    cin >> rows[i];
  }

  int _max = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int up, down, left, right;

      if (rows[i][j] == '#') {
        mat[i][j] = make_pair(make_pair(0, 0), make_pair(0, 0));
        int sum = mat[i][j].first.first + mat[i][j].first.second + mat[i][j].second.first + mat[i][j].second.second + 1;
        _max = max(sum, _max);
        continue;
      }

      if (i == 0 || rows[i-1][j] == '#') {
        down = counter(j, i, 1, 0, rows);
        up = 0;
      } else {
        down = mat[i-1][j].first.second - 1;
        up = mat[i-1][j].first.first + 1;
      }

      if (j == 0 || rows[i][j-1] == '#') {
        right = counter(j, i, 0, 1, rows);
        left = 0;
      } else {
        right = mat[i][j-1].second.second -1;
        left = mat[i][j-1].second.first + 1;
      }

      mat[i][j] = make_pair(make_pair(up, down), make_pair(left, right));
      int sum = mat[i][j].first.first + mat[i][j].first.second + mat[i][j].second.first + mat[i][j].second.second + 1;
      _max = max(sum, _max);
    }
  }

  cout << _max << endl;

  return 0;
}

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


signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& u:a)cin>>u;
	int l=0,r=0,cnt=0,sm=0;
	rep(l,n){
	if(l>0)sm-=a[l-1];
	if(r<l)r=l;
		while(r<n && (sm&a[r])==0){
			sm^=a[r];r++;
		}
		cnt+=r-l;
	}
	cout<<cnt<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 main(){
    ll n,k;cin>>n>>k;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll r=1e18,l=0;
    while(r-l>1){
        ll m=(r+l)/2;
        ll cnt=0;
        rep(i,n){
            cnt+=a[i]/m;
            if(a[i]%m==0&&a[i]>=m)cnt--;
        }
        if(cnt>k)l=m;
        else r=m;
    }
    if(l!=0){
    ll cnt=0;
    rep(i,n){
        cnt+=a[i]/l;
        if(a[i]%l==0&&a[i]>=l)cnt--;
    }
    if(cnt>k)cout<<r<<endl;
    else cout<<l<<endl;
    }
    else cout<<1<<endl;
}
    

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

int k;
const long long M = 3234566668;
priority_queue <long long> Q;

void gen(long long t) {
	if (t < M) {
		Q.push(M - t);

		long long u = t % 10;

		gen(t * 10 + u);

		if (u != 0)
			gen(t * 10 + u - 1);
		
		if (u != 9)
			gen(t * 10 + u + 1);
	}
}

int main()
{
	cin >> k;

	for (int i = 1; i <= 9; i++)
		gen(i);

	int j = 0;

	while (j < k - 1) {
		Q.pop();
		j++;
	}

	cout << M - Q.top() << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Node {
  vector<int> edges_to;
  vector<int> edges_cost;

  bool done;
  bool in_queue;
  int cost;
  int index;

  bool operator> (const Node& node) const{
    return index > node.index;
  }
  bool operator< (const Node& node) const{
    return index < node.index;
  }

};

using node = struct Node;

int main(){

  node graph[100000];
  node doneNode;
  priority_queue<node> q;

  int v, e, r;
  cin >> v >> e >> r;

  for(int i = 0; i < v; ++i) {
    graph[i].cost = -1;
    graph[i].index = i;
  }

  int s, t, d;
  for(int i = 0; i < e; ++i){
    cin >> s >> t >> d;
    graph[s].edges_to.push_back(t);
    graph[s].edges_cost.push_back(d);
    graph[s].in_queue = false;
  }

  graph[r].cost = 0;
  q.push(graph[r]);
  graph[r].in_queue = true;

  int to, cost;
  while(!q.empty()){
    doneNode = q.top();
    q.pop();

    graph[doneNode.index].done = true;
    graph[doneNode.index].in_queue = false;
    for(int i = 0, n = doneNode.edges_to.size(); i < n; ++i){
      to = doneNode.edges_to[i];
      cost = doneNode.cost + doneNode.edges_cost[i];
      if(graph[to].cost < 0 || cost < graph[to].cost){
        graph[to].cost = cost;
        if(!graph[to].in_queue) q.push(graph[to]);
      }
    }
  }



  for(int i = 0; i < v; ++i){
    if(graph[i].cost < 0) cout << "INF" << endl;
    else cout << graph[i].cost << endl;
  }

  return 0;
}



Measured memory_bytes: 119644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e5+10;
ll n,m;
ll P[maxx],C[maxx],ans;
int vis[maxx],num[maxx];
int main() {
	scanf("%lld%lld",&n,&m);
	rep(i,1,n+1){
		scanf("%lld",&P[i]);
	}
	rep(i,1,n+1){
		scanf("%lld",&C[i]);
	}
	memset(vis,0,sizeof(vis));
	ans=-1e9-10;
	rep(i,1,n+1){
		memset(vis,0,sizeof(vis));
		ll x=P[i],count=m;
		ll cnt=0,maxup=-1e9-10,maxnow=0;
		rep(j,0,count){
			if(vis[x]){
				break;
			}
			else{
				cnt++;
				vis[x]=1;
				maxup=max(maxup,maxnow+C[x]);
				maxnow=maxnow+C[x];
				x=P[x];
			}
		}
		if(cnt==count)ans=max(maxup,ans);
		else {
			if(maxnow<0){
				ans=max(maxup,ans);
			}else{
				ll h=count/cnt;
				ll rest=count%cnt;
				ll tempup=-1e9-10;
				ll tempnow=0;
				if(rest==0){
					ll result=(h-1)*maxnow+maxup;
					ans=max(ans,result);
				}else{
					x=P[i];
					rep(j,0,rest){
						tempnow+=C[x];
						tempup=max(tempnow,tempup);
						x=P[x];
					}
					ll result=h*maxnow+tempup;
					ans=max(ans,result);	
				}
			}
		}
	}
	cout<<ans;
} 

Measured memory_bytes: 4244
class Circle
  def initialize
    @n = $stdin.gets.chomp.to_i
    @result = []

    @n.times do
      @xa,@ya,@ra,@xb,@yb,@rb = $stdin.gets.chomp.split(' ').map(&:to_f)
      @d = calc_distance
      if @d > @ra+@rb
        @result << "0"
        next
      end
      if @ra > @rb
        if check_a
          @result << "2"
          next
        end
      else
        if check_b
          @result << "-2" 
          next
        end
      end  
      @result << "1"
    end

    @result.each do |n|
      puts n
    end
  end

  def calc_distance
    a = @xa - @xb
    b = @ya - @yb
    dist = Math::sqrt(a*a+b*b)
  end

  def check_a
    @d + @rb < @ra
  end

  def check_b
    @d + @ra < @rb
  end
end

c = Circle.new

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = int.Parse(Console.ReadLine());

            if(aaa >= 1000)
            {
                Console.WriteLine("ABD");
            }
            else
            {
                Console.WriteLine("ABC");
            }

        }
    }
}


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

int main(){
 int n,a,b,c,d,i,j,u,p,v,t;
  c=0;
  d=0;
  cin>>n;
  vector<int>x(100001),y(100001);
  for (i=0;i<100001;i++){
    x[i]=0;
    y[i]=0;
  }
  for( i=0;i<n/2;i++){
    cin>>a>>b;
    x[a]++;
    y[b]++;
    }
  a=0,b=0;
  
for( j=0;j<100001;j++){
	
  if(x[j]>a){
    a=max(a,x[j]);
    p=j;
  }
  if(y[j]>b){
  b=max(b,y[j]);
  u=j;
  }
}
if(p!=u){
  cout<<n-a-b<<endl;
}
  else{
    for( j=0;j<100001;j++){
        if(x[j]>c&&j!=p){
    c=max(c,x[j]);
  }
  if(y[j]>d&&j!=u){
  d=max(d,y[j]);
  }
    }
    if(abs(a-c)>abs(b-d)){
      b=d;
    }
    else{
      a=c;
    }
    cout<<n-a-b<<endl;
}
}

Measured memory_bytes: 1024
<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$d = trim(fgets(STDIN));
$e = trim(fgets(STDIN));
$k = trim(fgets(STDIN));

if ( $e-$a>$k ) {
    echo ':(';
} else {
    echo 'Yay!';
}


Measured memory_bytes: 4856
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(item) - 1 for item in input().split()]
    edge[a].append(b)
    edge[b].append(a)

childs = [[] for _ in range(n)]
def dfs(p, v):
    val = 1
    for nv in edge[v]:
        if nv == p:
            continue
        ret = dfs(v, nv)
        val += ret
        childs[v].append(ret)
    if val != n:
        childs[v].append(n - val)
    return val

dfs(-1, 0)
total_pattern = pow(2, n, MOD)
total_pattern_inv = pow(total_pattern, MOD-2, MOD)
inv2 = pow(2, MOD-2, MOD)
pow2_table = [1]
for i in range(2 * 10**5):
    pow2_table.append(pow2_table[-1] * 2 % MOD)
ans = 0
for line in childs:
    pattern_ok = 0
    if len(line) == 1:
        continue
    for item in line:
        pattern_ok += pow2_table[item] - 1
    pattern_ok += 1
    ans += (total_pattern * inv2 - pattern_ok) * total_pattern_inv
    ans %= MOD
print(ans)

Measured memory_bytes: 190704
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    long long N;

    scanf("%lld", &N);

    long long ans = 1;

    for(long long i = 1; i <= N; i++){
        ans = (ans * i) % 1000000007;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
    int H, W;
    cin>>H>>W;
    int a[H][W];
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cin>>a[i][j];
        }
    }
    vector<vector<int> >ans;
    vector<int> tmp;
    for(int i=0;i<H;++i){
        if(i%2==0){
            for(int j=0;j<W;++j){
                if(a[i][j] % 2 == 1){
                    if(j<W-1){
                        tmp.push_back(i);
                        tmp.push_back(j);
                        tmp.push_back(i);
                        tmp.push_back(j+1);
                        ans.push_back(tmp);
                        tmp.clear();
                        a[i][j]--;
                        a[i][j+1]++;
                    }
                    else{
                        if(i<H-1){
                            tmp.push_back(i);
                            tmp.push_back(j);
                            tmp.push_back(i+1);
                            tmp.push_back(j);
                            ans.push_back(tmp);
                            tmp.clear();
                            a[i][j]--;
                            a[i+1][j]++;
                        }
                        else{
                            continue;
                        }
                    }
                }
            }
        }
        else{
            for(int j=W-1;j>=0;--j){
                if(a[i][j] % 2 == 1){
                    if(0<j){
                        tmp.push_back(i);
                        tmp.push_back(j);
                        tmp.push_back(i);
                        tmp.push_back(j-1);
                        ans.push_back(tmp);
                        tmp.clear();
                        a[i][j]--;
                        a[i][j-1]++;
                    }
                    else {
                        if(i<H-1){
                            tmp.push_back(i);
                            tmp.push_back(j);
                            tmp.push_back(i+1);
                            tmp.push_back(j);
                            ans.push_back(tmp);
                            tmp.clear();
                            a[i][j]--;
                            a[i+1][j]++;
                        }
                        else{
                            continue;
                        }
                    }
                }
            }
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();++i){
        cout<<ans[i][0]+1<<" "<<ans[i][1]+1<<" "<<ans[i][2]+1<<" "<<ans[i][3]+1<<endl;
    }
}


Measured memory_bytes: 10032
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    //freopen("in.txt","r",stdin);
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a+b>=c) printf("No\n");
    else {
        c=c-a-b;
        if(4*a*b>=c*c) printf("No\n");
        else printf("Yes\n");
    }
	return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

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

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

int sm(ll n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int fact(ll n){
    if(n==1)
        return 1;
    else
        return n*fact(n-1);
}

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n>=30)
            cout<<"Yes";
        else
            cout<<"No";
    }   
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  int i,v,u;
  queue<int> q;
  q.push(s);
  for(i=0;i<n;i++){
    d[i]=INFTY;
  }
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=0;v<n;v++){
      if(M[u][v]==0){
	continue;
      }
      if(d[v]!=INFTY){
	continue;
      }
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,((d[i]==INFTY)?(-1) : d[i]));
  }
}

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}

  
  
    
 
  
  



Measured memory_bytes: 2724
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


a, b = LI()
print(max(a - b * 2, 0))

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

bool isLower(char x){
    return 'a' <= x && x <= 'z';
}

int main(){
    string s;
    cin >> s;

    if(s[0] == 'A'){
        bool c = false;
        bool judge = true;
        for(int i = 2; i < s.length()-1; i++){
            if(!c && s[i] == 'C'){
                c = true;
            }else if(isLower(s[i])){
                // do nothing
            }else{
                judge = false;
            }
        }

        if(c && judge && isLower(s[1]) && isLower(s[s.length()-1])) 
            cout << "AC" << endl;
        else
            cout << "WA" << endl;
    }else{
        cout << "WA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long int a,b,c;
    cin>>a>>b>>c;
    long long int total = a/(b+c)*b;
    long long int remain = a%(b+c);
    total += min(remain,b);
    cout<<total<<'\n';
}

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

int main() {
  int N;
  cin >> N;
  
  string W;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  for(int i = 0; i < N; i++) {
	cin >> W;
    if (W == "P") {
    	p = 1;
    } else if (W == "W") {
      	w = 1;
    } else if (W == "G") {
        g = 1;
    } else if (W == "Y") {
    	y = 1;
    }
  }
  
  int type = p + w + g + y;
  if( type == 4) {
    cout << "Four" << endl;
  } else {
     cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Obj[] objs = new Obj[N];
        for (int i = 0; i < N; i++) {
            objs[i] = new Obj(scanner.next(), scanner.nextInt(), i);
        }
        Arrays.sort(objs);
        for (Obj obj : objs) {
            System.out.println(obj.num + 1);
        }
    }

    public static class Obj implements Comparable<Obj> {
        String name;
        int p;
        int num;

        public Obj(String name, int p, int num) {
            this.name = name;
            this.p = p;
            this.num = num;
        }

        @Override
        public int compareTo(Obj o) {
            if (this.name.compareTo(o.name) == 0) {
                return -Integer.compare(this.p, o.p);
            } else {
                return this.name.compareTo(o.name);
            }
        }

    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

using namespace std;

bool sieve[10001];

void s() {
    memset(sieve, 1, sizeof(sieve));
    sieve[0] = sieve[1] = 0;
    for(int i = 2; i <= sqrt(10001); i++) {
        if(sieve[i]) {
            for(int j = i * i; j < 10000; j += i) {
                sieve[j] = 0;
            }
        }
    }
}

int p, ct = 0;

int main(void) {
    s();
    while(~scanf("%d", &p)) {
        ct = 0;
        for(int i = 1; i <= p; i++) {
            if(sieve[i] && sieve[(p - i) + 1]) {
                ct++;
            }
        }
        printf("%d\n", ct);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(int argc, const char * argv[])
{
    int n;
    cin >> n;
    
    int total = 0;
    
    while(n >= 3)
    {
        total++;
        n = n - 3;
    }
    
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,i,q,flg;
	scanf("%d%d",&a,&b);
	c=b;
	q=1;
	while(c!=0){
		q*=10;
		c/=10;
	}
	c=q*a+b;
	flg=0;
	//printf("%d\n",c);
	for(i=1;i<1000;i++){
		if(i*i==c){
			flg=1;
			break;
		}
		//printf("%d\n",i*i);
	}
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
	int N;
  	cin >> N ;
  	if (N / 100 == (N % 100 / 10) * 11 || (N / 1000) / 10 == (N % 10) * 11)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
  	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int r;
  cin>>r;

  cout<<3*r*r<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main(){
    FAST
    int n;cin>>n;
    map<string,int> mp;
    mp["AC"]=0;mp["WA"]=0;mp["TLE"]=0;mp["RE"]=0;
    while(n--){
        string s;cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\nWA x "<<mp["WA"]<<"\nTLE x "<<mp["TLE"]<<"\nRE x "<<mp["RE"]<<endl;
    
    return 0;
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  ll n,k;
  cin>>n>>k;
  int a;
  REP(i,n){
    int x;
    cin>>x;
    if(x==1){a=i;}
  }
  if(k<=a&&a<=n-1-k){
    int x=a-1,y=n-k+1-a;
    if(x%(k-1)==0){x/=(k-1);}
    else{x/=(k-1);x++;}
    if(y%(k-1)==0){y/=(k-1);}
    else{y/=(k-1);y++;}
    cout<<x+y+1<<endl;
  }
  else{
    int x=n-k;
    if(x%(k-1)==0){x/=(k-1);}
    else{x/=(k-1);x++;}
    cout<<x+1<<endl;
  }
           
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    while (sc.hasNextLine) {
      var tmpline = sc.nextLine()
      while (!(tmpline.matches(""".*(the|that|this).*"""))) {
        val line2 = tmpline.map(
          _ match {
            case ch if 'b' to 'z' contains ch => (ch - 1).toChar
            case ch if ch == 'a' => 'z'
            case ch => ch
          }
        )
        tmpline = line2
      }
      println(tmpline)

    }
  }
}

Measured memory_bytes: 47732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k,sum=0;
    cin>>n>>k;
    vec<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    sort(ALL(a));
    rep(i,min(k,n)) sum-=a[n-1-i];
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

#define PB push_back
#define MEM(n, val) memset(n, val, sizeof(n))
#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define ROF(i, j, k) for(int i = j; i >= k; i--)
#define LL long long
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define INF 1000000000
#define MP make_pair
#define LN (node * 2)
#define RN ((node * 2) + 1)
#define MX 510
#define SF(a) scanf("%d", &a)
#define SFF(a, b) scanf("%d %d", &a, &b)
#define MOD 1000000007
#define SQN 600

int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};

int n, k;
LL ara[100010];
vector<LL> le, ri;
LL c_ri[100010], c_le[100010];


int main()  {
    cin >> n >> k;
    FOR(i, 0, n - 1)   {
        cin >> ara[i];
        if(ara[i] < 0)  {
            le.PB(ara[i]);
        }
        else if(ara[i] == 0)    {
            k--;
        }
        else    {
            ri.PB(ara[i]);
        }
    }

    FOR(i, 0, (int)ri.size() - 1)   {
        if(i == 0)    {
            c_ri[i] = ri[i] - 0;
        }
        else    {
            c_ri[i] = c_ri[i - 1] + (ri[i] - ri[i - 1]);
        }
        //cout << i << " : " << c_ri[i] << "\n";
    }
    ROF(i, (int)le.size() - 1, 0)   {
        if(i == (int)le.size() - 1)    {
            c_le[i] = 0 - le[i];
        }
        else    {
            c_le[i] = c_le[i + 1] + (le[i + 1] - le[i]);
        }
        //cout << i << " : " << c_le[i] << "\n";
    }
    LL ans = 1000000000000000;
    if(ri.size() >= k)    {
        ans = min(ans, c_ri[k - 1]);
    }
    if(le.size() >= k)    {
        ans = min(ans, c_le[ le.size() - k ]);
    }


    FOR(i, 0, min(k - 1, (int)ri.size() - 1))   {
        int baki = k - (i + 1);
        if(le.size() >= baki)    {
            ans = min(ans, 2 * c_ri[i] + c_le[ le.size() - baki ]);
        }
        //cout << i << " " << le.size() - baki << "\n";
    }
    int nisi = 0;
    ROF(i, (int)le.size() - 1, max(0, (int)le.size() - k))    {
        nisi++;
        int baki = k - nisi;
        if(ri.size() >= baki)    {
            ans = min(ans, c_ri[baki - 1] + 2 * c_le[i]);
        }

        //cout << i << ": " << nisi << " " << baki - 1 << " : " << c_ri[baki - 1] + 2 * c_le[i] << "\n";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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

  int X;
  cin >>X;

  cout <<(2000-X+200-1)/200;

  
  }

Measured memory_bytes: 3652
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

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

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll ans =0;
  rep(i, 5){
    ll a;
    cin >> a;
    if(a!=(i+1))ans = i+1;
  }
  cout << ans;
  return 0;
}


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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  string prev = "";
  ll ans = 0;
  rep(i, s.size()){
    repd(j, 1, 3){
      string tmp = s.substr(i, j);
      // cout << tmp << endl;
      if(prev != tmp){
        ans++;
        prev = tmp;
        i += j-1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(true){
		cin>>n;
		if(n==0){
			return 0;
		}
		bool k=false;
		int z=0;
		int m;
		for(int i=0; i<n; i++){
			cin>>m;
			if(m==0){
				z++;
			}
			if(m>=2){
				k=true;
			}
		}
		if(k){
			cout<<n-z+1<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
		
}


Measured memory_bytes: 3080
N = int(input())-1

A = []

Alpha = "abcdefghijklmnopqrstuvwxyz"

while True:
    N,n = divmod(N,26)
    A.append(n)
    N-=1
    if N < 0:
        break

name = ""
for i in A:
    name = Alpha[i]+name

print(name)

Measured memory_bytes: 8960
#include <bits/stdc++.h> 
using namespace std; 
int Min(int A,int B)
{
    return A<B?A:B;
}
int main()
{ 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int A,B,Q;
    cin>>A>>B>>Q;
    int arr[A+1];
    int arr1[B+1];
    int min=INT_MAX;
    int min1=INT_MAX;
    for(int i=1;i<=A;i++)
    {
        cin>>arr[i];
        if(arr[i]<min)
        {
            min=arr[i];
        }
    }
    for(int j=1;j<=B;j++)
    {
        cin>>arr1[j];
        if(arr1[j]<min1)
            min1=arr1[j];
    }
    int ans=INT_MAX;
    while(Q--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        int sum=arr[x]+arr1[y]-z;
        if(sum<ans)
            ans=sum;
    }
    cout<<Min(ans,min+min1);
    
}

Measured memory_bytes: 1024
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

K, S = list(map(int, sys.stdin.readline().split()))

ans = 0
for x in range(K + 1):
    yz = S - x
    if yz < 0 or 2 * K < yz:
        continue
    ans += yz + 1
    ans -= max(0, yz - K) * 2
print(ans)


Measured memory_bytes: 23596