akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

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

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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n==m?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;  
    ll w;
    cin >> n >> w;
    vector<vector<ll> > st(4);
    ll cw;
    for (int i = 0;i < n;i++){
        ll a,b;
        cin >> a >> b;
        if (i == 0) cw = a;
        st[a-cw].push_back(b);
    }
    for (int i = 0;i < 4;i++){
        sort(st[i].begin(),st[i].end());
        st[i].push_back(0);
        reverse(st[i].begin(),st[i].end());
        for (int j = 1;j < int(st[i].size());j++){
            st[i][j] += st[i][j-1];  
        }
    }
    ll ans = 0;
    for (int i = 0;i < int(st[0].size());i++){
        for (int j = 0; j < int(st[1].size());j++){
            for (int k = 0; k < int(st[2].size());k++){
                for (int h = 0; h < int(st[3].size());h++){
                    if (cw*i+(cw+1)*j+(cw+2)*k+(cw+3)*h <= w){
                        ll now = st[0][i] + st[1][j] +st[2][k] + st[3][h];
                        ans = max(now,ans);
                    }
                }
            }
        }
    }

    cout << ans << endl;


    
    
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int a,b;
	cin >> a >> b;
	int n = 1;
	int c = 0;
	while (n < b) {
		n += a-1;
		c++;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

bool valid(int mask){
   while(mask!=0){
      if((mask&3)==3) return false;
      mask/=2;
   }
   return true;
}
int main(){
   int H,W,K;
   cin >> H >> W >> K;
   int mod = 1000000007;
   long long dp[H+1][W];
   for(int i =0; i<H+1; i++)for(int j=0; j<W; j++) dp[i][j]=0;
   int pattern[W][3];//0 = not move, 1 = -1, 2 = +1
   memset(pattern, 0 , sizeof(pattern));
   int tot = 0;
   for(int mask = 0 ; mask < (1<<(W-1)); mask++){
      if(valid(mask)){
         tot++;
         for(int i=0; i < W-1; i++){
            if((mask&(1<<i))!=0){
               // switch i and i+1
               pattern[i+1][1]++;
               pattern[i][2]++;
            }
         }
      }
   }
   for(int i= 0 ; i < W; i++){
      pattern[i][0]=tot-pattern[i][1]-pattern[i][2];
      //cout << pattern[i][0] << ", "<< pattern[i][1] <<", " << pattern[i][2] << endl;
   }

   dp[0][0]=1;
   for(int h = 0 ; h < H; h++){
      for(int w = 0 ; w < W; w++){
         if( dp[h][w]!=0 ){
            long long tmp = pattern[w][0]*dp[h][w];
            dp[h+1][w] += tmp;
            dp[h+1][w] %= mod;
            if(w-1 >= 0 ){
               long long tmp2 = pattern[w][1]*dp[h][w];
               dp[h+1][w-1] += tmp2;
               dp[h+1][w-1] %= mod;
            }
            if(w+1 <= W-1){
               long long tmp3 = pattern[w][2]*dp[h][w];
               dp[h+1][w+1] += tmp3;
               dp[h+1][w+1] %= mod;
            }
         }
      }
   }
   cout << dp[H][K-1]<<endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;
 
 
 
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b;
	rep(i,n) cin >>a[i];
	ll ans=0, bf = 0;
	rep(i,n-1){
		int cf = a[i+1] - a[i];
		if(cf>0) cf=1;
		if(cf<0) cf=-1;
		if(cf==0) continue;
		if(bf*cf<0){ ans++; cf=0;}
			
		bf=cf;
	}
	cout << ans + 1<<endl;
	return 0;
}

Measured memory_bytes: 640
package main

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

const mod = 1000000007

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

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

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	h, _ := nextInt(), nextInt()
	c := make([]string, h)
	for i := 0; i < h; i++ {
		c[i] = next()
	}

	for i := 0; i < 2*h; i++ {
		fmt.Println(c[i/2])
	}
}


Measured memory_bytes: 640
H, W, A, B = map(int, input().split())
MOD = 10**9 + 7
c1 = []
c2 = []
for i in range(H-A):
    if i == 0:
        c1.append(1)
        c2.append(1)
    else:
        m = pow(i, MOD-2, MOD)
        t1 = (c1[i-1]*(B-1+i) % MOD) * m
        c1.append(t1 % MOD)
        t2 = (c2[i-1]*(W-B-1+i) % MOD) * m
        c2.append(t2 % MOD)
