akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main() {
	int n; cin >> n;
	vector<double> v(n);
	rep(i, n) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());

	double ans = (v[0]+v[1])/2;

	rep(i,n-2){
		ans = (ans + v[i + 2]) / 2;
	}

	cout << ans << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        new Solver().Solve();
        Console.ReadLine();
    }
}

class Solver
{
    int N;
    int[] A;

    public void Solve()
    {
        // 奇数がある場合
        if (A.Any(e => e % 2 == 1))
        {
            Console.WriteLine(0);
            return;
        }

        // 偶数のみの場合
        Func<int, int> func = delegate (int n) // 2で割れる回数を返す
        {
            int kaisuu = 0;
            for (; n % 2 == 0; n /= 2)
            {
                kaisuu++;
            }
            return kaisuu;
        };

        int min_kaisuu = A.Select(e => func(e)).Min();
        Console.WriteLine(min_kaisuu);
        return;
    }

    public Solver()
    {
        N = ReadInt();
        A = ReadIntArray();
    }

    static String ReadString() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static long ReadLong() { return long.Parse(Console.ReadLine()); }
    static double ReadDouble() { return double.Parse(Console.ReadLine()); }
    static String[] ReadStringArray() { return Console.ReadLine().Split(' '); }
    static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
    static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
    static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
}


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

