akhauriyash/Code-Regression huggingface dataset:
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto s = sread();
    auto tmp = new long[](4); //北西南東
    foreach (i; 0 .. s.length)
    {
        if (s[i] == 'N')
        {
            tmp[0] = 1;
        }
        else if (s[i] == 'W')
        {
            tmp[1] = -1;
        }
        else if (s[i] == 'S')
        {
            tmp[2] = -1;
        }
        else if (s[i] == 'E')
        {
            tmp[3] = 1;
        }
    }
    // writeln(tmp);
    if (tmp[0] + tmp[2] == 0 && tmp[1] + tmp[3] == 0)
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main(){
	int Times[5];
	int Mods[5];
	int score = 10;
	int num = 0;
	for(int i = 0;i < 5;i++){
		cin >> Times[i];
		Mods[i] = Times[i] % 10;
		if(score > Mods[i])
			if(Mods[i] != 0){
				score = Mods[i];
				num = i;
			}
	}
	int res = 0;
	for(int i = 0;i < 5;i++){
		if(i != num){
			res += (Times[i] + 9) / 10;
		}
	}
	res *= 10;
	res += Times[num];

	cout << res <<endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    private long fac[];
    private long finv[];
    private long inv[];
    private static int MAX_LEN = 1000001;
    private static int MOD = 1000000007;
    public static void main(String[] args) {
        Main main = new Main();
        main.COMinit();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        if (N == 1) {
            System.out.println(0);
            return;
        }
        // 0-9の全組み合わせ
        long ans = pow(10, N, MOD);
        // 1-8でできる全組み合わせ
        ans -= pow(8, N, MOD);
        if (ans < 0) {
            ans += MOD;
        }
        // 0をi箇所置いて、それ以外を1-8とする組み合わせ
        long sum = 0;
        for (int i = 1; i <= N; i++) {
            long t = pow(8, N-i, MOD);
            long com = COM(N, i);
            t = t * com;
            t %= MOD;
            sum += t;
            sum %= MOD;
        }
        sum *= 2;
        sum %= MOD;
        ans -= sum;
        if (ans < 0) {
            ans += MOD;
        }
        System.out.println(ans);
    }
    private long pow(long base, long count, long mod) {
        if (count == 0) {
            return 1;
        }
        if (count % 2 == 1) {
            long t = base * pow(base, count-1, mod);
            t %= mod;
            return t;
        }
        long t = pow(base, count / 2, mod);
        t *= t;
        t %= mod;
        return t;
    }
    void COMinit() {
        this.fac = new long[MAX_LEN];
        this.finv = new long[MAX_LEN];
        this.inv = new long[MAX_LEN];
        this.fac[0] = this.fac[1] = 1;
        this.finv[0] = this.finv[1] = 1;
        this.inv[1] = 1;
        for (int i = 2; i < MAX_LEN; i++) {
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }
    long COM(int n, int k) {
        if (n < k) {
            return 0;
        };
        if (n <0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k]%MOD)%MOD;
    }
}