for i in range(H-A, H):
    t = (c2[i-1]*(W-B-1+i) % MOD) * pow(i, MOD-2, MOD)
    c2.append(t % MOD)
ans = 0
for i in range(len(c1)):
    ans += (c1[i]*c2[-i-1]) % MOD
print(ans % MOD)


Measured memory_bytes: 10600
#!/usr/bin/env ruby

def koch(n, p1, p2)
  return if n.zero?
  s = {}
  t = {}
  u = {}

  # s, t
  s[:x] = (p1[:x] + p1[:x] + p2[:x]) / 3.0
  s[:y] = (p1[:y] + p1[:y] + p2[:y]) / 3.0
  t[:x] = (p1[:x] + p2[:x] + p2[:x]) / 3.0
  t[:y] = (p1[:y] + p2[:y] + p2[:y]) / 3.0

  # u
  u[:x] = (t[:x] - s[:x]) * 0.5 - (t[:y] - s[:y]) * Math.sqrt(3.0) * 0.5 + s[:x]
  u[:y] = (t[:x] - s[:x]) * Math.sqrt(3.0) * 0.5 + (t[:y] - s[:y]) * 0.5 + s[:y]

  koch(n - 1, p1, s)
  puts s.values.join(' ')
  koch(n - 1, s, u)
  puts u.values.join(' ')
  koch(n - 1, u, t)
  puts t.values.join(' ')
  koch(n - 1, t, p2)
end

p1 = { x: 0.0, y: 0.0 }
p2 = { x: 100.0, y: 0.0 }
n = gets.to_i

puts p1.values.join(' ')
koch(n, p1, p2)
puts p2.values.join(' ')

Measured memory_bytes: 7424
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main(){
  int w, h;
  vector<int> v;
  vector<int> ex, ey;
  ex = {1,-1,0,0};
  ey = {0,0,1,-1};
  while (cin >> w >> h, w){
    vector<string> M(h);
    vector< vector<int> > F(h, vector<int>(w,9));
    queue< vector<int> > que_W, que_B;
    for (int i = 0; i < h; ++i){
      cin >> M[i];
      for (int j = 0; j < w; ++j){
	if (M[i][j] == 'W') que_W.push({i,j});
	else if (M[i][j] == 'B') que_B.push({i,j});
	else F[i][j] = 0;
      }
    }
   
    while(!que_W.empty()){
      int x = que_W.front()[0], y = que_W.front()[1];
      que_W.pop();
      for (int i = 0; i < 4; ++i){
	if (0 <= x+ex[i] && x+ex[i] < h && 0 <= y+ey[i] && y+ey[i] < w && !F[x+ex[i]][y+ey[i]]){
	  --F[x+ex[i]][y+ey[i]];
	  que_W.push({x+ex[i],y+ey[i]});
	}
      }
    }
    while(!que_B.empty()){
      int x = que_B.front()[0], y = que_B.front()[1];
      que_B.pop();
      for (int i = 0; i < 4; ++i){
	if (0 <= x+ex[i] && x+ex[i] < h && 0 <= y+ey[i] && y+ey[i] < w && M[x+ex[i]][y+ey[i]] == '.'){
	  ++F[x+ex[i]][y+ey[i]];
	  M[x+ex[i]][y+ey[i]] = '!';
	  que_B.push({x+ex[i],y+ey[i]});
	}
      }
    }
    int W = 0, B = 0;
    for (int i = 0; i < h; ++i){
      for (int j = 0; j < w; ++j){
	if (F[i][j] == 1) ++B;
	if (F[i][j] == -1) ++W;
      }
    }
    cout << B << " " << W << endl;
  }
  return 0;
}

