akhauriyash/Code-Regression huggingface dataset:
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1156&lang=jp

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>
using namespace std;

typedef tuple<int, int, int, int> pass; // x, y, d, cost
typedef tuple<int, int, int, int> state; // cur, x, y, d

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

int main() {
  int w, h;
  while(cin >> w >> h && w) {
    // 入力
    int S[40][40];
    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
	cin >> S[j][i];
      }
    }
    int c[4];
    cin >> c[0] >> c[1] >> c[2] >> c[3];
    // 隣接リストを作る
    vector<pass> V[40][40][4];
    for (auto i=0; i<w; i++) {
      for (auto j=0; j<h; j++) {
	for (auto k=0; k<4; k++) {
	  for (auto l=0; l<4; l++) {
	    int nd = (k+l)%4;
	    int nx = i + dx[nd];
	    int ny = j + dy[nd];
	    int nc = c[l];
	    if (S[i][j] == l) nc = 0;
	    if (0 <= nx && nx < w && 0 <= ny && ny < h) {
	      V[i][j][k].push_back(make_tuple(nx, ny, nd, nc));
	    }
	  }
	}      
      }      
    }
    /* pass p = V[7][0][0][0];
    cerr << "(" << get<0>(p) << "," << get<1>(p) << ") "
       << get<2>(p) << " cost:" << get<3>(p) << endl; */
    // Dijkstra法を適用する。
    priority_queue<state> Q;
    bool visited[40][40][4];
    int cost[40][40][4];
    fill(&visited[0][0][0], &visited[0][0][0]+40*40*4, false);
    fill(&cost[0][0][0], &cost[0][0][0]+40*40*4, (int)1e8);
    Q.push(make_tuple(0, 0, 0, 0));
    while (!Q.empty()) {
      state s = Q.top();
      int x = get<1>(s);
      int y = get<2>(s);
      int d = get<3>(s);
      int C = -1 * get<0>(s);
      Q.pop();
      if (!visited[x][y][d]) {
	cost[x][y][d] = C;
	//	cerr << "(" << x << "," << y << ")" << " of " 
	//	<< d << " costs " << C << endl;
	visited[x][y][d] = true;
	for (auto i=0; i<V[x][y][d].size(); i++) {
	  pass p = V[x][y][d][i]; 
	  int nx = get<0>(p);
	  int ny = get<1>(p);
	  int nd = get<2>(p);
	  int nc = get<3>(p);
	  if (!visited[nx][ny][nd]) {
	    Q.push(make_tuple(-1 * (C + nc), nx, ny, nd));
	  }
	}
      }
    }
    int ans = (int)1e8;
    for (auto i=0; i<4; i++) {
      int t = cost[w-1][h-1][i];
      // cerr << t << endl;
      if (ans > t) ans = t;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    n %= 1000;
    if (n != 0) {
        cout << (1000-n) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#include<cstdio>
using namespace std;
static const int MAX_H = 1000;
static const int MAX_W = 1000;
static const int MULTI_DIRECTED = MAX_H * MAX_W;
#define MD MULTI_DIRECTED

int H, W;
int M[MAX_H][MAX_W];
int y[MAX_H * MAX_W], x[MAX_H * MAX_W];
int dest[MAX_H * MAX_W];

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

int main(){
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			scanf("%d", &M[i][j]);
			M[i][j]--;
			y[M[i][j]] = i;
			x[M[i][j]] = j;
			dest[M[i][j]] = M[i][j];
		}
	}
	for(int i = 0; i < H * W; i++){
		int cy = y[i], cx = x[i];
		for(int j = 0; j < 4; j++){
			int ny = cy + dy[j], nx = cx + dx[j];
			if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
			if(M[ny][nx] < i) continue;
			if(dest[M[ny][nx]] == M[ny][nx]) dest[M[ny][nx]] = dest[M[cy][cx]];
			else if(dest[M[ny][nx]] != dest[M[cy][cx]]) dest[M[ny][nx]] = MD;
		}
	}
	int res = 0;
	for(int i = 0; i < H * W; i++){
		if(dest[i] == MD) res++;
	}
	printf("%d\n", res);
	return 0;
}


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