Measured memory_bytes: 75860
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int n,x;
  while(cin >> n >> x && (n!=0 || x!=0)){
    int ans=0;
    rep(i,1,n+1){
      rep(j,i+1,n+1){
        rep(k,j+1,n+1){
          if(i+j+k==x) ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5;
pair<int,int> a[N];
int main(int argc, char const *argv[])
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		a[i] = {x,i+1};	
	}
	sort(a, a+n);
	for (int i = 0; i < n; ++i)
	{
		cout << a[i].second << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#define M 10000
int isprime(int);//0 =true ,1 = false

int main()
{
	int x[M], i = 0,v,limit,count=0;
	scanf("%d", &limit);
	for(i=0;i<limit;i++){
		scanf("%d", &x[i]);
		if (i == M-1)break;
	}
	for (v = 0; v <= i; v++) {
		if (isprime(x[v]) == 0) {
			count++;
		}
		
	}
	printf("%d\n", count);
	return 0;
}

int isprime(int x)
{
	int v,w,i=3,sec=0;
	v = x % 2;
	if (x == 2)return 0;
	if (x < 2 || v == 0)return 1;
	while (sec * sec <= x)sec++;
	while (i <= sec) {
		w = x % i;
		if (w == 0)return 1;
		i += 2;
	}
	return 0;
}




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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;
class UnionFind {
  private:
    size_t num;
    vector<size_t> par;
    vector<size_t> sizes;
    vector<size_t> rank;

  public:
    UnionFind(size_t num = 0) : num(num) {
        par.resize(num);
        sizes.resize(num);
        rank.resize(num);
        for (size_t i = 0; i < num; i++) {
            par[i] = i;
            sizes[i] = 1;
            rank[i] = 0;
        }
    }
    ~UnionFind() {}

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

    void unite(size_t x, size_t y) {
        size_t rx = root(x);
        size_t ry = root(y);
        if (rx == ry)
            return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        } else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) {
                rank[rx]++;
            }
        }
        size_t temp = sizes[rx] + sizes[ry];
        sizes[rx] = temp;
        sizes[ry] = temp;
    }

    size_t get_size(size_t x) { return sizes[root(x)]; }

    bool same(size_t x, size_t y) {
        size_t rx = root(x);
        size_t ry = root(y);
        return rx == ry;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    size_t n, m;
    cin >> n >> m;
    UnionFind u(n);
    rep(i, m) {
        size_t a, b;
        cin >> a >> b;
        a--;
        b--;
        u.unite(a, b);
    }

    size_t max_size = 0;
    rep(i, n) { max_size = max(max_size, u.get_size(i)); }
    cout << max_size << endl;
    return 0;
}


Measured memory_bytes: 7964
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;
const ll N=1e5+5;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll modinv(ll a,ll m);

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0;
    else
        cout<<10;
    return 0;
}  
void EE(ll a,ll b,ll &co1,ll &co2)
{
    if(a%b==0)
    {
        co1=0;
        co2=1;
        return;
    }
    EE(b,a%b,co1,co2);
    ll tmp=co1;
    co1=co2;
    co2=tmp-co2*(a/b);
}
ll modinv(ll a,ll m)
{
    ll x,y;
    EE(a,m,x,y);
    if(x<0) x+=m;
    return x;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
V=sorted(list(map(int,input().split())),reverse=True)
D=dict()
for i in range(N):
  D[V[i]]=D.get(V[i],0)+1
X=[1]
for i in range(1,51):
  X.append(X[-1]*i)
def cmb(n,r):
  return X[n]//(X[r]*X[n-r])

P=0
if V[0]==V[A-1]:
  for i in range(A,B+1):
    if i>D[V[0]]:
      break
    P+=cmb(D[V[0]],i)
else:
  Q=0
  for i in range(A-1,-1,-1):
    if V[i]!=V[A-1]:
      break
    Q+=1
  P=cmb(D[V[A-1]],Q)
print(sum(V[:A])/A)
print(P)

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x,y;
    vector<ll> temp(4);
    temp[0] = a*c;
    temp[1] = a*d;
    temp[2] = b*c;
    temp[3] = b*d;
    ll ans = temp[0];
    for (int i=0; i<4; i++) {
        ans = max(ans,temp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import scala.io.StdIn.readLine

object Main extends App {

  val lines = Iterator.continually(readLine())
  val xs = {
    val xs = for {
      line       <- lines
      Array(h, w) = line.split(" ").map { _.toInt }
    } yield (h, w)

    xs.takeWhile { _ != (0, 0) }
  }

  for {
    rows <- xs.map(solve)
  } {
    rows.foreach(println)
    println()
  }

  def solve(pair: (Int, Int)): Iterator[String] = pair match {
    case (h, w) =>
      val row  = Iterator.fill(w)('#').mkString("")
      val rows = Iterator.fill(h)(row)
      rows
  }
}



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

using namespace std;
const int Nmax = 3e5 + 5;
struct line
{
    int l,r;
    bool operator < (const line &b) const
    {
        return r - l < b.r - b.l;
    }
};
line a[Nmax];
int ans[Nmax];
int cnt[Nmax];
int T[Nmax];
int n,m;

void update(int i, int val)
{
    while (i <= m)
    {
        T[i] += val;
        i += i & -i;
    }
}

int get(int i)
{
    int res = 0;
    while (i > 0)
    {
        res += T[i];
        i -= i & -i;
    }
    return res;
}

int main()
{
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].l >> a[i].r;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
    {
        ans[1]++;
        ans[a[i].r - a[i].l + 2]--;
    }
    for (int i = 1; i <= m; i++)
    {
        ans[i] += ans[i - 1];
    }
    int j = 1;
    for (int i = 1; i <= m; i++)
    {
        while (j <= n && a[j].r - a[j].l + 1 < i)
        {
            update(a[j].l, 1);
            update(a[j].r + 1, -1);
            j++;
        }
        for (int k = i; k <= m; k += i)
        {
            ans[i] += get(k);
        }
    }
    for (int i = 1; i <= m; i++)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#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 rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;

int main()
{
  int x,y,a=0;
  cin >> x >> y;
  if(x==3) a+=1;
  else if(x==2) a+=2;
  else if(x==1) a+=3;

  if(y==3) a+=1;
  else if(y==2) a+=2;
  else if(y==1) a+=3;

  if(x==1 and y==1) a+=4;

  cout << a*100000 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> P;
#define MOD 1000000007
#define INF 1000000000
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<c+b-d<<" "<<d+c-a<<" "<<a+b-d<<" "<<b+c-a<<endl;
	return 0;
}


Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  const N = scan!long;

  void solve() {
    bool[string] items;

    foreach(_; 0..N) {
      const item = scan;
      items[item] = true;
    }

    writeln(items.keys.length);
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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


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

  int maxK = (B / K) * K;
  if(A<=maxK)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3628
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(12).
       01  a2 PIC 9(12).
       01  a3 PIC 9(12).
       01  r pic 9(12).
       01  g pic 9(12).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2.
        compute a3 = a1 + a2

        DIVIDE a3 BY 2 GIVING g REMAINDER r  

         IF r = 1 THEN
           DISPLAY "IMPOSSIBLE"
         ELSE
          MOVE FUNCTION TRIM(g) to disp
          DISPLAY disp
         END-IF


       STOP RUN.


Measured memory_bytes: 384
#include <iostream>

int main(){
	int n, a, b;

	std::cin >> n >> a >> b;

	int s = 0;

	for(int i = 0; i <= n; ++i){
		int q1, q2, q3, q4, q5;
		int r1, r2, r3, r4;

		q1 = i / 10000;
		r1 = i % 10000;

		q2 = r1 / 1000;
		r2 = r1 % 1000;

		q3 = r2 / 100;
		r3 = r2 % 100;

		q4 = r3 / 10;
		r4 = r3 % 10;

		q5 = r4 / 1;

		int tot = q1 + q2 + q3 + q4 + q5;
		if(tot >= a && tot <= b){
			s += i;
		}
	}

	std::cout << s << std::endl;

	return 0;
}


Measured memory_bytes: 256
integer1, integer2, term = map(int, input().split())
term_value = max(integer1, integer2)
largest_term = 0
while term_value <= 100:
    if integer1 % term_value == 0 and integer2 % term_value == 0:
        largest_term += 1
    if term == largest_term:
        break
    term_value -= 1
print(term_value)

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int arr1[a][b];
	int arr2[b][c];
	long long out[a][c];
	for(int i = 0; i < a; i++)
		for(int j = 0; j < b; j++)
			cin >> arr1[i][j];
	for(int i = 0; i < b; i++)
		for(int j = 0; j < c; j++)
			cin >> arr2[i][j];
	for(int i = 0; i < a; i++){
		for(int j = 0; j < c; j++){
			long long sum = 0;
			for(int k = 0; k < b; k++){
				sum += arr1[i][k] * arr2[k][j];
			}
			out[i][j] = sum;
		}
	}
	for(int i = 0; i < a; i++){
		for(int j = 0; j < c; j++){
			cout << out[i][j];
			if(j != c-1)
				cout << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3236
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

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 dx[2][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}}, dy[2][4] = {{1, 0, -1, 0}, {1, 0, -1, 0}};

string s1[55], s2[55];
int d[55][55][55][55];
signed main(void)
{
  while(true) {
    int w, h;
    cin >> w >> h;
    if(!w && !h) break;
    REP(i, h) cin >> s1[i] >> s2[i];

    int srx, sry, slx, sly, grx, gry, glx, gly;
    REP(i, h) REP(j, w) {
      if(s1[i][j] == 'L') {
        srx = j, sry = i;
      }
      if(s1[i][j] == '%') {
        grx = j, gry = i;
      }
      if(s2[i][j] == 'R') {
        slx = j, sly = i;
      }
      if(s2[i][j] == '%') {
        glx = j, gly = i;
      }
    }
    // cout << srx << " " << sry << " " << grx << " " << gry << endl;
    // cout << slx << " " << sly << " " << glx << " " << gly << endl;

    queue<VI> que;
    que.push({srx, sry, slx, sly});
    memset(d, 0x3f, sizeof(d));
    d[sry][srx][sly][slx] = 0;
    while(que.size()) {
      VI v = que.front(); que.pop();
      int rx = v[0], ry = v[1], lx = v[2], ly = v[3];
      // cout << rx << " " << ry << " " << lx << " " << ly << endl;
      if(s1[ry][rx] == '%' && s2[ly][lx] == '%') break;
      else if(s1[ry][rx] == '%' || s2[ly][lx] == '%') continue;
      REP(i, 4) {
        int nrx = rx + dx[0][i], nry = ry + dy[0][i], nlx = lx + dx[1][i], nly = ly + dy[1][i];
        bool r = !IN(0, w, nrx) || !IN(0, h, nry) || s1[nry][nrx] == '#',
             l = !IN(0, w, nlx) || !IN(0, h, nly) || s2[nly][nlx] == '#';
        if(!r && !l) {
          if(d[nry][nrx][nly][nlx] == 0x3f3f3f3f) {
            d[nry][nrx][nly][nlx] = d[ry][rx][ly][lx] + 1;
            que.push({nrx, nry, nlx, nly});
          }
        } else if(!r) {
          if(d[nry][nrx][ly][lx] == 0x3f3f3f3f) {
            d[nry][nrx][ly][lx] = d[ry][rx][ly][lx] + 1;
            que.push({nrx, nry, lx, ly});
          }
        } else if(!l) {
          if(d[ry][rx][nly][nlx] == 0x3f3f3f3f) {
            d[ry][rx][nly][nlx] = d[ry][rx][ly][lx] + 1;
            que.push({rx, ry, nlx, nly});
          }
        }
      }
    }

    if(d[gry][grx][gly][glx] == 0x3f3f3f3f) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 41736
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q);
    vector<int> b(q);
    vector<int> c(q);
    vector<int> d(q);
    for (int i = 0; i < q; i++)
    {
        int e, f, g, h;
        cin >> e >> f >> g >> h;
        a[i] = e;
        b[i] = f;
        c[i] = g;
        d[i] = h;
    }

    vector<int> A(n, 1);
    ll ans = 0;
    while (true)
    {
        ll tmp = 0;
        for (ll i = 0; i < q; i++)
        {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
            {
                tmp += d[i];
            }
        }
        ans = max(ans, tmp);

        // 更新
        for (int i = 0; i < n; i++)
        {
            if (A[n - 1 - i] != m)
            {
                A[n - 1 - i] += 1;
                for (int j = 0; j < i; j++)
                {
                    A[n - 1 - j] = A[n - 1 - i];
                }
                break;
            }
            else
            {
                // A[n-1-i] == 10
                continue;
            }
        }

        // debug
        // for (int i = 0; i < n; i++)
        // {
        //     cout << A[i] << " ";
        // }
        // cout << endl;
        bool flag = false;
        for (int i = 0; i < n; i++)
        {
            if (A[i] != m)
            {
                flag = true;
                break;
            }
        }
        if (!flag)
        {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
package main
 
import (
	"fmt"
)
 
func main() {
	var h, w int
	fmt.Scan(&h, &w)
	for y := 0; y < h; y++ {
		var s string
		fmt.Scan(&s)
		fmt.Println(s)
		fmt.Println(s)
	}
}

Measured memory_bytes: 512
import sys
import math

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

a,b = input().split(' ')
ash_1 = int(a[-1])
ash_2 = int(a[-2:])
bsh_1 = int(b[-2])
bsh_2 = int(b[-1])
bsh_0 = int(b[0])
kuri = (ash_1*bsh_1*10 + ash_2*bsh_2) //100
if len(a) == 1:
    res = int(a)*bsh_0 + kuri
elif len(a) == 2:
    a1 = a[:-1]
    res = int(a)*bsh_0 + int(a1)*bsh_1 + kuri
else:
    a1 = a[:-1]
    a2 = a[:-2]
    res = int(a)*bsh_0 + int(a1)*bsh_1 + int(a2)*bsh_2 + kuri
print(res)

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
void fl()
{
	freopen("get data.out","r",stdin);
	freopen("Brick Break.out","w",stdout);
}
int main()
{
//   	fl();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=-1,now=1,last=0;
	bool ok=false;
	for(int i=1;i<=n;i++)
		if(a[i]==now)
		{
			ok=true;
			ans+=(i-1-last);
			now++;
			last=i;
		}
	ans+=(n-last);
	printf("%d\n",ok?ans+1:-1);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
   ll n ,ans=0; cin>> n ;
  
  for(ll i=1;i<=n;i++){
   string s=to_string(i);
    if(s.size()%2==1) ans++;
  }
  
 cout<< ans<<endl;
  
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/24  Problem: 007_agc_b / Link: https://agc007.contest.atcoder.jp/tasks/agc007_b?lang=en  ----- */
/* ------問題------

集合 {1,2,…,N} の要素を並び替えた順列 p が与えられます。以下の条件をすべて満たす 2 つの正整数列 a1, a2, ..., aN および b1, b2, ..., bN を構成してください。
すべての i に対し、1≤ai,bi≤10^9
a1<a2<…<aN
b1>b2>…>bN
ap1+bp1<ap2+bp2<…<apN+bpN

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N), b(N);
	FOR(i, 0, N) {
		a[i] = 20000 * i + 1;
		b[i] = 20000 * (N - 1 - i) + 1;
	}
	VI p(N);
	FOR(i, 0, N) {
		cin >> p[i];
		a[p[i] - 1]+=i+1;
	}

	FOR(i, 0, N) {
		cout << a[i] << " ";
	}cout << endl;
	FOR(i, 0, N) {
		cout << b[i] << " ";
	}cout << endl;

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
ll A[Nmax], B[Nmax];

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

	ll ans = 0;
	for(int i=0; i<31; i++){
		vector<ll> bs(N);
		for(int j=0; j<N; j++) bs[j] = B[j]%(1LL<<(i+1));
		sort(bs.begin(), bs.end());
		//for(int i=0; i<N; i++) cout << bs[i] << (i<N-1?' ':'\n');
		ll k = 0;
		for(int j=0; j<N; j++){
			ll a = A[j]%(1LL<<(i+1));
			ll l1 = lower_bound(bs.begin(), bs.end(), (2LL<<i)-a)
				-lower_bound(bs.begin(), bs.end(), (1LL<<i)-a);
			ll l2 = lower_bound(bs.begin(), bs.end(), (4LL<<i)-a)
				-lower_bound(bs.begin(), bs.end(), (3LL<<i)-a);
			//if(l1>0||l2>0) cout << i << ":" << a << " "<< l1 << " " << l2 << endl;
			k += l1 + l2;
		}
		ans |= (k%2)<<i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4964
import sys
readline = sys.stdin.readline
from collections import deque
from math import isinf
INF = float("inf")
sys.setrecursionlimit(200000)
n = int(readline())
G = [[] for _ in range(n)]
D = [INF] * n
for _ in [0] * (n - 1):
    s, t, w = map(int, readline().split())
    G[s].append([t, w])
    G[t].append([s, w])
def bfs(s, D):
    dq = deque([s])
    D = [INF] * n
    D[s] = 0
    while dq:
        u = dq.popleft()
        for i in range(len(G[u])):
            e = G[u][i]
            if isinf(D[e[0]]):
                D[e[0]] = D[u] + e[1]
                dq.append(e[0])
    return D
D = bfs(0, D)
maxv = 0
tgt = 0
for i in range(n):
    if isinf(D[i]): continue
    if maxv < D[i]:
        maxv = D[i]
        tgt = i
D = bfs(tgt, D)
maxv = 0
for i in range(n):
    if isinf(D[i]): continue
    maxv = max(maxv, D[i])
print(maxv)

Measured memory_bytes: 55500
#include <stdio.h>

int main(void)
{
	int n, i;
	unsigned long money=100000;

	scanf("%d", &n);

	for(i=0; i<n; i++){
		money *= 1.05;
		if(money%1000 != 0){
			money = ( (money/1000) * 1000 ) + 1000;
		}
	}

	printf("%lu\n", money);
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
int main()
{
        string s,t;
        cin>>s;
        cin>>t;
        for(int i=0;i<s.length();i++)
        {
                if(s[i]==t[i])
                {
                        continue;
                }
                else
                {
                        cout<<"No";
                        return 0;
                }
        }
        cout<<"Yes";
        return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    int od = 0, tw = 0, fo = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a % 4 == 0){
            ++fo;
        }else if(a % 2 == 0){
            ++tw;
        }else{
            ++od;
        }
    }

    bool flag = true;
    if(tw > 0){
        flag = (fo >= od);
    }else{
        flag = (fo + 1 >= od);
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long LEN = (long) 1e18;
	
	void doIt() {
		long n = sc.nextLong();
		if(n % 2 != 0) {
			System.out.println(0);
			return;
		}
		long cnt = 0;
		long base = 5;
		while(base <= n) {
			cnt += n / base / 2;
			if(base > LEN / 5)break;
			base *= 5;
		}
		System.out.println(cnt);
	}
	

	long gcd(long a, long b) {
		return (b != 0) ? gcd(b, a % b) : a;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
	
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#define N 500002

int max(int a, int b){
  if (a>b) return a;
  else return b;
}

int main(void){
  char s[N];
  long long ans=0;
  int a[N];
  scanf("%s", &s);

  int n = strlen(s);

  for(int i=0; i<n; i++){
    if (s[i] == '<')
      a[i+1] = max(a[i+1], a[i]+1);  
  }

  for(int i=n-1; i>=0; i--){
    if (s[i] == '>')
      a[i] = max(a[i], a[i+1]+1);    
  }

  for(int i=0; i<=n; i++)
    ans += a[i];
  
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <limits.h>
#include <tgmath.h>

using namespace std;

typedef uint16_t ui16;
typedef uint32_t ui32;
typedef uint64_t ui64;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef long double ld;
typedef pair<int, int> pr;

//template<typename T> inline T abs(T a) { return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a) { return a * a; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) {for (int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl; return cout; }
void print() { cout << endl; }
template<typename T, typename... Ts> void print(T x, Ts... xs) { cout << x << " "; print(xs...); };
template<typename T> void read(vector<T>& v) { for (int i = 0; i < v.size(); ++i) cin >> v[i]; };

// dp[i][j] = min weight to reach value j using i items

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N + 1, 0);
    vector<int> w(N + 1, 0);

    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    vector<int> dp(sum + 1, 1000*1000*1000 + 7);
    dp[0] = 0;

    for (int i = 0; i <= N; ++i) {
        for (int j = sum; j > 0; --j) {
            if (v[i] <= j) {
                dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            }
        }
    }

    int ret = 0;
    for (int i = 1; i <= sum; ++i) {
        if (dp[i] <= W) {
            ret = i;
        }
    }
    cout << ret;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String s = sc.next();
    int[] rui = new int[n + 1];
    for(int i = 0; i < n - 1; i++) {
      rui[i + 1] = rui[i];
      if((s.charAt(i) == 'A') && (s.charAt(i + 1) == 'C')) rui[i + 1] = rui[i] + 1;
    }
    for(int i = 0; i < q; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      System.out.println(rui[r - 1] - rui[l - 1]);
    }
  }
}

Measured memory_bytes: 62820
N = int(input())
a_list = list(map(int, input().split()))

multi4 = len([a for a in a_list if a % 4 == 0])
odd_num = len([a for a in a_list if a % 2 != 0])

even_num = len(a_list) - odd_num
not4 = even_num - multi4

if not4 >0 :
    if odd_num <= multi4:
        print("Yes")
    else:
        print("No")

else:
    if odd_num <= multi4 + 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int main() {
long N,M;
  cin>>N>>M;
  if(N>=2&&M>=2){
  cout<<(N-2)*(M-2)<<endl;
  }
  else if(N==1&&M==1){
    cout<<1<<endl;
  }
  else {     
    cout<<N*M-2<<endl;
  }
}

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

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i=0,N,min,cnt=0;
  char ss[200001];
  scanf("%d",&N);
  scanf("%s",ss);
  while(i<N){
    if(ss[i]=='.'){
      cnt++;
    }
    i++;
  }
  if(ss[0]=='.')cnt--;
  min=cnt;
  for(i=1;i<N;i++){
    if(ss[i]=='.')cnt--;
    if(ss[i-1]=='#')cnt++;
    if(min>cnt)min=cnt;
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  str s;int a=0,m=0;
  cin>>s;
  rep(i,3){
    if(s[i]=='R')a++;
    else a=0;
    m=max(m,a);
  }
  cout<<m;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    if (s == "SUN") cout << "7" << endl;
    if (s == "MON") cout << "6" << endl;
    if (s == "TUE") cout << "5" << endl;
    if (s == "WED") cout << "4" << endl;
    if (s == "THU") cout << "3" << endl;
    if (s == "FRI") cout << "2" << endl;
    if (s == "SAT") cout << "1" << endl;

    return 0;
    
}

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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
       ll s , w;
       cin >> s >> w;
       if(w >= s)
       cout << "unsafe" << endl;
       else
       cout << "safe" << endl;      
   }
}


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

a.sort()
import bisect
bl = bisect.bisect_left(a, a[-1]//2)
#print(a[-1], a[bl], a[bl-1])

if abs(a[-1]/2 - a[bl]) < abs(a[-1]/2 - a[bl-1]):
    print(a[-1] , a[bl])
else:
    print(a[-1] , a[bl-1])



Measured memory_bytes: 14428
n,k = map(int,input().split())
p = list(map(int,input().split()))
p_ = [(i+1)/2 for i in p]
d = [0]
for i in p_:
  d.append(d[-1]+i)
ans = 0
for i in range(k,n+1):
  if ans < d[i]-d[i-k]:
    ans = d[i]-d[i-k]
print(ans)

Measured memory_bytes: 24812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
vector<int> v;

int main () {
  cin >> N;

  Rep(i, 2 * N) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  sort(All(v), greater<int>());

  ll ans = 0;

  Rep(i, N) {
    ans += v[i * 2 + 1];
  }

  cout << ans << "\n";
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k) cout << s << endl;
  else {
    s.erase(k);
    cout << s << "..." << endl;
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007

ll power(ll n , ll k)
{
	ll ans = 1;

	while(k)
	{
		if(k & 1)
		{
			ans *= n;
		}

		k /= 2;
		n = n * n;

	}

	return ans;

}

int main()
{

	cout<<fixed<<setprecision(12);

	ld ans = 0.0;

	ll n,k;
	cin>>n>>k;

	for(ll i = 1 ; i <= n ; i++)
	{
		ld t1 = (ld)i;
		ld t2 = (ld)k;

		ld mul = 1.0;

		while(t1 < t2)
		{
			t1 *= 2.0;
			mul *= 2.0;
		}

		ld t3 = 1.0/((ld)n);

		ld t4 = (t3)/mul;

		ans = ans + t4;

	}

	cout<<ans<<endl;


}	

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

al.sort()
table = [False]*1000001
table2 = [False]*1000001

for a in al:
    if table2[a]:
        table[a]=True
    if not table[a]:
        table2[a] = True
        for i in range(a+a,1000001,a):
            table[i]=True
    

cnt=0
for a in al:
    if not table[a]:
        cnt+=1
print(cnt)

Measured memory_bytes: 145116
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    ll H; cin>>H;

    int l = (int)log2(H);

    ll ans = (1ll << (l+1))-1ll;
    cout<<ans<<"\n";


   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class IO {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static String[] buffers = new String[1];
    private static int cur=1;

    static BufferedReader getBr() {
        return br;
    }

    static String next() {
        String res = null;
        try {
            res = br.readLine();
            cur = buffers.length;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return res;
    }

    static int nextInt() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Integer.parseInt(buffers[cur++]);
    }

    static long nextLong() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Long.parseLong(buffers[cur++]);
    }

    static double nextDouble() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Double.parseDouble(buffers[cur++]);
    }

    static void out(Object... obj) {
        if(obj==null || obj.length==0) {
            System.out.println();
            return ;
        } else if(obj.length == 1) {
            System.out.println(obj[0]);
            return ;
        }
        StringBuilder sb = new StringBuilder();
        for(Object o:obj) {
            sb.append(o);
        }
        System.out.println(sb);
    }

    static void outs(Object... obj) {
        if(obj==null || obj.length==0) {
            System.out.println();
            return ;
        } else if(obj.length == 1) {
            System.out.println(obj[0]);
            return ;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(obj[0]);
        for(int i=1; i<obj.length; i++) {
            sb.append(" ").append(obj[i]);
        }
        System.out.println(sb);
    }
}

public class Main {

    public static void main(String[] args) {
        int N = IO.nextInt(), K = IO.nextInt();
        int ans = 1;
        for(int i=0; i<N; i++) {
            ans += Math.min(ans, K);
        }
        IO.out(ans);
    }
}


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

using namespace std;

int dist[2][100005];

vector <int> edge[100005];
bool used[100005];

void bfs(int s, int t) {
    memset(used, 0, sizeof(used));
    dist[t][s] = 0;
    used[s] = 1;
    queue <int> que;
    que.push(s);
    
    while (que.size()) {
        int now = que.front();
        que.pop();
        
        for (int i = 0; i < edge[now].size(); i++) {
            int to = edge[now][i];
            if (used[to]) continue;
            used[to] = 1;
            dist[t][to] = dist[t][now] + 1;
            que.push(to);
        }
    }
}

int main() {
    int n, u, v;
    scanf("%d%d%d", &n, &u, &v);
    
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    
    bfs(u, 0);
    bfs(v, 1);
    
    int res = 0;
    
    for (int i = 1; i <= n; i++) {
        if (dist[0][i] >= dist[1][i]) continue;
        
        res = max(res, dist[1][i] - 1);
    }
    
    printf("%d\n", res);
}

Measured memory_bytes: 6784
//suhan lee, saitama university;
#include <iostream>
using namespace std;
int putbook(int *list,int bookwi,int stair,int width){

  int dara[100];
  int j=0;
  for(int i=0;i<100;i++)
    dara[i]=0;
  for(int i=0;i<bookwi;i++)
    if(dara[j]+list[i]<=width)
      dara[j]+=list[i];
    else  if(list[i]>width){
      //cout <<"too big book"<<endl;
      return 0;
    }
    else  dara[++j]+=list[i];     
  //  cout <<"hondara";
  for(int i=0;i<stair;i++)
    // cout <<dara[i]<<endl;
    // cout <<"kugiri";
  if(j<stair) return 1;// no problem
  else return 0;
}


int main(){

  int list[100];

  int bookwi,stair,temp;
  int max,min;
  while(1){
    cin >>stair>>bookwi;
    if(bookwi==0&&stair==0)
      return 0;
    for(int i=0;i<bookwi;i++)
      cin>>list[i];
    max=10000000;
    min=1;
    //cout << putbook( list,bookwi,stair,1800 )<<endl;
    while(1){
      if(min==max) break;
      if(putbook( list,bookwi,stair, ( max+min)/2  ) )
	max=(max+min)/2;
      else min= (max+min)/2+1;
      //   cout <<endl<<max<<" max&min   "<<min<<endl;   
    }
    cout <<max<<endl;
  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  cin >> s;
  t = s.at(0);
  for(int i = 1; i < s.size() ; i++){
    if(s.at(i)==','){
      t += ' ';
    } else {
      t += s.at(i);
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    int tmp = 1;
    int count = 0;
    rep(i, 0, N) {
        if(a[i] == tmp) {
            count++;
            tmp++;
        }
    }
    if(count == 0) {
        cout << -1 << endl;
    } else {
        cout << N - count << endl;
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int max = 0;
		boolean flag = true;
		
		for(int i=0; i<N ; i++) {
			int p = sc.nextInt();
			if(max - p >= 2) {
				flag = false;
				break;
			}
			if(max - p == 1) {
				// 何もしない
				continue;
			}
			max = p;
		}
		
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();	
	}

}

Measured memory_bytes: 46288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

vector<int> v;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n, q; 
    cin >> n;
    REP(i, n) {
        int a; cin >> a;
        v.push_back(a);
    }
    
    cin >> q;
    REP(i, q){
        int b, e; cin >> b >> e;
        reverse(v.begin()+b, v.begin()+e); 
    }
    for(int i=0; i<n; ++i){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll x=n;
    vlli v;
    while(x){
        x--;
        v.pb(x%26);
        x/=26;

    }
    for(ll i=v.size()-1;i>=0;i--){
        cout<<char(v[i]+'a');
    }
    cout<<endl;
}

Measured memory_bytes: 3556
n, l = map(int,input().split())
List1 = []
List2 = []

for i in range(n):
    L = l + i
    L_abs = abs(L)
    List1.append(L)
    List2.append(L_abs)

if min(List2) in List1:
    List1.remove(min(List2))
elif -min(List2) in List1:
    List1.remove(-min(List2))

print(sum(List1))

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

int main() {
  int N;
  cin >> N;
  
  vector<int> h(N);

  for(int i = 0 ; i < N ; i++){
  	cin >> h.at(i);
  }
  
  vector<int> x(N,0);
  
//  cout << h.at(0) << h.at(1) << h.at(2) << endl;
//  cout << x.at(0) << x.at(1) << x.at(2) << endl;

  
  
  int count = 0;
  bool flag_c = false;
  
  for(int j = 0 ; j < N ; ){  // 1番目から順番に水やりのチェック
  	if(h.at(j) != x.at(j)){
    	if(flag_c == false){   //水やり開始　カウント＋１
        	count += 1;
            flag_c = true;
//          	cout << "count:" << count << endl;
        }
    	for(int k = j; k < N; k++){ // j番目から右側を目的の高さにする
//          cout << "h.at(k):" << h.at(k) << " x.at(k):" << x.at(k) << endl;
       		if(h.at(k) != x.at(k)){
            	x.at(k) += 1;
//                cout << "x.at(" << k << "):" << x.at(k) << endl;
            }
			else{
//                cout << "flag clear"  << endl;
            	flag_c = false;
            	break;				// 目的の高さになった所に到達した時点でループを抜ける
            }
          if( k == N -1 ) flag_c = false;
     	}
   	
  	}
  	if(h.at(j) == x.at(j)){   // 左端の高さが目的に到達した時点で右にずれる
      j += 1;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256