Measured memory_bytes: 3152
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }

    Scanner kbd = new Scanner(System.in);
    double[] dice; // テヲツ慊淌・ツセツ?・ツ?、テ、ツソツ敕・ツュツ?
    int t, n, m, i, j;
    double v, r, p;

    void run(){
	while(kbd.hasNext()){
	    t = kbd.nextInt();
	    dice = new double[t+1];
	    for(i=0; i<t+1; i++){
		n = kbd.nextInt();
		m = kbd.nextInt();
		p = 0;
		for(j=0; j<m; j++){
		    v = kbd.nextDouble();
		    r = kbd.nextDouble();
		    p += r;
		    dice[i] += v*r;
		    // System.out.println("*"+v+" "+r);
		}
		dice[i] = dice[i]/p;
	        //System.out.println(dice[i]+" "+(p+1));
	    }

	    boolean ans = false;
	    for(i=0; i<t; i++){
		if(dice[i] > dice[t]){
		    if(Math.abs(dice[i]-dice[t]) > 0.0000001)
			ans = true;
		}
	    }
		
	    if(ans)
		System.out.println("YES");
	    else
		System.out.println("NO");
	}
    }
}

Measured memory_bytes: 30840
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll h, w, n;
    cin >> h >> w >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> s;
    rep(i, n){
        rep(j, a[i]){
            s.push_back(i+1);
        }
    }
    rep(i, h){
        string tmp = "";
        for(ll j = i*w; j < (i+1)*w; ++j){
            if(j > i*w) tmp += " ";
            tmp += to_string(s[j]);
        }
        cout << tmp << endl;

        ++i;
        if(i == h) break;
        
        tmp = "";
        for(ll j = (i+1)*w-1; j >= i*w; --j){
            if(j < (i+1)*w-1) tmp += " ";
            tmp += to_string(s[j]);
        }
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 3896
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int>res(200005, 0);
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; res[tmp]++;
	}
	sort(res.rbegin(), res.rend());
	int ans = 0;
	for (int i = k; i < 200005; i++)ans += res[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop
class Prim:
    """ find minimum spanning tree by Prim's algorithm
    """

    def __init__(self, V, E, start=0, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (undirected graph)
            start: start vertex
            INF: Infinity cost
        """
        self.prim(V, E, start, INF)

    def prim(self, V, E, start=0, INF=10**9):
        used = [False] * V
        self.mincost = 0
        que = []
        heappush(que, (0, 0))
        while len(que) > 0:
            cost, v = heappop(que)
            if used[v]: continue
            used[v] = True
            self.mincost += cost
            for to, c in E[v]:
                heappush(que, (c, to))

    def minCost(self):
        return self.mincost
    

    
V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    s, t, w = map(int, input().split())
    edge[s].append((t, w))
    edge[t].append((s, w))

msp = Prim(V, edge)
print(msp.minCost())

Measured memory_bytes: 47768
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

bool judge(vector<int> w_dir, vector<int> w_who, int w, int start) {
    int L = 1, R = w;
    for (int i = w_dir.size() - 1; i >= 0; i--) {
        if (w_who[i] == 1) {
            if (w_dir[i] == 1) {
                R--;
            } else {
                L++;
            }
        } else {
            if (w_dir[i] == 1) {
                L = max(L - 1, 1);
            } else {
                R = min(R + 1, w);
            }
        }
        if (R < L) {
            return false;
        }
    }
    if (start >= L && start <= R) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int s_r, s_c;
    string S, T;
    cin >> s_r >> s_c >> S >> T;

    vector<int> w_dir, w_who, h_dir, h_who;
    for (int i = 0; i < n; i++) {
        switch (S[i]) {
            case 'U':
                h_dir.push_back(-1);
                h_who.push_back(1);
                break;
            case 'D':
                h_dir.push_back(1);
                h_who.push_back(1);
                break;
            case 'L':
                w_dir.push_back(-1);
                w_who.push_back(1);
                break;
            case 'R':
                w_dir.push_back(1);
                w_who.push_back(1);
                break;
            default:;
        }

        switch (T[i]) {
            case 'U':
                h_dir.push_back(-1);
                h_who.push_back(0);
                break;
            case 'D':
                h_dir.push_back(1);
                h_who.push_back(0);
                break;
            case 'L':
                w_dir.push_back(-1);
                w_who.push_back(0);
                break;
            case 'R':
                w_dir.push_back(1);
                w_who.push_back(0);
                break;
            default:;
        }
    }

    if (judge(w_dir, w_who, w, s_c) && judge(h_dir, h_who, h, s_r)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 7328
#                         author:  kagemeka 
#                         created: 2019-11-07 11:52:43(JST)
import sys
# import collections
# import math
# import string
import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, *x = (int(i) for i in sys.stdin.read().split())
    s_x = list(sorted(x))
    m_s, m_l = s_x[n // 2 -1], s_x[n // 2]
    for i in x:
        b = bisect.bisect_left(s_x, i)
        print(m_l if b < n // 2 else m_s)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 25052
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 0
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}
int a,b,c;
main(){
	cin>>a>>b;
	dump((a-1)*(b-1));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long i,j,k,l,n,m;
	cin>>n>>m;
	long long a[n];
	//weight
	long long sum1=0;
	long long b[n];
	long long sum=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		sum1=sum1+a[i];
		sum=sum+b[i];
	}
	if(m>=sum1)
	{
		cout<<sum<<"\n";
	}
	else
	{
		long long dp[sum+1];
			for(j=0;j<=sum;j++)
			{
				dp[j]=INT_MAX;
			}
		dp[0]=0;
		for(i=1;i<=n;i++)
		{
			for(j=sum;j>=1;j--)
			{
				if(j>=b[i-1])
				{
					dp[j]=min(dp[j-b[i-1]]+a[i-1],dp[j]);
				}
			}
		}
		long long ans=0;
	/*	for(i=0;i<=sum;i++)
		{
			cout<<dp[i]<<" ";
		}
		cout<<"\n";*/
		for(i=0;i<=sum;i++)
		{
			if(dp[i]<=m)
			{
				ans=max(ans,i);
			}
		}
		cout<<ans<<"\n";
	}
		return 0;
}

Measured memory_bytes: 1024
import sys
from bisect import bisect_left
from operator import itemgetter


class SegTreeMax:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        n2 = 1 << (n - 1).bit_length()
        self.offset = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    def initialize(self, arr):
        for i, v in enumerate(arr, start=self.offset):
            self.tree[i] = v
        for i in range(self.offset - 1, 0, -1):
            j = i << 1
            self.tree[i] = max(self.tree[j], self.tree[j + 1])

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.offset
        self.tree[i] = x
        while i > 1:
            y = self.tree[i ^ 1]
            if y >= x:
                break
            i >>= 1
            self.tree[i] = x

    def get_max(self, a, b):
        """
        [a, b)の最大値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        l = a + self.offset
        r = b + self.offset
        while l < r:
            if r & 1:
                result = max(result, self.tree[r - 1])
            if l & 1:
                result = max(result, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1

        return result


n, *xd = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
xd = sorted(zip(xd[0::2], xd[1::2]))
xxx = list(map(itemgetter(0), xd))
ans = [0] * (n + 1)
skip = list(range(1, n + 1))
ans[n] = 1
sgt = SegTreeMax(n + 1, 0)
sgt.initialize(list(range(1, n + 2)))
for i in range(n - 1, -1, -1):
    x, d = xd[i]
    r = x + d
    j = bisect_left(xxx, r)
    k = sgt.get_max(i, j)
    ans[i] = (ans[i + 1] + ans[k]) % MOD
    sgt.update(i, k)
print(ans[0])


Measured memory_bytes: 122308
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    cout<<3*n*n;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val xList = readLine()?.split(" ")?.map { it.toInt() } ?: return

    val middleIndex = n / 2
    val sortedX = xList.sorted()

    val middleValue = sortedX[middleIndex] // 真っ二つにしたときに、大きい方の1番目に該当する値
    val lessMiddleValue = sortedX[middleIndex - 1] // 真っ二つにしたときに、小さい方のlastに該当する値

    val resultStr = xList.map {
        if (it >= middleValue) {
            lessMiddleValue
        } else {
            middleValue
        }
    }.joinToString("\n")

    println(resultStr)
}

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back;

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(a*b,max(a-b,a+b));
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    string s;
    ll q;
    cin >> s >> q;
    bool flip = false;
    string front, back;
    REP(i, 0, q) {
        ll t;
        cin >> t;
        if (t == 1) {
            flip = !flip;
            continue;
        }
        ll temp;
        char c;
        cin >> temp >> c;
        bool is_insert_back(temp - 1);
        if (is_insert_back == flip) {
            front += c;
        } else {
            back += c;
        }
    }
    string ans;
    if (!flip) {
        ans.assign(string(rbegin(front), rend(front)) + s + back);
    } else {
        ans.assign(string(rbegin(back), rend(back)) + string(rbegin(s), rend(s)) + front);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1348
import sys

MOD = 10 ** 9 + 7

def make_table(n=10**5+1, p=10**9+7):
    fac = [None] * (n + 1)
    fac[0] = 1
    ifac = fac.copy()
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % p
    ifac[n] = pow(fac[n], p - 2, p)
    for i in range(n-1, 0, -1):
        ifac[i] = ifac[i+1] * (i + 1) % p
    return fac, ifac
fac, ifac = make_table()
def comb_mod(n, r, mod=10**9+7):
    if r < 0 or r > n:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

n, *a = map(int, sys.stdin.read().split())

def main():
    appeared = [False] * (n + 1)
    for i in range(n+1):
        cur = a[i] 
        if appeared[cur]:
            x1, x2 = appeared[cur], i+1
            break
        appeared[cur] = i+1
    
    res = [0] * (n + 2)
    for i in range(1, n+2):
        res[i] += comb_mod(n+1, i)
        res[i] %= MOD
    x = (x1 - 1) + (n + 1 - x2)
    
    for i in range(x+1):
        res[i+1] -= comb_mod(x, i)
        res[i+1] %= MOD

    return res[1:]

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 24288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n;
  int d[101];

	cin>>n;

  for (size_t i = 0; i < n; i++) {
    cin >> d[i];
  }

  int ans = 0;

  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      if (i < j) {
        ans += d[i] * d[j];
      }
    }
  }

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
turn = 0
while (A > 0 and C > 0):
    if turn == 0:
        C = C - B
        turn = 1
    else:
        A = A - D
        turn = 0

if A > C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b, c; ll k; cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(1LL * a, k);
  k -= a;
  k -= b;
  if (k > 0) ans -= k;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=4e18;
const ll mod=1e9+7;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline db qd(){
    char c=getchar();int flag=1;double ans=0;
    while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
    if(c=='-') flag=-1,c=getchar();
    while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
    if(c=='.'){c=getchar();for(register int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
    return ans*flag;
}
//start!

int main()
{
	ll n=qi(),ans=0;
	ll tmp=1;
	repi(i,1,n) tmp=tmp*10%mod;
	ans=(ans+tmp)%mod;
	
	tmp=1;
	repi(i,1,n) tmp=tmp*9%mod;
	ans=(ans-2*tmp%mod)%mod;
	
	tmp=1;
	repi(i,1,n) tmp=tmp*8%mod;
	ans=(ans+tmp)%mod;
	
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll MOD = ll(1e9+7);


int main(){
    string s, t;
    int n, m;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    vector<int> scnt(n+1), tcnt(m+1);
    for(int i=0;i<n;i++){
        scnt[i+1] = scnt[i] + (s[i] == 'A' ? 1 : 2);
    }
    for(int i=0;i<m;i++){
        tcnt[i+1] = tcnt[i] + (t[i] == 'A' ? 1 : 2);
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; c--;
        cout << ((scnt[b]-scnt[a])%3 == (tcnt[d]-tcnt[c])%3 ? "YES" : "NO") << endl;
    }
    return 0;
}

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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()


void solve(){
  ll a,b;
  cin>>a>>b;
  cout<<a*b;
}

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

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

a = list(map(int, input().split()))

res = [0]
tmp = 0

tf = [-1 for i in range(n)]
tf[0] = 0

for i in range(n):
    tmp = a[tmp] - 1
    if tf[tmp] != -1:
        start = tmp
        break
    else:
        res.append(tmp)
        tf[tmp] = i+1

lenret = i+1
stridx = tf[start]

cycle = lenret - stridx

if stridx >= k:
    print(res[k]+1)
    exit()
else:
    k = k - stridx

    tmp = k % cycle

    print(res[stridx+tmp]+1)


Measured memory_bytes: 33436
k, s = gets.chomp.split(" ").map(&:to_i);
cnt = 0
for a in 0..k do 
  break if a > s
  for b in 0..k do
    break if (a + b) > s
    z = s - (a + b)
    cnt += 1 if ( 0 <=z && z <= k) && a + b + z = s
    #puts "pass = #{a} #{b} #{c}"
  end
end
puts cnt


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int> > A(H+1, vector<int>(W+1));
    vector<pair<int, int> > AA(H*W+1);
    for(int h=1; h<=H; h++) {
        for(int w=1; w<=W; w++) {
            cin >> A[h][w];
            AA[A[h][w]] = make_pair(h+1, w+1);
        }
    }

    vector<vector<int> > dist(D+1);
    for(int d=1; d<=D; d++) {
        dist[d%D].push_back(0);
        for(int i=1; i*D+d<=H*W; i++) {
            dist[d%D].push_back(dist[d%D][i-1] + abs(AA[(i-1)*D+d].first-AA[i*D+d].first)\
                +abs(AA[(i-1)*D+d].second-AA[i*D+d].second));
            // cout << dist[d%D][i] << endl;
        }
    }
    
    // cout << endl;
    // for(int d=1; d<=D; d++) {
    //     for(int i=0; i*D+d<=H*W; i++) {
    //         cout << dist[d%D][i] << ", ";
    //     }
    //     cout << endl;
    // }
    
    int Q;
    cin >> Q;
    for(int q=0; q<Q; q++) {
        int L, R;
        cin >> L >> R;
        if(L%D!=0) {
            cout << dist[L%D][R/D]-dist[L%D][L/D] << endl;
        } else {
            cout << dist[L%D][R/D-1]-dist[L%D][L/D-1] << endl;
        }
    }

    return 0;
    
}

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

int main(void)
{
	int s[1000], n, i, sum;
	double m, d, a, t;

	for (;;) {
		scanf("%d", &n);
		if (n == 0) break;
		sum = 0;
		for (i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			sum += s[i];
		}
		m = (double) sum / (double) n;
		a = 0.0;
		for (i = 0; i < n; i++) {
			t = s[i] - m;
			a += t * t;
		}
		printf("%lf\n", sqrt(a / n));
	}

	return 0;
}



Measured memory_bytes: 2036
x = int(input())
data = [""]
for i in range(3,x+1):
  flag = 0

  for j in str(i):
    if int(j) == 3:
      flag = 1
  if i % 3 == 0:
    flag = 1
  if flag == 1:
    data.append(i)
ans = ' '.join(map(str, data))
print(ans)


Measured memory_bytes: 6100
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    string s;cin >> s;
    string alp="abcdefghijklmnopqrstuvwxyz";
    map<string,int> m;

    for(int i=0;i<s.size();i++){
        m[s.substr(i,1)]++;
    }

    for(int i=0;i<alp.size();i++){
        if(m[alp.substr(i,1)]==0) {
            p(alp.substr(i,1))
            return 0;
        }
    }
    p("None")
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) cin >> A[i][j];
    }

    vector<vector<int>> dist(A);
    for(int k=0; k<N; ++k) {
        for(int i=0; i<N; ++i) {
            for(int j=0; j<N; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    long long res = 0;
    for(int i=0; i<N; ++i) {
        for(int j=i+1; j<N; ++j) {
            if(dist[i][j] < A[i][j]) {
                cout << -1 << endl;
                return 0;
            } else {
                int k=0;
                for(; k<N; ++k) {
                    if(k == i || k == j) continue;
                    if(dist[i][j] == dist[i][k] + dist[k][j]) break;
                }
                if(k == N) res += A[i][j];
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
 int n, a;
 cin >> n >> a;
 if (n % 500 <= a) cout << "Yes\n";
 else cout << "No\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = 0;
    if(str.equals("SUN")){
      ans = 7;
    }else if(str.equals("MON")){
      ans = 6;
    }else if(str.equals("TUE")){
      ans = 5;
    }else if(str.equals("WED")){
      ans = 4;
    }else if(str.equals("THU")){
      ans = 3;
    }else if(str.equals("FRI")){
      ans = 2;
    }else if(str.equals("SAT")){
      ans = 1;
    }
    System.out.println(ans);
  }
}
    
    

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



int main() {
  
  int H, W, K;
  scanf("%d %d %d", &H, &W, &K);
  
  vector<vector<char>> v(H, vector<char>(W));

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf(" %c", &v[i][j]);
    }
  }

  int N_Pattern=0;
  int bi, bj, S;
  for(int i=0;i<pow(2,H);i++){
    for(int j=0;j<pow(2,W);j++){

      S = 0;

      bi = i;
      for(int ii=0;ii<H;ii++){

        bj = j;
        for(int jj=0;jj<W;jj++){
          
          if(bi%2==1 && bj%2==1 && v[ii][jj]=='#'){
            S+=1;
          }
          bj/=2;
        }

        bi/=2;
      }

      if(S==K){N_Pattern++;}
      
    }
  }

  printf("%d\n", N_Pattern);

  return 0;
}




Measured memory_bytes: 4172
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()

int m;

int main()
{
    std::cin >> m;
    
    rep( i, m )
    {
        std::set<std::string> S;

        std::string s;
        std::cin >> s;

        rep( i, s.size()-1 )
        {
            std::string t1[2] = { s.substr( 0, i+1 ), s.substr( 0, i+1 ) }, t2[2] = { s.substr( i+1 ), s.substr( i+1 ) };
            std::reverse( all(t1[1]) );
            std::reverse( all(t2[1]) );

            rep( j, 2 ) rep( k, 2 )
            {
                S.insert( t1[j]+t2[k] );
                S.insert( t2[k]+t1[j] );
            }
        }

        std::cout << S.size() << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3236
import sys

n,k0=map(int,input().split())
v=list(map(int,input().split()))

k=k0
if n<=k:
    v.sort()
    vsum=sum(v)
    kk=k-n
    vsum=0
    for i in range(n):
        if i>kk:
            vsum+=v[i]
        elif i<=kk and v[i]>0:
            vsum+=v[i]
    print(max(0,vsum))
    sys.exit()

vmax=-10**10

kk=k0
for k in range(kk):
    k2=kk-k-1
    
    vv=[[0]*(k+1) for i in range(k+1+1)]
    for i in range(k+1):
        vv[0][i]=v[n-k+i-1]
    vsum=sum(vv[0])
    vmax=max(vsum,vmax)
#    print("k:",k,"vsum:",vsum,"vmax:",vmax)
#    print(vv[0])
    vvv=vv[0].copy()
    vvv.sort()
    for i in range(min(k2,k+1)):
        if vvv[i]<0:
            vsum-=vvv[i]
    vmax=max(vsum,vmax)
#    print("k:",k,"vsum:",vsum,"vmax:",vmax)

    for i in range(k+1):
        vv[i+1]=vv[i].copy()
        vv[i+1].pop(0)
        vv[i+1].append(v[i])
        vsum=sum(vv[i+1])
        vmax=max(vsum,vmax)
#        print("k:",k,"vsum:",vsum,"vmax:",vmax)
#        print(vv[i+1])
        vvv=vv[i+1].copy()
        vvv.sort()
        for i in range(min(k2,k+1)):
            if vvv[i]<0:
                vsum-=vvv[i]
        vmax=max(vsum,vmax)
#        print("k:",k,"vsum:",vsum,"vmax:",vmax)
    
print(max(0,vmax))    



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

using namespace std;

#define min(a,b) (a < b ? a : b)

int main(void){
	int d,g,ans=1000000000;
	cin >> d >> g;
	vector<int> q;
	vector<int> bonus;
	vector<int> use(d);
	for(int i=0;i<d;++i){
		int p,c;
		cin >> p >> c;
		q.push_back(p);
		bonus.push_back(c);
	}
	for(int i=0;i<(1<<d);++i){
		int res = 0;
		int count = 0;
		for(int j=0;j<d;++j){
			use[j] = (i>>j)%2;
		}
		for(int j=0;j<d;++j){
			if(use[j] == 1){
				res += 100 * (j+1) * q[j] + bonus[j];
				count += q[j];
			}
		}
		int unuse;
		if(res < g){
			for(int j=d-1;j>=0;j--){
				if(use[j] == 0){
					unuse = j;
					break;
				}
			}
		}
		int cc = 0;
		while(cc < q[d-unuse-1] && res < g){
			res += 100 * (unuse + 1);
			cc++;
			count++;
		}
		if(res >= g)ans = min(ans,count);
	}
	cout << ans << endl;
}

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

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

	int N, a, b, c, d;
	int red[200][200] = {}, blue[200][200] = {};
	cin >> N;
	rep(i, N) {
		cin >> a >> b;
		red[a][b] = 1;
	}
	rep(i, N) {
		cin >> c >> d;
		blue[c][d] = 1;
	}
	int kotae = 0;
	rep(i, 2 * N) {
		rep(ii, 2 * N) {
			int nukeru = 0;
			if (blue[i][ii]) {
				rep1(iii, ii) {
					rep1(iiii, i) {
						if (red[i - iiii][ii - iii]) {
							kotae++;
							red[i - iiii][ii - iii] = 0;
							nukeru = 1;
							break;
						}
					}
					if (nukeru) break;
				}
			}
		}
	}
	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  int a=s.size(),z=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='A') a=min(a,i);
    if(s[i]=='Z') z=max(z,i);
  }
  cout<<z-a+1<<endl;
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/perl

$line = 0;
while(<>) {
    chomp;
    if ($line == 0) {
        $n = $_;
    } else {
        @p = split /\s+/, $_;
    }
    $line++;
}

$cnt = 0;
foreach $i (0 .. $#p) {
    if ($i + 1 == $p[$i]) {
        if ($flag == 1) {
            $flag = 0;
        } else {
            $cnt++;
            $flag = 1;
        }
    } else {
        if ($flag == 1) {
            $flag = 0;
        }
    }
}

print "$cnt\n";


Measured memory_bytes: 16716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    LL cnt[26] = {};
    REP(i,S.length())
    {
        cnt[S[i]-'a']++;
    }
    LL comp = 0;
    REP(i,26)
    {
        comp += cnt[i]*(cnt[i]-1) /2;
    }
    LL ans = 1LL * SZ(S) * (SZ(S)-1) / 2 - comp;
    cout << ans+1 << endl;

}

Measured memory_bytes: 720
#include <cstdio>

int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main(){
    int a,b,k;
    cin >> a >> b >> k;

    int i=a;
    if ((k-1)*2 >= (b-a)-1){
	for (int i=a;i<=b;i++) cout << i << endl;
    } else {
	for (int i=a;i<a+k;i++) cout << i << endl;
	for (int i=b-k+1;i<=b;i++) cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt();
		if(a-b>0) {
			System.out.println(a-b);
		}else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll n;
    cin>>n;
    set<string> a;
    string s;
    for(ll i=0;i<n;i++){
        cin>>s;
        a.insert(s);
    }
    cout<<a.size();


    return 0;
}


Measured memory_bytes: 19156
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

long long cntA[200005];

int main(void) {
    string s; cin >> s;
    int N = s.length();
    char now[] = {'A', 'B', 'C'};
    int state = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A') {
            cntA[i] = 1;
            if (i-1 >= 0) cntA[i] += cntA[i-1];
        }
        if (s[i] == now[state]) {
            state++;
        } else if (s[i] == 'A') {
            state = 1;
        } else {
            state = 0;
        }
        if (state == 3) {
            if (i-2 >= 0){
                cntA[i] = cntA[i-2];
                ans += cntA[i-2]; 
            }
            state = 1;
        }
    }
    cout << ans << endl;
}   


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

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

    rep(i, B){
        int x = ((i + 1) * A) % B;
        if(x == C){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val str = readLine()!!.toString()
    var l = 0
    var r = k - 1
    var ans = 0
    while (l < r) {
        while (str[l] == 'R') {
            l++
            if (l !in str.indices) {
                println(ans)
                return
            }
        }
        while (str[r] == 'W') {
            r--
            if (r !in str.indices) {
                println(ans)
                return
            }
        }
        if (l < r) {
            ans++
            l++
            r--
        }
    }
    println(ans)
}

Measured memory_bytes: 39128
S = input()
lis = list()
for i in range(len(S)):
    if i % 2==0:
        if S[i] == "U" or S[i] == "R"or S[i] == "D":
            lis.append(True)
        else:
            lis.append(False)
    else:
        if S[i] == "L" or S[i] == "U"or S[i] == "D":
            lis.append(True)
        else:
            lis.append(False)


if all(lis):
    print("Yes")
else:
    print("No")

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

const int INF = 1001001001;

int main()
{

    int n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        if (a[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }
    long long ans = 1;
    long long reg = 1;
    rep(i, 18) reg *= 10;
    long long reg2 = 1;
    rep(i, 18) reg2 *= 10;
    rep(i, n)
    {
        reg2/=a[i];
        if (ans > reg || a[i] > reg||reg2==0)
        {
            cout << -1;
            return 0;
        }
        ans = ans * a[i];

    }

    if (ans > reg)
    {
        cout << '-1';
        return 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4052