int main() {
  long N;

  std::cin >> N;
  std::vector<long> X(N);
  std::vector<long> X_sorted(N);

  for (long i=0; i<N; i++) {
    std::cin >> X[i];
    X_sorted[i] = X[i];
  }

  std::sort(X_sorted.begin(), X_sorted.end());

  long const med_small = X_sorted[N/2-1];
  long const med_big = X_sorted[N/2];

  for (auto const& x : X) {
    if (x <= med_small)
      std::cout << med_big << std::endl;
    else
      std::cout << med_small << std::endl;
  }

  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define rg register
#define ll long long 
#define inf 0x3f3f3f3f
ll n,k;
ll a[55],b[55];
ll hh[6]={0,0,1,2,3,3};
ll work(ll res,ll lev)
{
    ll tmp=b[lev-1]+2;
    if(lev==0)
        return res>0;
    
    if(res<tmp) return work(res-1,lev-1);
    else if(res==tmp) return a[lev-1]+1;
    else return work(res-b[lev-1]-2,lev-1)+1+a[lev-1];
}
int main(){
    //freopen("a.in","r",stdin);
    scanf("%lld%lld",&n,&k);
    a[0]=b[0]=1;
    for(int i=1;i<=n;i++)
        a[i]=a[i-1]*2+1,b[i]=b[i-1]*2+3;
        /*
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    for(int i=1;i<=n;i++)
        cout<<b[i]<<" ";
    cout<<endl;
    */
    printf("%lld\n",work(k,n));
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;

int main(){
  ll T1,T2,A1,A2,B1,B2;
  scanf("%lld %lld",&T1,&T2);
  scanf("%lld %lld",&A1,&A2);
  scanf("%lld %lld",&B1,&B2);

  if(((A1>B1)and(T1*A1+T2*A2<T1*B1+T2*B2))or((A1<B1)and(T1*A1+T2*A2>T1*B1+T2*B2))){
    ll sa= T1*(A1-B1);//(T1*A1-T1*B1);
    ll sa2=T1*(A1-B1)+T2*(A2-B2);//T1*A1+T2*A2-T1*B1-T2*B2;

    if(sa<0) sa=-sa;
    if(sa2<0) sa2=-sa2;

    if(sa%sa2==0){
      printf("%lld\n",1+(sa/sa2-1)*2+1);
    }else{
      printf("%lld\n",sa/sa2*2+1);
    }
    

  }else if(T1*A1+T2*A2==T1*B1+T2*B2){
    cout << "infinity" << endl;

  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
r, c = gets.split( " " ).map { | val | val.to_i }

csums = Array.new( c, 0)
rsum = 0
output = []
r.times {
	matrix = gets.split( " " ).map { | val | val.to_i }

	rsum = 0
	for i in ( 0 ... c )
		rsum += matrix[i]
		csums[i] += matrix[i]
		output.push( "#{matrix[i]} " )
	end
	output.push( "#{rsum}\n" )
}

rsum = 0
csums.each { |val|
	rsum += val
	output.push( "#{val} " )
}
output.push( "#{rsum}\n" )
print( output.join )

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W;
std::string A[12];
int col[12];
bool used[12];

bool f(int s, int i){
    if(i == W / 2){
        memset(used, 0, sizeof(used));

        int n = 0;

        for(int j=0;j<H;++j){
            if(used[j]){
                continue;
            }

            for(int k=j+1;k<H;++k){
                if(used[k]){
                    continue;
                }

                bool rev = true;

                for(int l=0;l<W;++l){
                    if(A[j][col[l]] != A[k][col[W - 1 - l]]){
                        rev = false;
                        break;
                    }
                }

                if(rev){
                    used[j] = used[k] = true;
                    break;
                }
            }

            unless(used[j]){
                n += 1;
            }
        }

        if(H % 2 == 0){
            return n == 0;
        }
        return n == 1;
    }

    int a = __builtin_ctz(~s);
    col[i] = a;

    for(int b=a+1;b<W;++b){
        if(s >> b & 1){
            continue;
        }

        col[W - 1 - i] = b;

        if(f(s | (1 << a) | (1 << b), i + 1)){
            return true;
        }
    }

    return false;
}

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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        std::cin >> A[i];
    }

    bool can = false;

    if(W % 2 == 0){
        can = f(0, 0);
    }else{
        // 中心を先に決めておく
        for(int i=0;i<W;++i){
            col[W / 2] = i;

            if(f(1 << i, 0)){
                can = true;
                break;
            }
        }
    }

    if(can){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
sd = input()
t = input()
lsd = len(sd)
lt = len(t)
for i in range(lsd-lt,-1,-1):
  for j in range(lt):
    if sd[i+j] != "?" and sd[i+j] != t[j]:
      break
  else:
      print((sd[:i]+t+sd[i+lt:]).replace("?","a"))
      break
else:
  print("UNRESTORABLE")


Measured memory_bytes: 38256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
    ll n;
    cin>>n;
    vector<pll> ba(n);
    rep(i,0,n) cin>>ba[i].second>>ba[i].first;
    sort(range(ba));
    ll t=0;
    bool f=0;
    rep(i,0,n){
        t+=ba[i].second;
        if(t>ba[i].first) f=1;
    }
    if(f) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 3328
using System;

class Program
{
    static void Main(string[] args)
    {
        var x = Console.ReadLine().Split();
        var a = int.Parse(x[0]);
        var b = int.Parse(x[1]);
        var c = int.Parse(x[2]);

        for (int i = 0; i < b; i++)
        {
            if (a * i % b == c)
            {
                Console.WriteLine("YES");
                return;
            }
        }

        Console.WriteLine("NO");
    }
}


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

/*
    横と縦のuf持てば, kruskalっぽくできる？
    pqで小さい方からだす
    hとwでおなじだったらsizeが小さくなるようにやればいいのかな(未証明)
*/

struct UnionFind {
    vector<int> parent;
    int __size;
    UnionFind(int size_) : parent(size_, -1), __size(size_) {}
    bool unite(int x,int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
            return true;
        }
        return false;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x){ return -parent[find(x)]; }
    int size(){ return __size; }
};

int W, H, res;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq_h, pq_w;

signed main() {

    cin >> W >> H;

    REP(i, W) {
        int p;
        cin >> p;
        pq_w.emplace(make_pair(p, i));
    }
    REP(i, H) {
        int p;
        cin >> p;
        pq_h.emplace(make_pair(p, i));
    }

    UnionFind uf_h(H + 1), uf_w(W + 1);

    while ((uf_h.size() != 1 or uf_w.size() != 1) and (not pq_h.empty() or not pq_w.empty())) {
        if (pq_h.empty()) {
            pair<int, int> pw = pq_w.top();
            pq_w.pop();
            res += uf_h.size() * pw.first;
            uf_w.unite(pw.second, pw.second + 1);
            continue;
        }
        if (pq_w.empty()) {
            pair<int, int> ph = pq_h.top();
            pq_h.pop();
            res += uf_w.size() * ph.first;
            uf_h.unite(ph.second, ph.second + 1);
            continue;
        }
        pair<int, int> ph = pq_h.top();
        pair<int, int> pw = pq_w.top();
        if (ph.first == pw.first) {
            if (uf_h.size() <= uf_w.size()) {
                pq_h.pop();
                res += uf_w.size() * ph.first;
                uf_h.unite(ph.second, ph.second + 1);
            } else {
                pq_w.pop();
                res += uf_h.size() * pw.first;
                uf_w.unite(pw.second, pw.second + 1);
            }
        } else if (ph.first < pw.first) {
            pq_h.pop();
            res += uf_w.size() * ph.first;
            uf_h.unite(ph.second, ph.second + 1);
        } else {
            pq_w.pop();
            res += uf_h.size() * pw.first;
            uf_w.unite(pw.second, pw.second + 1);
        }
        // cout << uf_h.size() << ' ' << uf_w.size() << ' ' << pq_h.size() << ' ' << pq_w.size() << endl;
    }
    
    cout << res << endl;

}


Measured memory_bytes: 4976
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define lb lower_bound
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
#define pc __builtin_popcount
using namespace std;

void solve()
{
    ll i,j=0,r=200,p,q,k,d,y=0,h,flag=1,n,m=0,a=hell,b=hell,h1,h2,a1,b1,a2,w,x,u,f,l,c,z;
    cin>>n;
    string s;
    cin>>s;
    y=1;
    rep(i,1,n)
    {
        if(s[i]!=s[i-1]) y++;

    }

cout<<y;

}


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


Measured memory_bytes: 512
//ITP1_8_B
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
	int sum,i;
	char c;
	
	for(sum=0;;sum=0){
		for(i=0;;i++){
			c=getchar();
			if(c=='\n'){
				cout<<sum<<endl;
				break;
				}
			else if(c=='0'&&i==0)
				return 0;
			sum+=c-'0';
		}
	}
	return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int inputDay = Integer.parseInt(br.readLine());
            StringBuilder inputDayIs = new StringBuilder();
            inputDayIs.append("Christmas");

            for (int i = 0; i < (25 - inputDay); i++) {
                inputDayIs.append(" Eve");
            }

            System.out.println(inputDayIs);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20692
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

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

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector<int> dp(MAX, -1);
vector<int> h(MAX);

int cal(int idx){
    if( idx <= 0 )
        return 0;
    if( idx == 1 )
        return abs(h[idx]-h[idx-1]);
    if( dp[idx] != -1 )
        return dp[idx];
    else
        return dp[idx] = min( cal(idx-2) + abs(h[idx]-h[idx-2]), cal(idx-1) + abs(h[idx]-h[idx-1]));
}

int main(){
	optimizeIO();

    int n;
    cin >> n;
    REP(i, 0, n)
        cin >> h[i];
    cout << cal( n-1 ) << endl;
	
	return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <fstream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstring>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <bitset>
#define MOD 8192
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define NMAX 105

using namespace std;

typedef pair<int, int> pii;

string s;

int main() {
	int w,h,n,x,y,t,i,j,total=0;

	cin>>s;
	n=s.size();
	for(i=1;i<n;++i) {
		if(s[i]!=s[i-1]) ++total;
	}

	cout<<total;

	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < 5; i++) {
            int tmp = s.nextInt();
            if (max < tmp) {
                max = tmp;
            }
            if (min > tmp) {
                min = tmp;
            }
        }
        int k = s.nextInt();
        s.close();
        if (max - min > k) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,c;
  cin>>a>>b>>c;
  
  if(min(a,b)<=c && c<=max(a,b))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = 0;
		long min=-9;
		long a[] = new long[n + 1];
		long b[] = new long[n + 1];
		long c[] = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = a[i] - b[i];

			if(c[i]!=0){
				y=1;
			}

			if (c[i] > 0) {


				if(min==-9||b[i]<=min)
			min=b[i];
			}
		}
		long ans = 0;
		for (int i = 1; i <= n; i++) {

				ans += b[i];

		}

		if (y == 0) {
			System.out.println(0);
		} else {
			System.out.println(ans-min);
		}
	}

}

Measured memory_bytes: 49204
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int a ,b; cin >> a >> b;
	cout << ((a + b) % 2 == 0 ? (a + b) / 2 : (a + b) / 2 + 1) << endl;
	return 0;
}

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

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = Long.parseLong(scanner.next()) - i;
    }
    Arrays.sort(A);
    long ans = 0;
    for (int i = 0; i < N / 2; i++) {
      ans += A[N / 2] - A[i];
    }
    for (int i = N / 2; i < N; i++) {
      ans += A[i] - A[N / 2];
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 60856
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,c,d,e,f;
signed main()
{
	cin>>a>>b>>c;
	rep(i,a){
		cin>>d>>e;
		if(d>=b&&e>=c){
			f++;
		}
	}
	cout<<f;
}

Measured memory_bytes: 256
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b+c>=22 ? "bust" : "win")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  char c;
  cin>>c;

  cout << (c=='a' or c=='e' or c=='i' or c=='o' or c=='u'? "vowel" : "consonant") <<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 1000;