int main(){
    long A, B;
    cin >> A >> B;

    long ans(0);
    while(A % 4 != 0){
        ans = ans ^ A;
        A = A + 1;
    }
    while(B % 4 != 3 && B % 4 != -1){
        ans = ans ^ B;
        B = B - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
int_n = int(input())
int_d, int_x = map(int, input().split())

count = 0

array_a = []
for a in range(int_n):
    array_a.append(int(input()))


for a in array_a:
    count += len(set([(a * d) + 1 for d in range(int_d)]) & set([d + 1 for d in range(int_d)]))

print(count + int_x)


Measured memory_bytes: 3060
#17:09
n,k = map(int,input().split())
v = list(map(int,input().split()))
'''
左からa個
右からb個
k-a-b個以内捨てて良し
'''
can = []
nk = min(n,k)
for a in range(nk+1):
  if a != 0:
    x.append(v[a-1])
  else:
    x = []
  for b in range(nk+1-a):
    if b != 0:
      y.append(v[-b])
    else:
      y = []
    z = x + y
    z.sort()
    r = k - a - b
    tmp = 0
    if r < a+b:
      if z[r] < 0:
        for i in range(r,a+b):
          tmp += z[i]
      else:
        for i in range(a+b):
          if z[i] >= 0:
            tmp += z[i]
    else:
      for i in range(a+b):
        if z[i] >= 0:
          tmp += z[i]
    can.append(tmp)
print(max(can))

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string s;
    cin >> s;
    rep(i,12){
        cout << s[i];
        if(i==3){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3464
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
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;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

int main() {
    char ch;
    cin >> ch;
    if (ch >= 'a')
        puts("a");
    else
        puts("A");
    return 0;
}


Measured memory_bytes: 3592
module Main (main) where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = readInts >>= print . showAnswer . solve

type Input  = [Int]
type Output = Bool

solve :: Input -> Output
solve [a,b,c] = any (\x -> x `mod` b == c) [a,2*a .. b*a]

showAnswer :: Output -> Answer
showAnswer = YESNO

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | ByteString ByteString
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)       = bool "No" "Yes"  b
  show (YESNO b)       = bool "NO" "YES"  b
  show (AB b)          = bool "B"  "A"    b
  show (Number i)      = show i
  show (String s)      = s
  show (ByteString bs) = C8.unpack bs
  show (Compare o)     = ordering "<" "=" ">" o
  show (Compare2 o)    = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

-- | k 番目の文字に関数 f を適用する
indexMapBS :: Int -> (Char -> Char) -> ByteString -> ByteString
indexMapBS k f s = C8.concat [s1, C8.singleton (f c), s3]
  where
    (s1, s2) = C8.splitAt (k-1) s
    c = C8.head s2
    s3 = C8.tail s2

Measured memory_bytes: 380
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll N=10;
    ll h,w;cin>>h>>w;
    ll c[N][N];
    rep(i,0,N-1)rep(j,0,N-1)cin>>c[i][j];
    ll dp[N];
    rep(i,0,N-1)dp[i]=inf;
    dp[1]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>>q;q.push({0,1});
    while(!q.empty()){
        l_l t=q.top();q.pop();
        rep(i,0,N-1){
            if(i==t.se)continue;
            if(dp[i]>dp[t.se]+c[i][t.se]){
                dp[i]=dp[t.se]+c[i][t.se];
                q.push({dp[i],i});
            }
        }
    }
    
    //rep(i,0,N-1)cout<<dp[i]<<" ";cout<<endl;
    
    ll ans=0;
    rep(i,0,h*w-1){
        ll c;cin>>c;
        if(c==-1)continue;
        ans+=dp[c];
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main(void)
{
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  rep(i,M) cin >> B[i];
  int A[N][M];
  rep(i,N) rep(j,M) cin >> A[i][j];
  int ans = 0;
  rep(i,N){
    int sum = 0;
    rep(j,M) sum += A[i][j] * B[j];
    sum += C;
    if(sum > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

long long int parent[Max],cnt[Max],set_size[Max];


void makeSet(long long int n)
{
    parent[n]=n;
     set_size[n]=1;
}

long long int Find(long long int reprasentative)
{
    if (parent[reprasentative] == reprasentative)
    {
        return reprasentative;
    }
    return parent[reprasentative] = Find(parent[reprasentative]);
}

void Union(long long int a,long long int b)
{
    long long int u = Find(a);
    long long int v = Find(b);
    if(u == v)
    {
        //printf("Frnds");
    }
    else{
        if(set_size[u]>set_size[v])
           swap(u,v);
        parent[u]=v;
        set_size[v]+=set_size[u];
    }
}

long long int paircnt(long long int n)
{
    return (n-1)*n/2;
}

int main()
{
    long long int a,b,c,d,e,f,n,m,i,j,k;
    cin>>n>>m;
    for (int i=0; i <=n; i++)
    {
        makeSet(i);
    }
    c=paircnt(n);
    vector < pair <long long int , long long int > > v1;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        v1.push_back({a,b});
    }

    vector <long long int> ans;
    ans.push_back(c);
    for(i=m-1;i>0;i--)
    {
        a=v1[i].first;
        b=v1[i].second;
        if(Find(a)==Find(b))
            ans.push_back(c);
        else
        {
            d=set_size[Find(a)];
            e=set_size[Find(b)];
            Union(a,b);
            d=paircnt(d);
            e=paircnt(e);
            c-=(paircnt(set_size[Find(a)])-d-e);
            ans.push_back(c);
        }
    }
    k=ans.size();
    for(i=k-1;i>=0;i--)
    {
        cout<<ans[i];
         cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 8048
def comb(sum)
  ans=[]
  a=sum/200
  b=sum/300
  c=sum/500
  for i in 0.. a
    for j in 0.. b
      for k in 0.. c
        if 200*i+300*j+500*k == sum
          ans.push([i,j,k])
        end
      end
    end
  end
  return ans
end
 
def price(c)
  ans=0
  price=100000000
  p = [[1520,1870,2244],[380,550,850]]
  for i in 0.. c.length-1
    tp=0
    for j in 0.. 2
      t = c[i][j]/(5-j)
      tp += t*p[0][j]+(c[i][j]-t*(5-j))*p[1][j]
    end
    if tp<price
      price = tp
      ans = i
    end
  end
  puts price
end
 
 
while true
  g=gets.to_i
  if g==0 then break end
  price(comb(g))
end

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

const int N = 3005;

string s, t;
int dp[N][N];

int solve(int a, int b) {
  if (a == s.length() || b == t.length()) return 0;

  int &ret = dp[a][b];
  if (ret != -1) return ret;

  ret = max(solve(a+1, b), solve(a, b+1));
  if (s[a] == t[b]) ret = max(ret, 1 + solve(a+1, b+1));

  return ret;
}

void rec(int a, int b) {
  if (a == s.length() || b == t.length()) {
    puts("");
    return;
  }

  if (s[a] == t[b] && solve(a, b) == 1 + solve(a+1, b+1)) {
    printf("%c", s[a]);
    rec(a+1, b+1);
  } else if (solve(a, b) == solve(a+1, b)) {
    rec(a+1, b);
  } else {
    rec(a, b+1);
  }
}

int main() {
  cin >> s >> t;
  memset(dp, -1, sizeof dp);
  rec(0, 0);
  return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    cin >> N;
}

int solve(){
    for (int h = max(N/4,1); h <= 3500; h++)
    for (int n = max(N/4,1); n <= 3500; n++){
        int w = 1/((double)4/N-(double)1/h-(double)1/n);
        if(w<=0) continue;
        if(4*h*n*w==(N*(h*n+n*w+w*h))){
            cout << h << " " << n << " " << w << endl;
            return 0;
        }
    }
    return 0;
}   

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

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

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
    ll res=1;
    while(b)
    {
        if(b&1LL)
            res=(res*a)%c;
        a=(a*a)%c;
        b>>=1;
    }
    return res;
}


ll solve(ll n,ll height[],ll beauty[])
{


    //Dp[i]->maximum beauty for a subsequence which ends at ith flower:
    ll dp[n];
    dp[0]=beauty[0];

    //We maintain a map with key as height as we know height is always distinct:
    //To maintain a structure in which if height[i]< height[j] then dp[i]<dp[j];
    map<ll,ll>mp;

    mp[height[0]]=dp[0];

    for(ll i=1;i<n;i++)
    {
        dp[i]=beauty[i];
        auto it=mp.upper_bound(height[i]);

        if(it!=mp.begin())
        {
            --it;
            dp[i]+= it->second;
        }

        mp[height[i]]=dp[i];

        it=mp.upper_bound(height[i]);

        while(it!=mp.end() and it->second<dp[i])
        {
            auto temp=it;
            temp++;
            mp.erase(it);
            it=temp;
        }
       
    }


    return *max_element(dp,dp+n);

}


int main()
{
    FASTIO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    

    ll n;
     cin>>n;

     ll height[n];

     for(ll i=0;i<n;i++)
        cin>>height[i];

    ll beauty[n];

    for(ll i=0;i<n;i++)
        cin>>beauty[i];

    cout<<solve(n,height,beauty)<<"\n";
    
    return 0;
}

Measured memory_bytes: 20800
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,x,y,sw,m,n,dist,poi:Integer;
  a,b,c,d:array of Integer;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(n);
    Readln(m);
    SetLength(a,n);
    SetLength(b,n);
    for i := 0 to n - 1 do begin
      Read(a[i]);
      Readln(b[i]);
    end;
    SetLength(c,m);
    SetLength(d,m);
    for i := 0 to m - 1 do begin
      Read(c[i]);
      Readln(d[i]);
    end;

    for i := 0 to n - 1 do begin
      dist:=999999999;
      for j := m-1 downto 0 do begin
        //dist:=(dist + abs(a[i]-c[j])+abs(b[i]-d[j])- abs(dist - abs(a[i]-c[j])+abs(b[i]-d[j]))) div 2;
        if dist>=abs(a[i]-c[j])+abs(b[i]-d[j]) then begin
          poi:=j+1;
          dist:=abs(a[i]-c[j])+abs(b[i]-d[j]);
        end;
      end;
      Writeln(poi);
    end;

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;
int A[8];
int dz[4] = {-4,-1,1,4};
map<string,int> d;

void bfs() {
    d["01234567"] = 0;
    queue<string> Q;
    Q.push("01234567");
    while(!Q.empty()) {
        string cur = Q.front(); Q.pop();
        int z;
        for(int i=0; i<8; i++) {if(cur[i] == '0') {z = i; break;}}
        for(int i=0; i<4; i++) {
            int nz = z + dz[i];
            if(z == 3 && nz == 4) continue;
            if(z == 4 && nz == 3) continue;
            if(nz >= 0 && nz < 8) {
                string ns = cur;
                swap(ns[z], ns[nz]);
                if(d.find(ns) == d.end()) {
                    d[ns] = d[cur] + 1;
                    Q.push(ns);
                }  
            }
        }
    }
}

int main() {
    bfs();
    while(cin >> A[0]) {
        for(int i=1; i<8; i++) cin >> A[i];
        string s(8, '0');
        for(int i=0; i<8; i++) s[i] = '0' + A[i];
        cout << d[s] << endl;
    }
}


Measured memory_bytes: 5244
#include<iostream>
#include<algorithm>
 using namespace std;
 typedef unsigned long long ull;
 int main()
 {
 	ull h,w,ans;
 	cin>>h>>w;
 	ans=h/2*w;
 	if(h%2!=0) ans+=(w+1)/2;
	if(h==1||w==1) ans=1;  
 	cout<<ans;
 }

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
inf = float('inf')

def main():
    H, W = map(int, readline().split())
    grid = []
    grid.append(['*'] * (W+2))
    for _ in range(H):
        grid.append(['*'] + list(readline()[:-1]) + ['*'])
    grid.append(['*']*(W+2))

    DP = [[inf] * (W+2) for _ in range(H+2)]
    DP[1][1] = (grid[1][1] == '#')*1

    for i in range(1, H+1):
        for j in range(1, W+1): 
            if i == 1 and j == 1:
                continue
            k = i
            gridkj = grid[k][j]
            if gridkj == '.':
                DP[k][j] = min(DP[k][j-1], DP[k-1][j])
            if gridkj == '#':
                DP[k][j] = min(DP[k][j-1]+(grid[k][j-1] in ['.', '*']), DP[k-1][j] + (grid[k-1][j] in ['.', '*']))
    ans = DP[H][W]
    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
	int N, A, sum = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		if (A % 2) ++sum;
	}
	if (sum % 2) cout << "NO";
	else cout << "YES";
}

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

int main(){
	int w, n;
	int *L;
	int **A;
	int p;
	int i;

	scanf("%d", &w);
	scanf("%d", &n);

	L = (int *)malloc(w*sizeof(int));
	for(i = 0; i < w; i++){
		L[i] = i+1;
	}

	A = (int**)malloc(n*sizeof(int *));

	for(i = 0; i < n; i++){
		A[i] = (int*)malloc(2*sizeof(int));
		scanf("%d,%d", &A[i][0], &A[i][1]);
		p = L[A[i][0]-1];
		L[A[i][0]-1] = L[A[i][1]-1];
		L[A[i][1]-1] = p;
	}

	for(i = 0; i < w; i++){
		printf("%d\n", L[i]);
	}
	
	return 0;
}

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

int main(){
  int N, x_4, x_7, yes=0;
  cin >> N;
  x_4=N/4;
  x_7=N/7;
  for(int i=0; i<=x_4; i++){
    for(int j=0; j<=x_7; j++){
      if (4*i+7*j==N){
        yes=1;
      }
    }
  }
  if (yes==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<char> vec(W);
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << "#";
    for(int i = 0; i < W; i++){
      cin >> vec.at(i);
      cout << vec.at(i);
    }
    cout << "#" << endl;
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    k=int(input())
    A=list(map(int,input().split()))

    l=r=2
    for a in A[::-1]:
        l=a*((l-1)//a+1)
        r=a*(r//a)+(a-1)
        if(l>r):
            print(-1)
            return

    print(l,r)
resolve()

Measured memory_bytes: 63984
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const firstLine = input[0].split(' ').map(item => parseInt(item))
const N = firstLine[0]
const Y = firstLine[1]

result = '-1 -1 -1'
for (i = 0; i <= N; i++) {
    for (j = 0; j <= N - i; j++) {
        for (k = N - (i + j); k <= N - (i + j); k++) {
            if (10000 * i + 5000 * j + 1000 * k === Y) {
                result = `${i} ${j} ${k}`
            }
        }
    }
}
console.log(result)


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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,k,t=1,cnt=0,mid,r;
int a[200005],now[200005],visited[200005]; 

inline int get_mod(int aa,int bb){
	if(aa%bb==0)  
        return bb;
	else return aa%bb;
}

signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)  
        cin>>a[i];
	
	for(int i=1;i<=n*n;i++){
		now[++cnt]=t;
		
		if(visited[t]==0)  
            visited[t]=cnt;
		else{
			mid=visited[t];
			r=cnt;
			break;
		}
		t=a[t];
	}
	r--;
	k++;
	
	if(k<=mid)  
        cout<<now[k]<<endl;
	
	else{
		k=k-mid;
		k=get_mod(k,r-mid+1);
		k=k+mid;
		cout<<now[k]<<endl;
	}
	return 0;
}



Measured memory_bytes: 8264
#!/usr/bin/env python3
import sys

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a,b):
    return a*b//gcd(a,b)

def get_b_cnt(a,b,x):
    res = 0
    N = b - a + 1
    x1 = a % x 
    if x1 > 0:
        x1 = x - x1

    if x1 < N:
        res += 1

    N2 = N - x1 -1

    if N2 > 0:
        res += (N2 // x)

    return res


def solve(A: int, B: int, C: int, D: int):
    E = lcm(C,D)

    print(B-A+1-(get_b_cnt(A,B,C)+get_b_cnt(A,B,D)-get_b_cnt(A,B,E)))

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int i;
    int64_t sum,hun,X;
    sum = 100;
    hun = 100;
    i = 0;
 
    cin >> X;

    if(X<100508083){
        while (sum<X)
        {
            sum += sum/hun;
            i++;
        }
    }else{
        i=1446;
        sum=100508083;
        while(sum<X)
        {
            sum += sum/hun;
            i++;
        }
    }
 
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <string>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int translateChar(char ch){
	int ret;
	switch(ch){
	case 'A':
		ret = 1;
		break;
	case 'C':
		ret = 2;
		break;
	case 'G':
		ret = 3;
		break;
	case 'T':
		ret = 4;
		break;
	}
	return ret;
}

int calc(int num){
	if(num == 0){
		return 1;
	}else{
		return 4*calc(num-1);
	}
}

int translateStr(char buf[]){
	int sum = 0;
	for(int i = 0; buf[i] != '\0'; i++){
		sum += translateChar(buf[i])*calc(i);
	}
	return sum - 1;
}

int main(){

	queue<string> Messages;
	int n;
	scanf("%d",&n);
	char order[ORDER_LENGTH],str[STR_LENGTH];

	char* check_table = new char[TABLE_SIZE];

	for(int i = 0; i < n; i++){
		scanf("%s %s",order,str);
		if(strcmp(order,"insert") == 0){
			check_table[translateStr(str)] = 'Y';
		}else{
			if(check_table[translateStr(str)] == 'Y'){
				Messages.push("yes");
			}else{
				Messages.push("no");
			}
		}
	}

	while(!Messages.empty()){
			cout << Messages.front() << endl;
			Messages.pop();
	}

	delete[] check_table;
}

Measured memory_bytes: 27732
#include <stdio.h>
#include <math.h>
long long F(long long i, long long j)
{
   long long k,l=1;
    for(k=1;;k++)
        if(i<10)
            break;
        else
            i/=10;
    for(l=1;;l++)
        if(j<10)
            break;
        else
            j/=10;
    return k>l? k:l;

}
main()
{
	long long p=9876543210; 
    long long N,M,i,j=20;
    scanf("%lld",&N);
    M=(long long)sqrt(N);
    for(i=1;i<=M+1;i++)
    {
        if(N%i==0)
        if(F(i,N/i)<j)
        j=F(i,N/i);
    }
    printf("%lld",j);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int a, b, c, d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    if(a+b+c+d == 7)cout << a << "+" << b <<"+"<<c<<"+"<<d<< "=7" << endl;
    else if(a-b+c+d == 7)cout << a << "-" << b <<"+"<<c<<"+"<<d<< "=7" << endl;
    else if(a+b-c+d == 7)cout << a << "+" << b <<"-"<<c<<"+"<<d<< "=7" << endl;
    else if(a+b+c-d == 7)cout << a << "+" << b <<"+"<<c<<"-"<<d<< "=7" << endl;
    else if(a-b-c+d == 7)cout << a << "-" << b <<"-"<<c<<"+"<<d<< "=7" << endl;
    else if(a+b-c-d == 7)cout << a << "+" << b <<"-"<<c<<"-"<<d<< "=7" << endl;
    else if(a-b+c-d == 7)cout << a << "-" << b <<"+"<<c<<"-"<<d<< "=7" << endl;
    else if(a-b-c-d == 7)cout << a << "-" << b <<"-"<<c<<"-"<<d<< "=7" << endl;
}

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

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int, int>, int> cnt;
    for (int rep = 0; rep < n; ++rep) {
        double x;
        scanf("%lf", &x);
        long long i = llround(x * 1e9);
        int two = 0, five = 0;
        while (i % 2 == 0) {
            ++two;
            i /= 2;
        }

        while (i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two, five}];
    }

    long long ans = 0;
    for (auto p1 : cnt) {
        for (auto p2 : cnt) {
            if (p1.first.first + p2.first.first >= 18 && p1.first.second + p2.first.second >= 18) {
                if (p1 < p2) {
                    ans += (long long) p1.second * p2.second;
                }else if (p1 == p2) {
                    ans += (long long)p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3852
while 1:
    n = input()
    if n == 0: break
    m = input()
    s = raw_input()
    t = "IOI" + "OI"*(n-1)
    t_len = 3 + 2 *(n-1)
    ans = 0
    for i in range(m - t_len + 1):
        if s[i:i+t_len] == t: ans += 1
    print ans

Measured memory_bytes: 38788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll t,i,j,k;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll m[a],n[b],o[c];
    for(i=0;i<a;i++)
    cin>>m[i];
    for(i=0;i<b;i++)
    cin>>n[i];
    for(i=0;i<c;i++)
    cin>>o[i];
    sort(m,m+a);
    sort(n,n+b);
    sort(o,o+c);
    i=a-x;
    j=b-y;
    k=c-1;
    
    vector<ll>p;
    for(t=0;t<c;t++)
    p.push_back(o[t]);
    for(t=i;t<a;t++)
    p.push_back(m[t]);
    for(t=j;t<b;t++)
    p.push_back(n[t]);
    sort(p.begin(),p.end());
    ll sum=0;
    x=x+y;
    i=p.size()-1;
    while(x)
    {
        sum+=p[i--];
        x--;
    }
    cout<<sum;
}

Measured memory_bytes: 8304
#include <bits/stdc++.h>
#define PRECISION(x) cout << fixed << setprecision(x); 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(i,n) for (int i = 0; i < n; ++i)
#define DO(X) while(X--)
#define DRI(X) int (X); cin >> X
#define DRII(X, Y) int X, Y; cin >> X >> Y
#define DRIII(X, Y, Z) int X, Y, Z; cin >> X >> Y >> Z
#define read(X) for(int &ele : (X)) cin >> ele
#define readI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define debug(x) cerr << '>' << #x << ':' << x << endl
#define MP make_pair
#define PB push_back
#define F first
#define S second

using namespace std;
typedef long long LL;
const int INF = 1<<29;
inline int in() { int x; cin >> x; return x; }
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }

int main(){
	FAST_IO 
	long long fNum, sNum; cin >> fNum >> sNum;
	cout << (long long)fNum * sNum / __gcd(fNum, sNum) << endl;
	return 0;
}

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

int main() {
  long n, check = 1;
  cin >> n;
  vector<int> bri(n);
  for (int i = 0; i < n; i++) {
    cin >> bri.at(i);
    check *= bri.at(i) == 1 ? 0 : 1;
  }
  if (check == 1) {
    cout << -1;
  }
  else {
    long ans = 0, num = 1;
    for (int i = 0; i < n; i++) {
      if (bri.at(i) == num) {
        num++;
      }
      else {
        ans++;
      }
    }
    cout << ans;
  }
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    for(int i=0;i<n;i++){
        if(ans<k)ans*=2;
        else ans+=k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ColorfulSubsequence
//
//  Created by Mihozil on 3/21/19.
//  Copyright © 2019 Mihozil. All rights reserved.
//

#include <iostream>
using namespace std;

long n;
long long a[28];
long long result;
#define maxD 1000000007

void solve() {
    result = 1;
    for (long i=0; i<=26; i++)
        if (a[i]>0)
            result = (result*(a[i]+1))%maxD;
    result = (result-1)%maxD;
    cout<<result;
}

void read() {
//    freopen("/Users/mihozil/Desktop/CodeJam/input.in", "r", stdin);
//    freopen("/Users/mihozil/Desktop/CodeJam/output.txt", "w", stdout);
    
    cin>>n;
    for (int i=0;i<=26; i++)
        a[i] = 0;
    
    for (int i=1; i<=n; i++) {
        char ch;
        cin>>ch;
        long no = ch - 'a';
        a[no] += 1;
        
    }
    solve();
}

int main(int argc, const char * argv[]) {
    // insert code here...
    read();
    return 0;
}


Measured memory_bytes: 256
def build_stairs(n, h)
  max = h[0]
  1.upto(n - 1) do |i|
    return 'No' if max - 1 > h[i]
    max = [max, h[i]].max
  end
  'Yes'
end

n = gets.chomp.to_i
h = gets.split.map(&:to_i)
puts build_stairs(n, h)

Measured memory_bytes: 11140
import java.io.BufferedInputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner s = new Scanner(new BufferedInputStream(System.in));
        String str = s.nextLine();

        StringBuilder sb = new StringBuilder();
        for (int i = 0;i < str.length(); i++) {
            char c = str.charAt(i);
            if (c == '0' || c == '1') {
                if (c == '0')
                sb.append('0');
                else
                sb.append('1');
            } else if (c == 'B') {
                if (sb.length() > 0)
                sb.deleteCharAt(sb.length()-1);
            }

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

}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    int x=0,ma=0;
    string s;cin>>s;
    rep(i,N){
        if(s[i]=='I')x++;
        else x--;
        chmax(ma,x);
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

mod = 10**9 + 7
bit_num = [0] * 60
bit_0 = [0] * 60
bit_1 = [0] * 60
for i in a:
    for j in range(60):
        if( (i>>j)&1 == 1 ):
            bit_num[j] += bit_0[j]
            bit_1[j] += 1
        else:
            bit_num[j] += bit_1[j]
            bit_0[j] += 1

ans = 0
for i in bit_num[::-1]:
    ans *= 2
    ans += i
    ans %= mod

print(ans)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;

int main()
{
	fast;
	ll n; cin>>n;
	string res;
    while(n > 0)
    {
        int t;
        if(n % 26 == 0)
        {
            res += 'z';
            n = (n/26)-1;
        }
        else 
        {
            t = (n % 26 + 25) % 26;
            res += (char)(t + 97);
            n /= 26;
        }
    }
    reverse(res.begin(),res.end());
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
temparr = input()
dicts = {}
dicts["W"] = 0 
dicts["R"] = 0 
for i in temparr:
    dicts[i] += 1 

if dicts["W"] == 0 or dicts["R"] == 0 :
    print(0)
else:
    arr = []
    for i in temparr:
        arr.append(i)
    count = 0 
    index = 0 
    #print(arr)
    while dicts["R"]:
        if arr[index] == 'R':
            dicts["R"] -= 1 
        else:
            dicts["R"] -= 1 
            count += 1 
        index += 1
        #print(count)
    print(count)
            
            
            
            
        
        

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    string ans = "Yes";
    if(n%2==0){
        for(int i=0;i<n/2;i++){
            if(s.at(i)!=s.at(i+(n/2))){
                ans = "No";
            }
        }
    }
    else{
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=305;

int n;
int a[N][N],b[N][N];

int main()
{

	scanf("%d",&n);
	for (int i=1;i<=n;i++) 
		for (int j=1;j<=n;j++) scanf("%d",&a[i][j]),b[i][j]=(i==j)?0:1e9+1;
	
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++) 
		{
			bool o=false;
			for (int l=1;l<=n;l++)
			if (l!=i&&l!=j) 
			{
				if (a[i][l]+a[l][j]<a[i][j]) {puts("-1");return 0;}
				if (a[i][l]+a[l][j]==a[i][j]) {o=true;break;}
			}
			if (!o) b[i][j]=b[j][i]=a[i][j];
		}
	long long ans=0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++) if (b[i][j]!=1e9+1) ans+=b[i][j];
	/*for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++) b[i][j]=min(b[i][j],b[i][k]+b[k][j]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) if (b[i][j]!=a[i][j]) {puts("-1");return 0;}*/ 
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P);
int solve();

int main(void){
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i=0;i<n;i++){
		scanf("%d",&T[i]);
	}
	llong ans=solve();
	printf("%d\n",ans);
	return 0;
}



int check(llong P){
	int i=0;
	for(int j=0;j<k;j++)
	{
		llong s=0;
		while(s+T[i]<=P)
		{
			s +=T[i];
			i++;
			if(i==n){
				return n;
			}
		}
	}
	return i;
}

int solve(){
	llong left=0;
	llong right=100000*10000;
	llong mid;
	while(right-left>1)
	{
		mid=(right+left)/2;
		int v=check(mid);
		if(v>=n){
			right=mid;
		}
		else{
			left = mid;
		}
	}
	return right;
}





Measured memory_bytes: 2636
///
// File:  alds1_2_d.cpp
// Author: ymiyamoto
//
// Created on Wed Oct  4 23:56:00 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint32_t> array;
static vector<uint32_t> G;

uint64_t insersion_sort(int64_t dist)
{
  uint64_t count = 0;
  for (uint32_t i = dist; i < array.size(); i++) {
    int32_t val = array[i];
    int32_t j = i - dist;
    while (j >= 0 && array[j] > val) {
      swap(array[j + dist], array[j]);
      count++;
      j -= dist;
    }
    array[j + dist] = val;
  }

  return count;
}

uint64_t shell_sort()
{
  uint32_t i = 1;
  while (i <= array.size()) {
    G.push_back(i);
    i = 3 * i + 1;
  }

  uint64_t count = 0;

  for (int32_t j = G.size() - 1; j >= 0; j--) {
    count += insersion_sort(G[j]);
  }

  return count;
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
  }

  uint64_t count = shell_sort();
  cout << G.size() << endl;

  for (int32_t i = G.size() - 1; i >= 0; i--) {
    if (i != G.size() - 1) cout << " ";
    cout << G[i];
  }

  cout << endl << count << endl;

  for (uint32_t i = 0; i < array.size(); i++) {
    cout << array[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 6932
#include <iostream>

#define MAX 100005

using namespace std;

struct Data {
    string name;
    int num;
};

Data d[MAX];
int head, tail, n;

void enqueue(Data t) {
    d[tail] = t;
    tail = (tail + 1) % MAX;
}

Data dequeue() {
    int temp = head;
    head = (head + 1) % MAX;
    return d[temp];
}

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

    int now = 0;

    for (int i = 0; i < n; i++) {
        cin >> d[i].name >> d[i].num;
    }

    head = 0;
    tail = n;

    while (head != tail) {
        Data tmp = dequeue();
        if (time < tmp.num) {
            tmp.num -= time;
            now += time;
            enqueue(tmp);
        } else {
            now += tmp.num;
            cout << tmp.name << " " << now << endl;
        }


    }


}

Measured memory_bytes: 7044
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}a
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
	int n;
	scanf("%d", &n);
	int k;
	scanf("%d", &k);
	vector<int> h(n);
	for (int& x:h){
		scanf("%d", &x);
	}
	vector<int> cost(n, INF);
	cost[0] = 0;
	for (int i = 0; i<n; ++i){
		for (int j = i+1; j <= i+k; ++j){
			if (j < n){
				cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", cost[n-1]);
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int mi = INF,ma = -INF;

int a;
int n;
int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%d",&a);
    mi = min(mi,a);
    ma = max(ma,a);
  }
  printf("%d\n",ma-mi);
}


Measured memory_bytes: 256
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, k = read_int_list()
    a = read_int_list()
    res = 1
    for i in range(k - 1, n - 1, k - 1):
        res += 1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  map<int, int, greater<int>> mp;
  for (int i = 0; i < n; i++) {
    mp[a[i]]++;
  }
  int edge1 = -1, edge2 = -1;
  for (auto&& [len, cnt] : mp) {
    debug(len, cnt);
    if (edge1 == -1) {
      if (cnt >= 2) {
        edge1 = len;
        cnt -= 2;
      }
    }
    if (edge2 == -1) {
      if (cnt >= 2) {
        edge2 = len;
        break;
      }
    }
  }
  if (edge1 == -1 || edge2 == -1) {
    cout << 0 << '\n';
  } else {
    cout << (long long)edge1 * edge2 << '\n';
  }
  debug(edge1, edge2);
  return 0;
}

Measured memory_bytes: 8128
#include<bits/stdc++.h>
 using namespace std;
 
 int main()
 {
  
  vector<int> dai(5),amari(5),sa(5);
   int i,j,k,x,m,ans;
   for(i=0;i<5;i++)
       {
         cin >> x ;
         dai[i]=x;
         amari[i]= dai[i]%10;
         if(amari[i]==0)
         {
           sa[i]=0;
         }
     else
     {
       sa[i]=10-amari[i];
     }
   ans += dai[i]+sa[i];
       }
   m=max(max(max(max(sa[0],sa[1]),sa[2]),sa[3]),sa[4]);
   cout << ans-m << endl ;
 }

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

const int dx[] = {0, 0, 1, -1};
const int dy[] = {-1, 1, 0, 0};
int W, H;
char board[30][30];

int dfs(int y, int x) {
   board[y][x] = '#';
   int ret = 1;
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < H && nx >= 0 && nx < W && board[ny][nx] == '.') {
         ret += dfs(ny, nx);
      }
   }
   return ret;
}

int main() {
   while (cin >> W >> H, W) {
      for (int i = 0 ; i < H; i++) {
         cin >> board[i];
      }

      for (int i = 0 ; i < H; i++) {
         for (int j = 0 ; j < W; j++) {
            if (board[i][j] == '@') {
               cout << dfs(i, j) << endl;
            }
         }
      }
   }

   return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int n,a,b,c;
	cin >> n;
	int A[n],B[n],C[n];
	cin >> a;
	
	for(int i = 0;i<a;i++){
		cin>>A[i];
	}

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

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

	int count = c;

	for(int i = 0;i<a;i++){
		for(int j = 0;j<b;j++){
			if(A[i]==B[j]){
				A[i]=n+1;
			}
		}
	}

	for(int i = 0;i<c;i++){
		for(int j = 0;j<a;j++){
			if(A[j]==C[i]){
				count--;
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3136
#include<cstdio>
const int mod=998244353;
int n;
char s[200010];
int main(){
	int cnt=0,sum=0,ans;
	for(scanf("%s",s);s[n];n++){
		if(n&&s[n-1]!=s[n])cnt++;
		(sum+=s[n]-'a')%=3;
	}
	if(!cnt)ans=1;
	else{
		int pw=ans=1;
		for(int i=1;i<n;i++)pw=pw*2ll%mod,ans=ans*3ll%mod;
		ans=(ans+mod-pw+(cnt==n-1))%mod;
		if(n%3==0){
			pw=1;
			for(int i=1;i<n/3;i++)pw=pw*2ll%mod;
			if(!sum)pw=((mod-pw)*2ll+(n==3?mod-1:0))%mod;
			ans=(ans+pw)%mod;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      
      	int r = 0;
      	while(n > 0){
          n -= 1000;
        }
      
         
      	if(n < 0)
          n *= -1;
      
      	System.out.print(n);
    }
}

Measured memory_bytes: 27068
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



Measured memory_bytes: 2744
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    string s;
    cin >> s;
    int ans = INF;
    REP(i,0,s.size()-2){
        int sum = (int)(s[i] - '0') * 100 + (int)(s[i+1] - '0') * 10 + (int)(s[i+2] - '0');
        if (abs(ans) > abs(sum - 753)) ans = abs(sum - 753);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if( a + b > c + d ) {
		cout << "Left" << endl;
	} else if( a + b == c + d ) {
		cout << "Balanced" << endl;
	} else {
		cout << "Right" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3592