akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

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

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


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


// Constants

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


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

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

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

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

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



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

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n=in();
  vi b(n-1);
  rep(i,n-1) cin>>b[i];

  ll ret = b[0];
  rep(i,1,n-1){
    ret += min(b[i-1],b[i]);
  }
  ret += b[n-2];
  cout << ret << endl;
  return 0;
}


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

def find_array(N: int, Y: int):
    for a in range(N + 1):
        for b in range(N - a + 1):
            c = N - a - b
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return [a, b, c]
    return [-1, -1, -1]

def solve(N: int, Y: int):
    array = find_array(N, Y)
    print(' '.join(map(str,array)))
    return


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

if __name__ == '__main__':
    main()


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

using ll = long long int;

int main() {
    ll n;
    cin >> n;
    if(n & 1){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        n /= 2;
        while(n > 0){
            ans += n/5;
            n /= 5;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector < int > Solve(int n, int fn)
{
    if (n == 1)
        return (vector < int > {0, 1});
    if ((fn >> n - 1) & 1)
    {
        int md = (1 << n - 1) ^ 1;
        if (fn == md) md ^= 3;
        vector < int > R1 = Solve(n - 1, md ^ (1 << n - 1));
        vector < int > R2 = Solve(n - 1, fn ^ md);
        for (int r : R2)
            R1.push_back(r ^ md);
        return (R1);
    }
    vector < int > R1 = Solve(n - 1, fn);
    vector < int > R2 = Solve(n - 1, R1[1]);
    vector < int > R = {R1[0]};
    for (int r : R2)
        R.push_back(r ^ (1 << n - 1));
    for (int r : R1)
        if (r)
            R.push_back(r);
    return (R);
}
int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    if (!(__builtin_popcount(b ^ a) & 1))
        return !printf("NO");
    vector < int > R = Solve(n, b ^ a);
    printf("YES\n");
    for (int r : R)
        printf("%d ", r ^ a);
    return 0;
}

Measured memory_bytes: 2064
from collections import defaultdict

INF = 999999999999999999999

def bellman_ford(G, n):
  d = {}
  for i in range(n):
    d[i] = {}
    for j in range(n):
      if i in G and j in G[i]:
        d[i][j] = G[i][j]
      else:
        d[i][j] = INF
    d[i][i] = 0
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if d[i][k] == INF or d[k][j] == INF:
          continue
        if d[i][j] > d[i][k] + d[k][j]:
          d[i][j] = d[i][k] + d[k][j]
  return d

G = {}

n, m = [int(v) for v in input().strip().split(' ')]
for i in range(n):
  G[i] = {}
for _ in range(m):
  s, t, c = [int(v) for v in input().strip().split(' ')]
  G[s][t] = c

d = bellman_ford(G, n)

for i in range(n):
  if d[i][i] < 0:
    print("NEGATIVE CYCLE")
    exit()

for i in range(n):
  print(" ".join([str(d[i][j]) if d[i][j] != INF else "INF" for j in range(n)]))

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

using namespace std;

typedef long long LL;

const int N = 100003;

int n, m, a[5][5];
char s[N];
bool st[5][5];

int main()
{
    for (int i = 1; i <= 3; i+=1)
        for (int j = 1; j <= 3; j+=1)
            cin >> a[i][j];
    cin >> n;
    for (int i = 1; i <= n; i+=1)
    {
        int u; cin >> u;
        for (int j = 1; j <= 3; j+=1)
            for (int k = 1; k <= 3; k+=1)
                if (a[j][k] == u)
                    st[j][k] = true;
    }
    if (st[1][1] && st[1][2] && st[1][3]) puts("Yes");
    else if (st[2][1] && st[2][2] && st[2][3]) puts("Yes");
    else if (st[3][1] && st[3][2] && st[3][3]) puts("Yes");
    else if (st[1][1] && st[2][1] && st[3][1]) puts("Yes");
    else if (st[1][2] && st[2][2] && st[3][2]) puts("Yes");
    else if (st[1][3] && st[2][3] && st[3][3]) puts("Yes");
    else if (st[1][1] && st[2][2] && st[3][3]) puts("Yes");
    else if (st[1][3] && st[2][2] && st[3][1]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    ll x; cin>>x;
    for(ll i = -118; i < 120; i++){
        for(ll j = -119; j < 119; j++){
           
            if(i*i*i*i*i - j*j*j*j*j == x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";

    // 1回目の往路
    for (int i = 1; i <= ty - sy; i++) ans += "U";
    for (int j = 1; j <= tx - sx; j++) ans += "R";

    // 1回目の復路
    for (int i = 1; i <= ty - sy; i++) ans += "D";
    for (int j = 1; j <= tx - sx; j++) ans += "L";

    // 2回目の往路
    ans += "L";
    for (int i = 1; i <= ty - sy + 1; i++) ans += "U";
    for (int j = 1; j <= tx - sx + 1; j++) ans += "R";
    ans += "D";

    // 2回目の復路
    ans += "R";
    for (int i = 1; i <= ty - sy + 1; i++) ans += "D";
    for (int j = 1; j <= tx - sx + 1; j++) ans += "L";
    ans += "U";

    cout << ans << endl;
    return 0;
}

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

int main() {

    string s ;
    cin >> s  ;

    int ans[3] ;
    ans[0] = ans[2] = ans[1] = 0 ; 
    for (int i = 0; i < 3; i++)
    {
        if(s[i]=='a') ans[0] += 1 ;
        if(s[i]=='b') ans[1] += 1 ;
        if(s[i]=='c') ans[2] += 1 ;
    }
    
    bool Answer = false ;
    if(ans[0]==1 && ans[1]==1 && ans[2]==1) Answer = true ;

    if(Answer)
     cout << "Yes" << endl ;
    else 
     cout << "No" << endl ;     

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto C = RD;
	
	writeln(B - A == C - B ? "YES" : "NO");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, C;
	cin >> N >> C;

	int A[400], B[400];
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	ll dp[401] = {};
	dp[0] = 1;
	ll mod = 1e9 + 7;

	ll AB[401][401];
	rep1(i, 400) {
		AB[i][0] = 1;
		rep(j, 400) {
			AB[i][j + 1] = AB[i][j] * i % mod;
		}
	}
	rep(j, 401) {
		AB[0][j] = 0;
		rep(i, 400) {
			AB[i + 1][j] = (AB[i + 1][j] + AB[i][j]) % mod;
		}
	}

	rep(i, N) {
		for (int j = C; j >= 0; j--) {
			dp[j] %= mod;
			for (int k = C - j; k >= 0; k--) {
				dp[j + k] += dp[j] * (AB[B[i]][k] - AB[A[i] - 1][k] - !k) % mod;
			}
		}
	}

	co((dp[C] % mod + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	int tak = a/d;
	if(a%d) tak++;
	int aok = c/b;
	if(c%b) aok++;
	cerr<<aok SP tak << endl;
	if(aok<=tak) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

int main() {
  int a, b, c, x, s = 0;
  cin >> a >> b >> c >> x;
  x /= 50;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        if(i*10+j*2+k == x) ++s;
      }
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
L = list(map(int,input().split()))
L = sorted(L)
a = L[0]
b = L[1]
c = L[2]
ans = 0
ans += (c-a)//2 + (c-b)//2
if ((c-a)%2) == 0 and ((c-b)%2) == 0 :
    print(ans)
elif ((c-a)%2) == 1 and ((c-b)%2) == 1 :
    print(ans+1)
else :
    print(ans+2)
    

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    Int N;
    vector<vector<Int>> treeone;
    vector<Int> bdist, wdist;

    void compute_dist(Int v, vector<Int> &dist, Int d = 0, Int p = -1) {
        dist[v] = d;
        for (auto e : treeone[v]) {
            if (e != p) {
                compute_dist(e, dist, d + 1, v);
            }
        }
    }

    void solve() {
        cin >> N;
        treeone.resize(N);
        bdist.resize(N, -1);
        wdist.resize(N, -1);
        for (int i = 1; i < N; ++i) {
            Int a, b;
            cin >> a >> b;
            a--, b--;
            treeone[a].push_back(b);
            treeone[b].push_back(a);
        }

        compute_dist(0, bdist);
        compute_dist(N - 1, wdist);

        Int B = 0, W = 0;
        for (int i = 0; i < N; ++i) {
            if (bdist[i] <= wdist[i]) {
                B++;
            } else {
                W++;
            }
        }
        if (W >= B) {
            cout << "Snuke" << endl;
        } else {
            cout << "Fennec" << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


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

int N, M;
int s[10][10];
int p[10];
int k[10];

int main() {
    std::cin >> N >> M;

    for (int i = 0; i < M; ++i) {
        std::cin >> k[i];
        for (int j = 0; j < k[i]; ++j) {
            std::cin >> s[i][j];
        }
    }
    
    for (int i = 0; i < M; ++i) {
        std::cin >> p[i];
    }

    int cnt = 0;
    for (int i = 0; i < (1 << N); ++i) {
        int on[N] = {0};
        for (int j = 0; j < N; ++j) {
            on[j] = ((i >> j) & 1ul);
        }

        bool ok = true;
        for (int j = 0; j < M; ++j) {
            int on_cnt = 0;
            for (int l = 0; l < k[j]; ++l) {
                on_cnt += on[s[j][l] - 1];
            }

            if (on_cnt % 2 != p[j]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ++cnt;
        } 
    }

    std::printf("%d\n", cnt);

    return 0;
}


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


int main(){

   char buf[1010];
   fgets(buf,1010,stdin);

   for(int i=0;buf[i] != '\0';i++){
	 if(i >= 4 && buf[i] == 'e' && buf[i-1] == 'l' && buf[i-2] == 'p' &&
			   buf[i-3] == 'p' && buf[i-4] == 'a'){
		   buf[i-4] = 'p';
		   buf[i-3] = 'e';
		   buf[i-2] = 'a';
		   buf[i-1] = 'c';
		   buf[i] = 'h';
	   }else if(i >= 4  && buf[i] == 'h' && buf[i-1] == 'c' && buf[i-2] == 'a' &&
			   buf[i-3] == 'e' && buf[i-4] == 'p'){
		   buf[i-4] = 'a';
		   buf[i-3] = 'p';
		   buf[i-2] = 'p';
		   buf[i-1] = 'l';
		   buf[i] = 'e';
	   }
   }

   printf("%s",buf);

    return 0;
}



Measured memory_bytes: 2580
function Main(input) {
    lines = input.split('\n')
    line = lines[0].split(" ");
    n = parseInt(line[0]);
    m = parseInt(line[1]);
    if (n < 10 && m < 10) {
        console.log(n * m);
    } else {
        console.log(-1);
    }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main(require("fs").readFileSync("test.txt", "utf8"));

Measured memory_bytes: 7372
import math

def prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if  n % i == 0:
            return False
    return True

num_prime = []
k = 0
while True:
    try:
        n = input()
    except:
        break
    if prime(int(n)):
        if not int(n) in num_prime:
            k += 1
            num_prime.append(int(n))

print(k)

Measured memory_bytes: 7684
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    string c;
    cin >> c;

    int cr = 0;
    REP(i, c.size()) {
        if (c[i] == 'R') cr++;
    }

    int cw = N - cr;

    int ans = min(cr, cw);

    int cnt = 0;
    REP(i, cr) {
        if (c[i] == 'W') cnt++;
    }

    print(min(ans, cnt));
    
}


Measured memory_bytes: 3776
n, a, b = map(int, input().split())
 

def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
        
    return bunshi*pow(bunbo, mod-2, mod)%mod
        
        
mod = 1000000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)

Measured memory_bytes: 3064
#include <iostream>

int main()
{
    using ll = long long;
    ll n = 0;
    std::cin >> n;

    ll a = 0;
    std::cin >> a;

    ll b = 0;
    std::cin >> b;

    const auto sum = a + b;
    const auto repeat = n / sum;
    auto blueCount = a * repeat;

    const auto rest = n % sum;
    if (rest <= a)
    {
        blueCount += rest;
    }
    else
    {
        blueCount += a;
    }

    std::cout << blueCount;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
h,w=map(int,input().split())
s=[]
wall_num=0
for i in range(h):
    s.append(list(input()))
    wall_num+=s[i].count("#")

q=deque()

i=0
j=0
s[0][0]=0
q.appendleft([0,0])
while(len(q)>0):
    qi=q.popleft()
    j,i=qi[0],qi[1]
    num=s[j][i]
    if(i==w-1 and j==h-1):
        print(h*w - wall_num - num - 1)
        sys.exit()
    if(i>0 and s[j][i-1]=="."):
        s[j][i-1]=num+1
        q.append([j,i-1])
    if(i<w-1 and s[j][i+1]=="."):
        s[j][i+1]=num+1
        q.append([j,i+1])
    if(j>0 and s[j-1][i]=="."):
        s[j-1][i]=num+1
        q.append([j-1,i])
    if(j<h-1 and s[j+1][i]=="."):
        s[j+1][i]=num+1
        q.append([j+1,i])

print(-1)

Measured memory_bytes: 3316
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
        	int a = sc.nextInt();
        int b = sc.nextInt();
        if (a==0 && b==0) break;
        for (int i=0; i<a; i++) {
        		for(int j=0; j<b;j++) {
        			System.out.print("#");
        			if(j == b-1) System.out.println();
        		}
        		if(i == a-1) System.out.println();
        }
        }
    }
}


Measured memory_bytes: 34756
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    map<ll, int> cnt;
    for (int i = 0; i < n; ++i) {
        ll a; cin >> a;
        cnt[a]++;
    }

    bool ok;
    for (auto e: cnt) {
        if (e.second > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 12800
import itertools
n,m = map(int,input().split())

nc2 = n*(n-1)/2 
mc2 = m*(m-1)/2

if n == 1 or n == 0:
    nc2 = 0
if m == 1 or m == 0:
    mc2 = 0
print(int(nc2+mc2))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int n = s.length();
    reverse(s.begin(), s.end());
    int v = 0, p = 1;
    vector<int> c(2019, 0);
    c[0] = 1;
    long long ans = 0;
    for(int i=0;i<n;i++){
        v += (s[i]-'0') * p;
        v %= 2019;
        ans += c[v]++;
        p *= 10;
        p %= 2019;
        // cout << v << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define INFL 1000000000000000018
#define MOD 1000000007
#define MAXN 200005
#define MAXM 200005

ll n, k, t[MAXN], s, ans;

int main()
{
    cin >> n >> k;
    REP(i, 0, n){
        cin >> t[i];
        if(t[i] > t[i - 1] + k && i > 0){
            ans += t[i - 1] + k - s;
            s = t[i];
        }
        if(i == n - 1){
            ans += t[i] + k - s;
        }
    }
    cout << ans << endl;


    return 0;
}
/*
*/





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

int matrixChainMultiplication(int *p, int n) {
  int m[n+1][n+1];
  for (int i = 0; i <= n; i++) m[i][0] = 0;
  for (int j = 0; j <= n; j++) m[0][j] = 0;
  for (int i = 1; i <= n; i++) m[i][i] = 0;

  for (int l = 2; l <= n; l++) {
    //対象とする行列の数
    for (int i = 1; i <= n-l+1; i++) {
      //左端の行列
      int j = i + l - 1;
      //右端の行列
      m[i][j] = INF;
      for (int k = i; k <= j-1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  //上のループで、DPテーブル対角線上のゼロに近接するマスが順に埋まっていく
  //最終的に右端のm[1][n]がM1M2...Mnを計算する際の最小計算回数になる

  return m[1][n];
}

int main() {
  int n;
  cin >> n;
  int p[n+1];
  for (int i = 1; i <= n; i++) cin >> p[i-1] >> p[i];
  cout << matrixChainMultiplication(p, n) << endl;
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)

int main()
{
    int N, A, B, C = 0;
    cin >> N;

    int M[9][9] = {};
    REP(i, 9)
    {
        REP(j, 9)
        {
            int _i = i + 1;
            int _j = j + 1;
            int l, count = 0;
            l = (int)floor(log10(N));
            REP(k, l + 1)
            {
                if (k == 0)
                {
                    if (_i == _j && _i <= N)
                    {
                        count++;
                    }
                }
                else
                {
                    int diff = N - (_i * (int)pow(10, k) + _j);
                    if (diff >= (int)pow(10, k) - 10)
                    {
                        count += pow(10, k - 1);
                    }
                    else if (diff >= 0)
                    {
                        count += (int)(diff / 10) + 1;
                    }
                }
            }
            M[i][j] = count;
        }
    }

    REP(i, 9)
    {
        REP(j, 9)
        {
            C += M[i][j] * M[j][i];
            // cout << M[i][j] << " ";
        }
        // cout << endl;
    }

    cout << C << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 2730: Line Gimmick
// 2017.10.27 bal4u@uu
#include <stdio.h>
#include <stdlib.h>

char buf[100002];

int main()
{
	int n, i, j;

	fgets(buf, 20, stdin); n = atoi(buf);
	fgets(buf, 100002, stdin);
	i = 0;   while (buf[i] == '<') i++;
	j = n-1; while (buf[j] == '>') j--;
	if (i > n-1-j) i = n-1-j;
	printf("%d\n", n-i);
	return 0;
}

Measured memory_bytes: 1940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

int n;
long long m;
long long sum[300000];
long long c[300000];
long long d[300000];

int lowbit(int x){
	return x & -x;
}

void update(int x){
	while (x<=n+10){
		c[x]+=1;
		x+=lowbit(x);
	}
}

int query(int x){
	int s=0;
	while (x>0){
		s+=c[x];
		x-=lowbit(x);
	}
	return s;
}

struct o_O{
	long long b;
	int d;
}p[600000];

bool cmp(o_O a,o_O b){
	return a.b<b.b;
}

int main(){
	scanf("%d%lld",&n,&m);
	long long w;
	sum[0]=0;
	for (int i=1;i<=n;i++){
		scanf("%lld",&w);
		sum[i]=sum[i-1]+w;
	}
	for (int i=0;i<=n;i++){
		sum[i]=sum[i]-m*i;
		p[i].b=sum[i];
		p[i].d=i;
	}
	sort(p,p+n+1,cmp);
	sum[p[0].d]=1;
	int n1=1;
	for (int i=1;i<=n;i++){
		if (p[i].b==p[i-1].b){
			sum[p[i].d]=n1;
		}else {
			n1++;
			sum[p[i].d]=n1;
		}
	}
	memset(c,0,sizeof(c));
	long long ans=0;
	for (int i=0;i<=n;i++){
		ans+=query(sum[i]);
		update(sum[i]); 
	}
	printf("%lld",ans);
	return 0;
} 

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main(){
    ll a,b;
    cin >> a >> b;
    cout  << a*b << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string S = strArray[0];
            string T = strArray[1];
            string ans = "";
            for(int i = 0; i < N; i++)
            {
                ans += S[i];
                ans += T[i];
            }
            Console.WriteLine(ans);
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27668
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n, k;in(n),in(k);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  // if (k==0) {
  //   ll max_ = 0;
  //   for (auto&&a: A) max_ = max(max_, a);
  //   print(max_);
  //   return 0;
  // }
  
  auto f = [&](ll x) {
    ll kk = k;
    for (auto &&a: A) {
      ll d = (a-1)/x;
      if (kk < d) return false;
      kk -= d;
    }
    return true;
  };
  ll ng = 0, ok = 100000000000;
  while (ng + 1 < ok) {
    ll mid = (ng+ok)/2;
    if (f(mid)) ok = mid;
    else ng = mid;
  }
  print(ok);
  return 0;
}


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

vector<int> a(55), b(55), c(55), d(55);
int n, m, q;
int ans = -1;
void dfs(string s, int cur) {
    if (s.size() == n) {
        int sum = 0;
        for (int i = 0; i < q; i++) {
            int Ab = s[b[i] - 1] - '0';
            int Aa = s[a[i] - 1] - '0';
            if (Ab - Aa == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    for (int i = cur; i <= m; i++) {
        char c = i + '0';
        dfs(s + c, i);
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs("1", 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
while True:
    n, x = map(int, input().split(" "))
    count = 0
    if n == x ==0:
        break
    for i in range(1,n-1):
        for j in range(2, n):
            for k in range(3, n+1):
                if i < j < k and i + j + k ==x:
                    count += 1
    print(count)


Measured memory_bytes: 5592
n = gets.to_i
h = gets.chomp.split.map(&:to_i)

move = Array.new(n, 0)

(1..n).each do |i|
  mi = -i
  if mi == -1 then
    move[mi] = 0
    next
  end

  if h[mi] >= h[mi + 1] then    
    move[mi] = move[mi + 1] + 1
    next
  end

  move[mi] = 0
end

puts move.max


Measured memory_bytes: 10500
n = int(input())
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        print(2*a-2)
    else:
        c = int((a*b)**0.5)
        if c**2 == a*b:
            c -= 1
        if c*(c+1) >= a*b:
            print(2*c-2)
        else:
            print(2*c-1)

Measured memory_bytes: 3060
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
s, t = input().split()
a, b = gi()
u = input()
if u == s:
	print(a - 1, b)
elif u == t:
	print(a, b - 1)
else:
	print(a, b)

Measured memory_bytes: 3064
s=list(input())
t=input()
n,m=len(s),len(t)
def match(a,b):
    for i in range(len(a)):
        if a[i]!=b[i] and a[i]!="?":
            return False
    return True
flag=True
for i in range(n-m,-1,-1):
    if match(s[i:i+m],t):
        for j in range(m):
            s[j+i]=t[j]
        flag=False
        break
if flag:
    print("UNRESTORABLE")
    exit()
for i in range(n):
    if s[i]=="?":
        s[i]="a"
print(*s,sep="")

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

void solve() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vi32 sums(n + 1);
  rep(i, n - 1) {
    if (s.substr(i, 2) == "AC") sums[i + 2] = 1;
  }
  rep(i, n) sums[i + 1] += sums[i];
  rep(_, q) {
    int l, r;
    cin >> l >> r;
    cout << sums[r] - sums[l] << endl;
  }
}


Measured memory_bytes: 1488
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 5;
 
char s[1000];
int main () {
	int n;
	scanf("%d", &n);
	getchar();
	for(int i = 0; i < 2 * n - 1; i++) scanf("%c", &s[i]);
	int flag = 0;
	for(int i = 0; i < strlen(s); i += 2) 
		if(s[i] == 'Y') flag = 1;
	if(flag) printf("Four\n");
	else printf("Three\n");
	return 0;
}

Measured memory_bytes: 256
msum k l s x x' =
  if l >= k
  then  s `seq` x `seq` s:(msum k (l-1) s' (tail x) (tail x'))
  else []
  where
    s' = (s - (head x) + (head x'))

ans' n k x =
  let s = sum $ take k x
      x'= drop k x
      y = msum k n s x x'
  in
    maximum y

ans (l:ls) =
  if n == 0 && k == 0
  then []
  else (ans' n k x):(ans r)
  where
    [n,k] = map read $ words l :: [Int]
    x = map read $ take n ls :: [Int]
    r = drop n ls

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ print o



Measured memory_bytes: 34620
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x=int(readline())

    l=0
    r=10**9
    while l<r-1:
        m=(l+r)//2
        if m*(m+1)//2>=x:
            r=m
        else:
            l=m

    print(r)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n,dice[3],hold,sum,i;
  char order[6];
  scanf("%d",&n);
  while(n>0){
    sum=1;
    dice[0]=1; //up
    dice[1]=2; //front
    dice[2]=3; //right
    for(i=0;i<n;i++){
      scanf("%s",order);
      switch (order[0]) {
        case 'N':
        hold=dice[0];
        dice[0]=dice[1];
        dice[1]=7-hold;
        sum+=dice[0];
        break;
        case 'E':
        hold=dice[0];
        dice[0]=7-dice[2];
        dice[2]=hold;
        sum+=dice[0];
        break;
        case 'W':
        hold=dice[0];
        dice[0]=dice[2];
        dice[2]=7-hold;
        sum+=dice[0];
        break;
        case 'S':
        hold=dice[0];
        dice[0]=7-dice[1];
        dice[1]=hold;
        sum+=dice[0];
        break;
        case 'R':
        hold=dice[1];
        dice[1]=dice[2];
        dice[2]=7-hold;
        sum+=dice[0];
        break;
        case 'L':
        hold=dice[1];
        dice[1]=7-dice[2];
        dice[2]=hold;
        sum+=dice[0];
        break;
      }
    }
    printf("%d\n",sum);
    scanf("%d",&n);
  }
  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 100'000
i64 N, M;

int main() {
    cin >> N >> M;
    vector<i64> H(N);
    REP(i, N) cin >> H[i];
    vector<bool> good(N, true);

    i64 a, b;
    REP(i, M) {
        cin >> a >> b;
        a--; b--;
        if (H[a] <= H[b]) good[a] = false;
        if (H[b] <= H[a]) good[b] = false;
    }

    i64 cnt = 0;
    REP(i, N) {
        if (good[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3992
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	makefact(2000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	ll s=0;
	rep(i,0,m+1)s=(s+choose(m,i,MOD)*pom(i,n,MOD)*((m-i)%2==0?1:-1))%MOD;
	s=s*invfact[m]%MOD;
	printf("%lld\n",(s+MOD)%MOD);
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define ALL(x) x.begin(), x.end()

int K;
vl cand;

ll S(ll x) {
    ll res = 0;
    while (x) {
        res += x%10;
        x /= 10;
    }
    return res;
}

ld T(ll x) {
    return (ld)x/S(x);
}

int main() {

    ll k = 1;
    ll n = 0;
    REP (i, 15) {
        FOR (a, 1, 200) cand.push_back(a*k+n);
        k *= 10;
        n = n * 10 + 9;
    }

    sort(ALL(cand));

    cin >> K;
    int i = 0;
    while (K) {
        // if (cand[i] > 1e15) break;
        if (cand[i] == cand[i+1]) {
            i++;
            continue;
        }
        bool res = true;
        FOR (j, i+1, cand.size()) {
            res &= (T(cand[i]) <= T(cand[j]));
        }
        if (res) {
            cout << cand[i] << endl;
            K--;
        }
        i++;
    }
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args){
		int S, h, m, s;
			String buf;
			try{
			BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
				buf = br.readLine();
				S = Integer.parseInt(buf);
				h = S/3600;
				m = (S % 3600) / 60;
				s = (S % 3600) % 60;
				System.out.print(h + ":" + m + ":" + s);
		  		System.out.print("\n");
		  } catch (Exception e){
		  }
	}
}

Measured memory_bytes: 24144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
struct node
{
    char s;
    char v;
};
void bubble(struct node a[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>=i+1;j--)
        {
            if(a[j].v<a[j-1].v)
            {
                node t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}
void selection(struct node a[],int n)
{
    for(int i=0;i<n;i++)
    {
        int mn=i;
        for(int j=i;j<n;j++)
        {
            if(a[j].v<a[mn].v)
                mn=j;
        }
        node t=a[i];
        a[i]=a[mn];
        a[mn]=t;
    }
}
void trace(int n,struct node a[])
{
    for(int i=0;i<n;i++)
    {
        if(i)
            cout<<" ";
        cout<<a[i].s<<a[i].v;
    }
    cout<<endl;
}
int check(struct node a[],struct node b[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(a[i].s!=b[i].s)
            return 0;
    }
    return 1;
}
int main()
{
    int n;
    char c;
    node c1[105],c2[105];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c1[i].s>>c1[i].v;
    }
    for(int i=0;i<n;i++)
    {
        c2[i]=c1[i];
    }
    bubble(c1,n);
    selection(c2,n);
    trace(n,c1);
    cout<<"Stable"<<endl;
    trace(n,c2);
    if(check(c1,c2,n))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
    return 0;
}



Measured memory_bytes: 3124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	for i := 1; i <= 9; i++ {
		if 111*i >= n {
			fmt.Println(111 * i)
			break
		}
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
string s[110];
map<string, int> mp;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  int no = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    if (mp[s[i]]) no = 1;
    mp[s[i]]++;
    if (i) {
      if (s[i][0] != s[i-1].back()) no = 1;
    }
  }
  cout << (no ? "No" : "Yes") << endl;

  return 0;
}

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

b=max(a)
d=b/2

c=abs(d-a[0])
#print(c)
if a[0]==b:
  c=99999
ans=a[0]
for i in a:
  #print(abs(i-d))
  if i==b:
    continue
  if abs(i-d)<c:
    ans=i
    c=abs(i-d)
    
print(b,end=" ")
print(ans)

Measured memory_bytes: 62704
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int r;


int main() {
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	} else if (r < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        ll sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (modpow(2, i, MOD) * ((sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int h,w,n; cin>>h>>w>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  vector<vector<int>> ans(h, vector<int>(w));
  int cnt=0;
  rep(i, h) {
    rep(j, w) {
      if (a[cnt]==0) cnt++;
      ans[i][j]=cnt+1;
      a[cnt]--;
    }
  }
  rep(i, h) {
    if (i%2==1) {
      reverse(ans[i].begin(), ans[i].end());
    }
  }
  rep(i, h) {
    rep(j, w) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}


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

int n,A,B,a[100000];

bool check(int cnt) {
	int t=0;
	for(int i=0;i<n;i++) if(a[i] > 1ll*cnt*B) {
		t += (a[i]-cnt*B + (A-B)-1) / (A-B);
		if(t > cnt) return false;
	}
	return true;
}
int main() {
	scanf("%d%d%d",&n,&A,&B);
	for(int i=0;i<n;i++) scanf("%d",a+i);

	int lo=0,up=1e9;
	while(up-lo>1) {
		int md=(lo+up)>>1;
		if(check(md)) up=md;
		else lo=md;
	}
	printf("%d\n",up);

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==7 && b==5 && c==5)
    {
        printf("YES\n");
    }
    else if(a==5 && b==7 && c==5)
    {
        printf("YES\n");
    }
    else if(a==5 && b==5 && c==7)
    {
        printf("YES\n");
    }
    else
        printf("NO\n");
    return 0;
}



Measured memory_bytes: 128