ll grid[MAX][MAX];
ll h, w;

ll yoko[MAX][MAX];
ll tate[MAX][MAX];

bool ingrid(ll i, ll j) {
	bool flag1 = ((i + j) >= 250);
	bool flag2 = ((i + j) <= 950);
	bool flag3 = (j >= i - 350);
	bool flag4 = (j <= i + 350);
	return flag1 && flag2&&flag3&&flag4;
}

int main() {
	cin >> h >> w;
	REP(i, 0, MAX - 1) {
		REP(j, 0, MAX - 1) {
			grid[i][j] = tate[i][j] = yoko[i][j] = 0;
		}
	}
	REP(i, 1, h) {
		REP(j, 1, w) {
			char c;
			cin >> c;
			if (c == '#') {
				grid[i + j][i - j + 301] = 1;
			}
		}
	}	
	h = 603; w = 603;

	REP(i, 1, h+1) {
		REP(j, 1, w+1) {
			yoko[i][j] = yoko[i][j - 1] + grid[i][j];
		}
	}
	REP(j, 1, w+1) {
		REP(i, 1, h+1) {
			tate[i][j] = tate[i - 1][j] + grid[i][j];
		}
	}
	ll ans = 0;
	REP(i, 1, h) {
		REP(j, 1, w) {
			if (!ingrid(i, j)) continue;
			if (grid[i][j] == 0) continue;
			REP(k, i + 1, h) {
				if (!ingrid(k, j)) break;
				if (grid[k][j] == 0)continue;
				ll r = k - i;
				if (j + r <= w) {
					ll e;
					e = tate[k][j + r] - tate[i - 1][j + r];
					ans += e;

					//cout << e << " "<< i << " "  <<j<< " " << r << endl;
				}
				if (j - r >= 1) {
					ll e;
					e = tate[k][j - r] - tate[i - 1][j - r];
					ans += e;
					//cout << e << " "  << i << " " << j << " " << r << endl;

				}
			}
			REP(l, j + 1, w) {
				if (!ingrid(i, l)) break;
				if (grid[i][l] == 0)continue;
				ll r = l - j;
				if (i + r <= h) {
					ll e;
					e = yoko[i + r][l-1] - yoko[i + r][j];
					ans += e;
					//cout <<e << " " << i << " " << j <<" " << r << endl;

				}
				if (i - r >= 1) {
					ll e;
					e = yoko[i - r][l-1] - yoko[i - r][j];
					ans += e;
					//cout << e << " " << i << " " << j <<  " " << r<< endl;

				}
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 23808
package main

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var (
	goods [3000][3000]int
)

func main() {
	defer flush()

	R := readInt()
	C := readInt()
	K := readInt()

	goods := make([][]int, R)
	for i := 0; i < R; i++ {
		goods[i] = make([]int, C)
	}
	for i := 0; i < K; i++ {
		r := readInt() - 1
		c := readInt() - 1
		v := readInt()
		goods[r][c] = v
	}

	n := make([]int, C+1)
	c := make([]int, 4)
	for i := 0; i < R; i++ {
		for k := 0; k < 4; k++ {
			c[k] = 0
		}
		c[0] = n[0]
		for j := 0; j < C; j++ {
			for k := 2; k >= 0; k-- {
				c[k+1] = max(c[k+1], c[k]+goods[i][j])
			}
			for k := 0; k < 4; k++ {
				n[j] = max(n[j], c[k])
			}
			c[0] = max(c[0], n[j+1])
		}
	}

	result := -1
	for k := 0; k < 4; k++ {
		result = max(result, c[k])
	}

	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

using namespace std;

#define MAX 100010
typedef pair<int,int> pii;

class Union_Find{
public:
  int par[MAX],rank[MAX],W[MAX];
  Union_Find(int N){
    for(int i = 0 ; i < N ; i++){
      par[i] = i;
      rank[i] = W[i] = 0;
    }
  }

  pii find(int x){
    if(par[x] == x){ return pii(x,0); }
    pii p = find(par[x]);
    par[x] = p.first;
    W[x] = (p.second += W[x]);
    return p;
  }

  void unite(int x,int y,int w){
    pii nx = find(x), ny = find(y);
    x = nx.first; y = ny.first;
    if(x == y){ return; }
    w -= nx.second-ny.second;
    if(rank[x] < rank[y]){
      par[x] = y; W[x] = w;
    }else{
      par[y] = x; W[y] = -w;
      if(rank[x] == rank[y]){
        rank[x]++;
      }
    }
  }

  bool same(int x,int y){
    return (find(x).first == find(y).first);
  }

  int diff(int a,int b){
    return W[a]-W[b];
  }
};

int main(){
  int N,M,a,b,c;
  while(cin >> N >> M,N){
    Union_Find uf(N);
    for(int i = 0 ; i < M ; i++){
      char ch;
      cin >> ch >> a >> b;
      a--; b--;
      if(ch == '!'){
        cin >> c;
        uf.unite(a,b,c);
      }else{
        if(uf.same(a,b)){
          cout << uf.diff(a,b) << endl;
        }else{
          puts("UNKNOWN");
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2332
def main():
    import sys
    input = sys.stdin.readline
    
    N,M = map(int,input().split())
    PY = [[i]+list(map(int,input().split())) for i in range(M)]

    PY = sorted(PY,key = lambda x:(x[1],x[2]))
    
    ans_li = ['0'*12]*M
    town_dict = {}

    for idx,p,y in PY:
        x = town_dict.get(p,1)

        id_ = ('{:6d}'.format(p)+'{:6d}'.format(x)).replace(' ','0')
        ans_li[idx] = id_

        town_dict[p] = town_dict.get(p,1)+1

    print('\n'.join(ans_li))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 44324
#include <bits/stdc++.h>
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 ANS(ans) cout << ans << endl
#define FLG(flg) if(flg) cout << "Yes" << endl; else cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define AN vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
#define IN  int n;  cin >> n;
#define VI  vector<int> 
#define R0 return 0;


int main() {
    string s,L,R;
    cin >> s;
    bool flg = true;
    int l = s.length();
    REP(i,l) {
        if(i % 2 == 0) {
            if(s[i] != 'R' && s[i] != 'U' & s[i] != 'D') {
                NO
                R0
            }
        }
        else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                NO
                R0
            }
        }
    }
    YES
}


Measured memory_bytes: 256
import Data.List                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  a <- map read . words <$> getLine :: IO [Int]                                                                            
  b <- map read . words <$> getLine                                                                                        
  c <- map read . words <$> getLine                                                                                        
  putStrLn $ if (maximum . map length . group . sort . concat $ [a,b,c]) == 3                                              
             then "NO"                                                                                                     
             else "YES"

Measured memory_bytes: 508
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mod 1000000007
#define fst first
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//ユークリッドの互除法
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }


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

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

const int MAXN = 1e5 + 10; //dummy
const ll MOD = 1e9 + 7;

template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}

vector<int> job[MAXN];

void solve(){
	int n, m;
	cin >> n >> m;

	for(int i= 0, x, y; i < n; ++i){
		cin >> x >> y;
		job[x].push_back(y);
	}

	multiset<int> available;
	int ans = 0;
	for(int i = m - 1; i >= 0; --i){
		for( int x: job[m - i]){
			available.insert(x);
		}
		if( !available.empty() ){
			auto it = available.end();
			it--;
			ans += *it;
			available.erase(it);
		}
	}

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

int main(){
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 7808
from collections import Counter

H, W, N, *AB = map(int, open(0).read().split())

move = [
    (-1, -1), (-1, 0), (-1, 1),
    (0, -1),  (0, 0),  (0, 1),
    (1, -1),  (1, 0),  (1, 1),
]

C = Counter()
for a, b in zip(*[iter(AB)] * 2):
    C.update(
        (a - i, b - j)
        for i, j in move
        if 2 <= a - i <= H - 1 and 2 <= b - j <= W - 1
    )

D = [0] * 10
for v in C.values():
    D[v] += 1

print((H - 2) * (W - 2) - len(C))
for i in range(1, 10):
    print(D[i])


Measured memory_bytes: 178292
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" << endl;
	}
	else if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}




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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  vector<vector<int> > r(h), c(w);
  for (int i = 0; i < h; i++) {
    r[i].push_back(-1);
  }
  for (int j = 0; j < w; j++) {
    c[j].push_back(-1);
  }
  for (int i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        r[i].push_back(j);
        c[j].push_back(i);
      }
    }
  }
  for (int i = 0; i < h; i++) {
    r[i].push_back(w);
  }
  for (int j = 0; j < w; j++) {
    c[j].push_back(h);
  }
  vector<vector<int> > ans(h + 1, vector<int>(w + 1, 0));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < r[i].size() - 1; j++) {
      int d = r[i][j + 1] - r[i][j] - 1;
      ans[i][r[i][j] + 1] += d;
      ans[i][r[i][j + 1]] -= d;
      ans[i + 1][r[i][j] + 1] -= d;
      ans[i + 1][r[i][j + 1]] += d;
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < c[i].size() - 1; j++) {
      int d = c[i][j + 1] - c[i][j] - 1;
      ans[c[i][j] + 1][i] += d;
      ans[c[i][j] + 1][i + 1] -= d;
      ans[c[i][j + 1]][i] -= d;
      ans[c[i][j + 1]][i + 1] += d;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      ans[i][j + 1] += ans[i][j];
    }
  }
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w; j++) {
      ans[i + 1][j] += ans[i][j];
    }
  }
  int res = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      res = max(res, ans[i][j]);
    }
  }
  cout << res - 1 << endl;
}


Measured memory_bytes: 56064
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6 + 69;

ll n,m,k,x,y,ans;

ll A[N];

vector< ll > v;

string s;

int main(){

    ios::sync_with_stdio(0);

    cin>>n>>k;

    for(int i=1;i<=n;i++){
        cin>>A[i];
    }

    sort(A+1,A+1+n);

    for(int i=1;i<=n-k;i++){
        ans += A[i];
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
ld dp[3000][3000];

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

    ld p[n+1];
    rep(i, 1, n + 1){
        cin >> p[i];
    }

    rep(i, 0, n + 1){
        rep(j, 0, i + 1){
            if(i == 0){
                dp[i][j] = 1;
            }else if(j == 0){
                dp[i][j] = dp[i-1][j] * (1 - p[i]);
            }else{
                dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i];
            }
        }
    }

    ld sum = 0;
    rep(i, ceil(n / 2.0), n + 1){
        sum += dp[n][i];
    }
    printf("%.10Lf\n", sum);
    return 0;
}


Measured memory_bytes: 139136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n,h,w; cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //
		Scanner input = new Scanner(System.in);
		int R = input.nextInt();
		int C = input.nextInt();
		boolean[] badRows = new boolean[R];
		boolean[] badCols = new boolean[C];
		String[] rows = new String[R];
		for (int r = 0; r < R; r++) {
			rows[r] = input.next();
			boolean bad = true;
			for (int c = 0; c < C; c++) {
				if (rows[r].charAt(c)=='#') {
					bad=false;
					break;
				}
			}
			if (bad) badRows[r]=true;
		}
		for (int c = 0; c < C; c++) {
			boolean bad = true;
			for (int r = 0; r < R; r++) {
				if (rows[r].charAt(c)=='#') {
					bad=false;
					break;
				}
			}
			if (bad) badCols[c]=true;
		}
		for (int r = 0; r < R; r++) {
			if (!badRows[r]) {
				String ans = "";
				for (int c = 0; c < C; c++) {
					if (!badCols[c]) ans+=rows[r].substring(c,c+1);
				}
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 28308
// ABC045 B - 3人でカードゲームイージー

#include <stdio.h>

int main(void) {
    char A[101];
    char B[101];
    char C[101];

    // input
    scanf("%s", A);
    scanf("%s", B);
    scanf("%s", C);

    int a_top = 0, b_top = 0, c_top = 0;
    char next;
    char winner;

    next = A[a_top++];

    while(1) {
        if (next == 'a') {
            next = A[a_top++];
            if (next =='\0') {
                winner = 'A';
                break;
            }
        } else if (next == 'b') {
            next = B[b_top++];
            if (next == '\0') {
                winner = 'B';
                break;
            }
        } else if (next == 'c') {
            next = C[c_top++];
            if (next == '\0') {
                winner = 'C';
                break;
            }
        }
    }

    // output
    printf("%c\n", winner);

    return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    long x[N];
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    long res = LONG_MAX;
    for(int i=0;i<=N-K;i++){
        if(x[i+K-1]<=0){
            res = min(abs(x[i]),res);
        }else if(x[i]>=0){
            res = min(x[i+K-1],res);
        }else{
            long longer = max(x[i+K-1],-x[i]);
            long shorter = min(x[i+K-1],-x[i]);
            res = min(shorter*2+longer,res);
        }
    }
    cout<<res<<endl;
   
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int d,n;
  cin>>d>>n;
  LL ans=n;
  if(ans%100==0)++ans;
  REP(i,0,d){
    ans*=100;
  }
  cout<<ans<<endl;
  


  return 0;
}


Measured memory_bytes: 256
//copy
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>
 
using namespace std;
 
typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;
 
const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;
 
template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }
 
char S[200050];
 
int main() {
  scanf("%s", S);
  const int N = strlen(S);
 
  int cnt[26] = {};
  Int res = 1;
  for (int i = 0; i < N; ++i) {
    res += i - cnt[S[i] - 'a'];
    ++cnt[S[i] - 'a'];
  }
  
  printf("%lld\n", res);
 
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
        int a,b,k,i,s,c;
        scanf("%d%d%d",&a,&b,&k);

        s=a+k;c=b-k;
        for(i=a;i<=b;i++){
                if(i<s || i>c)printf("%d\n",i);
        }
        return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

ll n,k;
ll md = 1000000000+7;

vvi MUL(vvi A, vvi B) {
    vvi C;
    rep(i,0,n) C.pb(vi(n,0));
    rep(i,0,n) {
        rep(j,0,n) {
            rep(z,0,n) {
                C[i][j] += (A[i][z] * B[z][j]) % md;
                C[i][j] %= md;
            }
        }
    }
    return C;
}

vvi mod_pow(vvi A, ll p) {
    if(p % 2 == 0) {
        vvi F = mod_pow(A,p/2);
        return MUL(F,F);
    } else {
        if(p == 1) return A;
        return MUL(mod_pow(A,p-1), A);
    }
}

int main() {
    cin.sync_with_stdio(false);
    cin >> n >> k;
    vvi A;
    rep(i,0,n) A.pb(vi(n));
    rep(i,0,n) {
        rep(j,0,n) cin >> A[i][j];
    }
    vvi T = mod_pow(A,k);
    ll tts = 0;
    rep(i,0,n) rep(j,0,n) {
        tts += T[i][j];
        tts %= md;
    }
    cout << tts << endl;
    return 0;
}


Measured memory_bytes: 4096
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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 MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, cnt = 0,ans = 0; cin >> N;
    VI A(100000, 0);
    REP(i, N) {
        int a;
        cin >> a;
        a--;
        A[a]++;
    }
    REP(i, 100000) {
        if (A[i] == 0) continue;
        ans++;
        if (A[i] % 2 == 0) {
            cnt++;
        }
    }
    if (cnt % 2 == 1) ans--;
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 640
import java.math.BigDecimal

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (a, b) = readLine()!!.split(" ").map { it.toBigDecimal() }
    println((a * b).setScale(0, BigDecimal.ROUND_FLOOR))
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

char s[maxn], t[maxn];

int main() {
    scanf("%s", s);
    int res = 0, ans = 0, n = strlen(s);
    for (int i = 0; i < n; i++) t[i] = s[i];
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) s[i] = (s[i] - '0' + 1) % 2 + '0', res++;
    }
    for (int i = n - 2; i >= 0; i--) {
        if (t[i] == t[i + 1]) t[i] = (t[i] - '0' + 1) % 2 + '0', ans++;
    }
    printf("%d\n", min(res, ans));
    return 0;
}


Measured memory_bytes: 384
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[4] = {0};
	int ans = 0;
	scanf("%s", S);
	switch(S[0]) {
	case 'S':
		if (S[1] == 'U') {
			ans = 7;
		} else {
			ans = 1;
		}
		break;
	case 'M':
		ans = 6;
		break;
	case 'T':
		if (S[1] == 'U') {
			ans = 5;
		} else {
			ans = 3;
		}
		break;
	case 'W':
		ans = 4;
		break;
	case 'F':
		ans = 2;
		break;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128