akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

const long int INF=1L<<60;
int N;
long int h[100001];
long int memo[100001];

void swap(long int* a, long int* b) {
    long int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void swmin(long int* origin, long int comp) {
    if(*origin > comp) {
        swap(origin, &comp);
    }
}

long int rec(int i) {
    if(i==0) return 0;
    if(memo[i]!=-1) return memo[i];
    
    long int res=INF;
    swmin(&res, rec(i-1)+abs(h[i]-h[i-1]));
    if(i>1) swmin(&res, rec(i-2)+abs(h[i]-h[i-2]));
    memo[i] = res;
    return res;
}

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

    memset(memo, -1, sizeof(memo));
    
    long int ans;
    ans = rec(N-1);
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 6528
N=gets.to_i
A,B=gets.split.map &:to_i
P=gets.split.map &:to_i
c=0
while true do
    p1=P.index{|x|x<=A}
    if !p1 then break end
    P.delete_at(p1)
    p2=P.index{|x|x>A&&x<=B}
    if !p2 then break end
    P.delete_at(p2)
    p3=P.index{|x|x>B}
    if !p3 then break end
    P.delete_at(p3)
    c+=1
end
p c

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>

int main()
{
    int l, flag, i;
    char ch1[20], ch2[20], ch3[20];
    scanf("%s %s", ch1, ch2);
    l=strlen(ch2);
    for (i=0; i<l-1; i++) ch3[i]=ch2[i];
    ch3[i++]='\0';
    flag=strcmp(ch1, ch3);
    if (flag==0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 1620
def main():
    h,w = map(int,input().split())
    ans=min(h,w)
    if h%3==0 or w%3==0:
        print(0)
        return
    for i in range(h+1):
        s1=i*w
        s2=(w//2)*(h-i)
        s3=(w-(w//2))*(h-i)
        ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))
    for i in range(w+1):
        s1=i*h
        s2=(h//2)*(w-i)
        s3=(h-(h//2))*(w-i)
        ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))
    print(ans)
    
if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> v1(n);
  vector<pair<ll, ll>> v2(m);
  rep(i, n) {
    cin >> v1[i].first >> v1[i].second;
  }
  rep(i, m) {
    cin >> v2[i].first >> v2[i].second;
  }
  ll low, tmp;
  int ans;
  rep(i, n) {
    ans = 1;
    low = abs(v1[i].first - v2[0].first) + abs(v1[i].second - v2[0].second);
    rep(j, m) {
      tmp = abs(v1[i].first - v2[j].first) + abs (v1[i].second - v2[j].second);
      if (tmp < low) {
        low = tmp;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
	return 0;
}



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

ll N, M, V, P;
ll A[100010];

ll search(void){
	ll ok = N, ng = -1;
	while(ok - ng > 1){
		ll mid = (ok + ng)/2, cnt = 0, s = 0;
		for(int i=0; i<N; i++){
			if(A[i] > A[mid] + M) cnt++;
		}
		if(cnt >= P) ng = mid;
		else{
			if(V <= P) ok = mid;
			else{
				int cn = 0;
				for(int i=0; i<N; i++){
					if(cn == N-P) continue;
					if(i == mid) continue;
					s += min(A[mid] + M - A[i], M);
					cn++;
				}
				if(s >= (V-P)*M) ok = mid;
				else ng = mid;
			}
		}
	}
	return ok;
}

int main(){
	cin >> N >> M >> V >> P;
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A, A+N);
	ll ans = search();
	cout << N - ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll x, y,an=99999999999,n=0;
	cin >> x >> y;
	if (y >= x) {
		an = min(an, y - x);
	}

	if (y >= -x) {
		an = min(an, y + x + 1);
	}

	if (-y >= -x) {
		an = min(an, -y + x + 2);
	}

	if (-y >= x) {
		an = min(an, -y - x + 1);
	}

	cout << an << endl;
}



Measured memory_bytes: 256
n = int(input())
count = 0
arr  = [1,2,3,4,5,6,7,8,9]

while len(arr)<n:
    lastnum = int(str(arr[count])[-1])
    if lastnum == 0:
        arr.append(int(str(arr[count])+'0'))
        arr.append(int(str(arr[count])+'1'))
    elif 1 <= lastnum <= 8:
        arr.append(int(str(arr[count])+str(lastnum-1)))
        arr.append(int(str(arr[count])+str(lastnum)))
        
        arr.append(int(str(arr[count])+str(lastnum+1)))
    else:
        arr.append(int(str(arr[count])+'8'))
        arr.append(int(str(arr[count])+'9'))
    count += 1

print(arr[n-1])

Measured memory_bytes: 45912
<?php 
list($N)=sscanf(trim(fgets(STDIN)),"%d");
list($S)=sscanf(trim(fgets(STDIN)),"%s");
if($N % 2 == 1){
    printf("No");
    exit;
}
$l = (int)$N/2;
if(substr($S,0,$l) == substr($S,$l*-1)){
    printf("Yes");
}else{
    printf("No");
}

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

int N,K,p[1000];
int main(){
    cin >> N >> K;
    for(int i = 0;i < N;i++){
        cin >> p[i];
    }
    sort(p,p+N);
    int ans = 0;
    for(int i = 0;i < K;i++){
        ans+=p[i];
    }
    cout << ans;
}

Measured memory_bytes: 3144
import java.util.*;
import java.io.*;
public class Main
{
    static BufferedReader br;
    static BufferedWriter bw;
    static void solve()throws Exception
    {
        String s = br.readLine();
        String d = br.readLine();
        if((s.length()+1) != d.length())
        bw.write("No");
        else
        {
            boolean flag = true;
            for(int i=0;i<s.length();i++)
            {
                if(s.charAt(i)!=d.charAt(i))
                {
                    flag = false;
                    break;
                }
            }
            if(flag)
            bw.write("Yes");
            else
            bw.write("No");
        }
    }
    public static void main(String []args)throws Exception
    {
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));
        solve();
        br.close();
        bw.close();
    }
}

Measured memory_bytes: 25356
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str = sc.next(),ans="";
    for(int i=0;i<str.length();i++){
      if(str.charAt(i)=='1'){
        ans+="9";
      }
else if(str.charAt(i)=='9'){
        ans+="1";
      }
else{
        ans+=str.charAt(i)+"";
}
    }
System.out.print(ans);
  }
}

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
    ll N; cin >> N;
    auto mp = prime_factor(N);
    int ans = 0;
    for(auto &p : mp){
        int n = p.second;
        int sume = 0, e = 1;
        while(true){
            sume += e;
            if(sume > n) break;
            e++; ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
int M=1e9+7;
using namespace std;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll max;
	max=a*c;
	if(a*d>max)
	max=a*d;
	if(b*c>max)
	max=b*c;
	if(b*d>max)
	max=b*d;
	cout<<max;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 3e2+5, oo = 0x3f3f3f3f;
int n, m, c[N], ans, d[N][N]; char s[N][N];
void dfs(int x, int w)
{
    c[x] = w;
    for(int y = 1; y <= n; ++y) if(s[x][y] == '1')
    {
        if(!c[y]) dfs(y, w^1);
        else if(c[y] != (w^1)) puts("-1"), exit(0);
    }
}
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    dfs(1, 2); for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) 
        if(i == j) d[i][j] = 0; else if(s[i][j] == '1') d[i][j] = 1; else d[i][j] = oo;
    for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j)
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    for(int i = 1; i <= n; ++i) ans = max(ans, *max_element(d[i]+1, d[i]+n+1));
    printf("%d\n", ans+1);
    return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

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

char s[200010];
int a[200010], cnt[10010];
int main()
{
    int n, p;
    scanf("%d%d%s", &n, &p, s + 1);
    cnt[0]++;
    for (int i = n, cur = 1; i >= 1; i--) {
        a[i] = ((s[i] - '0') * cur % p + a[i + 1]) % p;
        cur = cur * 10 % p;
        cnt[a[i]]++;
    }
    ll ans = 0;
    if (p == 2 || p == 5) {
        memset(cnt, 0, sizeof cnt);
        for (int i = 1; i <= n; i++)
            if ((s[i] - '0') % p == 0)
                ans += i;
    } else
        for (int i = 1; i <= n; i++) {
            cnt[a[i]]--;
            ans += cnt[a[i]];
        }
    cout << ans << endl;

    /*for (int i = 1; i <= n; i++) {
        int tmp = 0;
        for (int j = i; j <= n; j++) {
            tmp = (tmp * 10 % p + s[j] - '0') % p;
            if (!tmp)
                ans--;
        }
    }
    printf("%lld\n", ans);*/
}


Measured memory_bytes: 1280
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

int main(){
  string n="",ans="";
  cin >> n;
  for(int i=0;i<3;++i){
    if(n[i]=='1'){
      ans += '9';
    }else if(n[i]=='9'){
      ans += '1';
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>

using namespace std;
		
int main(void){
	string str,search;
	cin>>str>>search;
	while(str.size()<=100){
		str = str + str;
	}
	if(str.find(search)==-1)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		int d[12][12]={};
		rep(i,0,n) rep(j,0,n){
			cin>>d[i][j]; d[i][n]+=d[i][j];
		}
		rer(i,0,n) rep(j,0,n) d[n][i]+=d[j][i];
		rer(i,0,n){
			rer(j,0,n){
				printf("%5d",d[i][j]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1164
// std::set を用いた解
#include <iostream>
#include <set>
using namespace std;

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

  set<int>values;
  for (int i=0; i<N; i++){
    values.insert(d[i]);
  }

    // set のサイズを出力します
    cout << values.size() << endl;
}

Measured memory_bytes: 256
const val INF = 1000000000

fun main(args: Array<String>) {
    val (N, A, B ,C) = readLine()!!.split(" ").map { it.toInt() }
    var L = mutableListOf<Int>()
    for (i in 0 until N) {
        L.add(readLine()!!.toInt())
    }

    fun dfs(cur: Int, a: Int, b: Int, c: Int): Int {
        // ４分木(aに使う, bに, cに, 使わない)を探索し，枝まで到達したら, コストを計算して返す
        // 各接点で min なもののみを残していけばよい
        // コスト計算はそれぞれ出来上がったものと，目標とする長さの差分

        // 全ての枝を使うかどうかの判断が終わっている場合は，その組み合わせでのコストを計算
        // それぞれ必ず一つの枝を使うが，その場合，合成していなくても必ず 10 は足されているので -30 する
        // 必ず a, b, c それぞれに一つの枝を割り当てないといけない，割り当てていない場合は INF を返して候補から除外する
        if (cur == N){
            val cost = abs(A - a) + abs(B - b) + abs(C - c) - 30
            return if(min(listOf(a, b, c)) > 0) cost else INF
        }

        // 4つの分岐先のコストをそれぞれ計算
        val one = dfs(cur+1, a, b, c)
        val two = dfs(cur+1, a + L[cur], b, c) + 10
        val three = dfs(cur+1, a, b + L[cur], c) + 10
        val four = dfs(cur+1, a, b, c + L[cur]) + 10

        return min(listOf(one, two, three, four))
    }

    print(dfs(0,0,0,0))
}


fun abs(x: Int): Int{
    return if(x<0) -1 * x else x
}

fun min(x: List<Int>): Int{
    var m = x[0]
    for (v in x) {
        if (m > v) m = v
    }
    return m
}

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

int main(){
  int n, h, keep = 0, ans = 0;
  cin >> n;
  
  rep(i,n){
  cin >> h;
    if (keep < h) {ans += h - keep; keep = h;continue;}
    if (keep >= h) {keep = h; continue;} 
  }
  cout << ans << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
  l:??????
  r:??????
  h:?????¨????°´???
  w:1?§??????????????°´??????
  lkabe:???????£??????????
  rkabe:???????£??????????
*/
const double EPS = 1e-8; 
struct dat{double l,r,h,w,lkabe,rkabe;};
typedef pair<double,double> P;
typedef pair<P,int> PP;
vector<dat> A;

double getMinTime(){
  double res = 1e9;
  for(dat a:A){
    if(a.w==0)continue;
    double t = ((min(a.lkabe,a.rkabe) - a.h)*(a.r-a.l)*30)/a.w;
    res = min(res,t);
  }
  return res;
}

dat Merge(dat l,dat r){
  dat res;
  res.l = l.l;
  res.r = r.r;
  res.h = min(r.h,l.h);
  res.w = l.w + r.w;
  res.lkabe = l.lkabe;
  res.rkabe = r.rkabe;
  return res;
}

bool replace(int idx,int flg){
  A[idx+flg].w += A[idx].w;
  A[idx].w = 0;
  if(abs(A[idx+flg].h-A[idx].h)>EPS) return 0 ;
  if(flg == 1) A[idx] = Merge(A[idx],A[idx+1]);
  if(flg == -1)A[idx] = Merge(A[idx-1],A[idx]);
  A.erase(A.begin()+idx+flg);
  return 1;
}

void adTime(double sec){
  for(int i=0;i<(int)A.size();i++){
    if(A[i].w==0)continue;
    A[i].h += (sec*A[i].w)/(30*(A[i].r-A[i].l));
  }

  int update = 1;
  while(update){
    update = 0;
    for(int i=0;i<(int)A.size();i++){
      if(A[i].w==0)continue;
      
      if(A[i].lkabe<=A[i].h+EPS){ update=1,replace(i,-1);break;}
      else if(A[i].rkabe<=A[i].h+EPS) { update=1,replace(i,1);break;}
    } 
  }
}

void sim(double t){
  while(t){
    double sec = min(t,getMinTime());
    assert(sec>=0);
    adTime(sec);
    t -=sec;
  }
}


double getH(int x){
  for(int i=0;i<(int)A.size();i++) if(A[i].l<x && x<A[i].r) return A[i].h;
  return -1;
}

int main(){
  int q;
  cin>>q;
  while(q--){
    int n;
    cin>>n;
    A.resize(n+1);
    double l=0,r,lkabe=1e15,rkabe;
    for(int i=0;i<n; i++,l=r,lkabe = rkabe){
      cin>>r>>rkabe;
      A[i] = (dat){l,r,0,0,lkabe,rkabe};
      if(i==n-1) A[n] = (dat){r,100,0,0,rkabe,1e15};
    }
    
    int m;
    cin>>m;
    for(int i=0,x,w;i<m;i++){
      cin>>x>>w;
      for(dat &a:A) if(a.l<x&&x<a.r)a.w+=w;
    }
    int L;
    cin>>L;
    vector<PP> que(L);
    for(int i=0;i<L;i++)cin>>que[i].first.second>>que[i].first.first,que[i].second = i;
    sort(que.begin(),que.end());
    
    vector<double>ans(L);
    int sec=0;
    for(int i=0;i<L;i++){
      double x =que[i].first.second,t = que[i].first.first;
      int idx = que[i].second;
      sim(t-sec);
      ans[idx] = min(50.0,getH(x));
      sec = t;
    }

    for(int i=0;i<L;i++)printf("%.8f\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef map<ll, ll> Map;

int main(void) {
    ll N, x;
    ll a[2001];
    ll b[2001];
    ll i, k;
    
    cin >> N >> x;
    for(i=0; i<N; i++) {
        cin >> a[i];
    }
    
    ll ans=INF;
    for(i=0; i<N; i++) {
        b[i]=a[i];
    }
    
    for(k=0; k<N; k++) {
        ll can=k*x;
        
        for(i=0; i<N; i++) {
            b[i]=min(b[i], a[(i-k+N)%N]);
        }
        
        for(i=0; i<N; i++) {
            can+=b[i];
        }
        
        ans=min(ans, can);
    }
    
    prin(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
 
using namespace std;
 
typedef long long LL;
 
const int N = 5010;
const int M = 210;
 
int n, m, b[N][M], a[N], st[N], nxt[M][N], f[M];
 
LL sa[N];
 
struct T{ LL x, tg;} t[N * 4];
 
void up(int x) { t[x].x = max(t[x << 1].x, t[x << 1 | 1].x);}
 
void pushdown(int x)
{	
	t[x << 1].x += t[x].tg, t[x << 1 | 1].x += t[x].tg;
	t[x << 1].tg += t[x].tg, t[x << 1 | 1].tg += t[x].tg;
	t[x].tg = 0; 
}
 
void modify(int x, int l, int r, int l0, int r0, LL c)
{
	if (l0 <= l && r <= r0){
		t[x].x += c, t[x].tg += c;
		return;
	}
	pushdown(x);
	int mid = (l + r) >> 1;
	if (l0 <= mid) modify(x << 1, l, mid, l0, r0, c);
	if (r0 > mid) modify(x << 1 | 1, mid + 1, r, l0, r0, c);
	up(x);
}
 
LL query(int x, int l, int r, int l0, int r0)
{
	if (l0 <= l && r <= r0) return t[x].x;
	pushdown(x);
	int mid = (l + r) >> 1; LL ret = -1e18;
	if (l0 <= mid) ret = query(x << 1, l, mid, l0, r0);
	if (r0 > mid) ret = max(query(x << 1 | 1, mid + 1, r, l0, r0), ret);
	return ret;
}
 
int main()
{
	//freopen("bar.in", "r", stdin);
	//freopen("bar.out", "w", stdout);
	
	scanf("%d%d", &n, &m);
	
	for (int i = 2; i <= n; i ++) scanf("%d", &a[i]);
	Rep(i, n) Rep(j, m) scanf("%d", &b[i][j]);
	
	Rep(k, m) {
		int top = 0;
		for (int i = n; i; i --) {
			while (top && b[st[top]][k] <= b[i][k]) top --;
			if (top) nxt[k][i] = st[top];
			else nxt[k][i] = n + 1;
			st[++ top] = i;
		}
	}
	
	Rep(i, n) {
		LL sum = 0;
		Rep(k, m){
			f[k] = max(f[k], b[i][k]);
			sum += f[k];
		}
		sa[i] = sa[i - 1] + a[i], sum -= sa[i];
		modify(1, 1, n, i, i, sum);
	}
	
	LL ans = query(1, 1, n, 1, n);
	
	Rep(i, n - 1) {
		Rep(k, m) for (int j = i + 1; j != nxt[k][i]; j = nxt[k][j])
			modify(1, 1, n, j, nxt[k][j] - 1, b[j][k] - b[i][k]);
		LL tmp = query(1, 1, n, i + 1, n) + sa[i + 1];
		ans = max(ans, tmp);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 8704
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		String out = "";
		for (int i = 0; i < totalVertex; i++) {
			for (int j = 0; j < totalVertex; j++) {
				if (adjList.get(i).contains(j)) {
					adjMatrix[i][j] = 1;
					if (j == totalVertex-1){
					    out += "1";
					}
					else{
					    out += "1 ";
					}
				}
				else {
					adjMatrix[i][j] = 0;
					if (j == totalVertex-1){
					    out += "0";
					}
					else{
					    out += "0 ";
					}
				}
			}
			if (i != totalVertex-1) {
				out += "\n";
			}
		}
		System.out.println(out);
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 283324
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int s){
	V[s]=true;
	for (int i = 0; i < G[s].size(); ++i) {
		int v=G[s][i];
		if(!V[v])dfs(v);
	}
	out.push_front(s);
}

int main(){
	int s,t,M;
	cin>>N>>M;
	for (int i = 0; i < N; ++i) {V[i]=false;}
	for (int i = 0; i < M; ++i) {
		cin>>s>>t;
		G[s].push_back(t);
	}
	for (int u = 0; u < N; ++u) {
			//?¨?????????????????????????????????\?¬???°?????????????????????list?????\?????????
			if(!V[u])dfs(u);}
	for (list<int>::iterator it=out.begin();it !=out.end();it++) {
		cout<<*it<<endl;
	}
	return 0;
}

Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int X,N;
    cin >> X >> N;
    vector<int> p(102,0);
    rep(i,N){
        int a;
        cin >> a;
        p[a] = 1;
    }
    int topans,downans;
    int k = X;
    while(k <= 101){
        if(k == 101){
            topans = 101;
            break;
        }
        if(p[k] == 0){
            topans = k;
            break;
        }
        k++;
    }
    k = X;
    while(true){
        if(k == 0){
            downans = 0;
            break;
        }
        if(p[k] == 0){
            downans = k;
            break;
        }
        k--;
    }
    if( abs(downans - X) > abs(topans - X)){
        cout << topans << endl;
    }else{
        cout << downans << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n,x;
	cin >> n >> x;
	int ans = 0;
	int curr = 0;
	for(int i = 0; i < n; i++){
		if(curr <= x) ans++;
		int y;
		cin >> y;
		curr += y;
	}
	if(curr <= x) ans++;
	cout << ans;
	
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template<class T>
class dinicWithCostScalling {
    struct edge{
        int to;
        T cap;
        int rev;
        bool isrev;
    };

    vector<vector<edge>> G;
    vector<int> level, iter;

    void bfs(int s, const T base) {
        level.assign(G.size(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(que.size()) {
            int v = que.front(); que.pop();
            for(auto i: G[v]) {
                if(i.cap >= base && level[i.to] < 0) {
                    level[i.to] = level[v] + 1;
                    que.push(i.to);
                }
            }
        }
    }
    T dfs(int v, const int t, T f, const T base) {
        if(v == t) return f;
        for(int &i = iter[v]; i<(ll)G[v].size(); ++i) {
            edge &e = G[v][i];
            if(e.cap >= base && level[v] < level[e.to]) {
                T d = dfs(e.to, t, min(f, e.cap), base);
                if(d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    dinicWithCostScalling() {}
    dinicWithCostScalling(int n) : G(n), level(n), iter(n) {}

    void add_edge(int from, int to, T cap) {
        G[from].push_back({to, cap, (int)G[to].size(), false});
        G[to].push_back({from, 0, (int)G[from].size()-1, true});
    }

    // max_capは辺の最大容量
    T maxflow(int s, int t, T max_cap = 1LL<<30) {
        T flow = 0;
        const int tmp = __builtin_ctzll(max_cap);
        for(T base = 1LL<<tmp; base >= 1;) {
            bfs(s, base);
            if(level[t] < 0) {
                base >>= 1;
                continue;
            }
            iter.assign(G.size(), 0);
            flow += dfs(s, t, 1LL<<60, base);
        }
        return flow;
    }

    friend ostream &operator <<(ostream& out, const dinicWithCostScalling& a){
        out << endl;
        for(int i = 0; i < (int)a.G.size(); i++) {
            for(auto &e : a.G[i]) {
                if(e.isrev) continue;
                auto &rev_e = a.G[e.to][e.rev];
                out << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
            }
        }
        return out;
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    dinicWithCostScalling<ll> graph(n);
    REP(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        graph.add_edge(a, b, c);
    }

    cout << graph.maxflow(0, n-1, 10000) << endl;

    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;

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

  string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  string s2;

  cin >> s2;

  for(int i = 0 ; i < 7 ; i++) {
    if(s2 == s[i]) {
      cout << 7 - i << endl;
    }
  }
} 

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <cstring>

int main() {
	string A,B;
	cin >> A >> B;
	int ans = 1000000;
	for(int i = 0;i <= A.length() - B.length();++i) {
		int counter = 0;
		for(int j = 0;j < B.length();++j) {
			if(B[j] != A[i + j]) counter++;
		}
		ans = min(ans,counter);
	}
	cout << ans << endl;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	vi ws={1};
	for(int i=6;i<=100000;i*=6) ws.push_back(i);
	for(int i=9;i<=100000;i*=9) ws.push_back(i);

	for(int n;cin>>n&&n;){
		vi dp(n+1,INF);
		dp[0]=0;
		for(int w:ws) repi(i,w,n+1) chmin(dp[i],dp[i-w]+1);
		cout<<dp[n]<<endl;
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String sa = in.next();
        String sb = in.next();
        String sc = in.next();
        Deque<Character> a = new ArrayDeque<Character>();
        Deque<Character> b = new ArrayDeque<Character>();
        Deque<Character> c = new ArrayDeque<Character>();
        
        for (int i = 0; i < sa.length(); i++) {
            a.addLast(sa.charAt(i));
        }
        for (int i = 0; i < sb.length(); i++) {
            b.addLast(sb.charAt(i));
        }
        for (int i = 0; i < sc.length(); i++) {
            c.addLast(sc.charAt(i));
        }
        
        char turn = 'a';
        char winner = 'A';
        
        while(true){
            if(turn == 'a'){
                if(a.isEmpty()){
                    winner = 'A';
                    break;
                }
                else{
                    turn = a.removeFirst();
                }
            }
            else if(turn == 'b'){
                if(b.isEmpty()){
                    winner = 'B';
                    break;
                }
                else{
                    turn = b.removeFirst();
                }
            }
            else {
                if(c.isEmpty()){
                    winner = 'C';
                    break;
                }
                else{
                    turn = c.removeFirst();
                }
            }
            
        }
        System.out.println(winner);
    }
}


Measured memory_bytes: 27032
n=input()[:-2]
s=sorted(set(range(10))-set(map(int,input().split())))
s=[str(i)for i in s]
if all(i in s for i in n):
  print(n)
  exit()
f=0
t=''
for i in n:
  if f:
    t+=s[0]
  elif i in s:
    t+=i
  else:
    for j in s:
      if int(j)>int(i):
        t+=str(j)
        f=1
        break
    else:
      break
else:
  print(t)
  exit()
t=(s[0]*(s[0]!='0')or s[1])+s[0]*len(n)
print(t)

Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int main(){
	int n;
	int d,x;
	cin >> n;
	cin >> d >> x;
	
	int ate = 0;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		ate += (d - 1) / a + 1;
	}
	
	cout << ate + x << endl;
	return 0;
}

Measured memory_bytes: 256
CONST = 998244353
n = int(input())
d = list(map(int, input().split()))
l = [0 for i in range(n)]
max_d = max(d)
for i in d:
  l[i] += 1
ans = 1
cnt = 0
prev = 1
if d[0] != 0:
  print(0)
elif l[0] != 1:
  print(0)
else:
  for i in range(max_d+1):
    cnt = l[i]
    ans *= prev**cnt%CONST
    prev = cnt
  print(ans%CONST)

Measured memory_bytes: 56244
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[1<<18];
int rec(int k,int d){
  //cout<<k<<" "<<d<<endl;
  if(d==n){
    return a[k];
  }
  int x=rec(k*2,d+1),y=rec(k*2+1,d+1);
  if(x==y) return x;
  if(x<y)  return y-x;
  if(x>y)  return x-y;
}
signed main(){
  cin>>n;
  for(int i=0;i<(1<<n);i++) cin>>a[i];
  cout<<rec(0,0)<<endl;
  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

template<class T>
void chmin(T &a, T &b){
    if(a > b)a = b;
}

class edge {
    public:
    edge(){};
    edge(ll f, ll t, ll c):f(f), t(t), c(c)
    {};
    ll f;
    ll t;
    ll c;
};

int main(){
    ll n,m; cin >> n >> m;
    vvl gr(n, vector<ll>(n,INF));
    vector<edge> edg(m);
    rep(i,m){
        ll a,b,c; cin >> a >> b >> c;
        a--;b--;
        gr[a][b] = gr[b][a] = c;
        edg[i] = edge(a,b,c);
    }
    rep(i,n)gr[i][i] = 0;
    rep(k,n)rep(i,n)rep(j,n){
        // chmin(gr[i][j], gr[i][k] + gr[k][j]);
        gr[i][j] = min(gr[i][j], gr[i][k] + gr[k][j]);
    }

    ll res = 0;
    rep(i,m){
        edge t = edg[i];
        if(gr[t.f][t.t] < t.c)res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

MAX_L = 43

def main():
    A, B = ZZ()

    p = []
    e = 1
    for _ in range(MAX_L+1):
        p.append(e)
        e *= 2

    def bitc(num):
        ret = []
        for i in range(1, MAX_L+1):
            x = (num//p[i]) * p[i-1] + max(0, num%p[i]-p[i-1]+1)
            ret.append(x%2)
        return ret

    a = bitc(max(0, A-1))
    b = bitc(B)
    output = 0
    for i in range(MAX_L): output += (a[i]+b[i])%2 * p[i]
    print(output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    //cout <<"aaa" <<endl;
    int N;
    int cnte=0,cntw=0;
    int E[300001] = {};
    int W[300001] = {};
    int m = 300000;
    string S;
    cin >> N >> S;
    for(int i=1;i<N+1;i++){
        if(S[i-1] == 'E'){
            cnte++;
        }else{
            cntw++;
        }
        E[i] = cnte;
        W[i] = cntw;
    }
    E[N+1]=cnte;
    W[N+1]=cntw;
    for(int i=1;i<N+2;i++){
        m = min(m, W[i-1]+(E[N+1] - E[i]));
        //cout << W[i-1]<< " "<< E[i] <<endl;
    }

    cout << m << endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	vector <int> cand;

	for (int i = 0; i < 3; i++) {
		int ipts;
		cin >> ipts;
		cand.push_back(ipts);

	}
	sort(cand.begin(), cand.end());
	if (cand[0] + cand[1] == cand[2])cout << "Yes" << endl;
	else cout << "No" << endl;




	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    for (i in 1 until n-1) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i]) && (p[i] > p[i+1])) ans++
    }
    println(ans)
}


Measured memory_bytes: 37620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
// constexpr double EPS = 1e-10;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;



void solve() {
	int A, B; cin >> A >> B;
	print(A*B);
}

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


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    int N,K;
    cin >> N >> K;
    vector<int> v(200001,0);
    vector<int> w;
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        v[tmp]++;
    }
    rep(i,0,v.size()){
        if(v[i] != 0) w.push_back(v[i]);
    }
    sort(all(w));

    int ans = 0;
    rep(i,0,w.size()-K){
        ans += w[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main(void){
    ll h, w;
    cin >> h >> w;
    ll a, b, c;
    ll mi = 100000000;

    for(int i = 1; i < h ; i++){
        a = i * w;
        b = ceil((h - i) / 2.0) * w;
        c = floor((h - i) / 2.0) * w;
        ll dif = max(a, max(b, c)) - min(a, min(b, c));
        mi = min(dif, mi);

        b = ceil(w / 2.0) * (h - i);
        c = floor(w / 2.0) * (h - i);
        dif = max(a, max(b, c)) - min(a, min(b, c));
        mi = min(dif, mi);
    }

    swap(h, w);
    for(int i = 1; i < h ; i++){
        a = i * w;
        b = ceil((h - i) / 2.0) * w;
        c = floor((h - i) / 2.0) * w;
        ll dif = max(a, max(b, c)) - min(a, min(b, c));
        mi = min(dif, mi);

        b = ceil(w / 2.0) * (h - i);
        c = floor(w / 2.0) * (h - i);
        dif = max(a, max(b, c)) - min(a, min(b, c));
        mi = min(dif, mi);
    }

    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/9/2020
 
 17:43-
 
 */

const int MAX_N=200+1;
string S[MAX_N];
int mx[MAX_N][MAX_N];
int N;

bool ans=true;
const int Inf=1e7;
int viz[MAX_N];
void dfs(int u, int col) {
  if(viz[u]!=-1) {
    if(viz[u]!=col) ans=false;
    return;
  }
  viz[u]=col;
  REP(v,N)if(u!=v&&S[u][v]=='1') dfs(v,col^1);
}
void solve() {
  REP(i,N)REP(j,N) mx[i][j]=i==j?0:Inf;
  REP(i,N)REP(j,N)if(S[i][j]=='1') mx[i][j]=1;

  REP(k,N)REP(i,N)REP(j,N) SMIN(mx[i][j],mx[i][k]+mx[k][j]);
  int res=0;
  REP(i,N)REP(j,N)SMAX(res,mx[i][j]+1);
  MINUS(viz);
  dfs(0,0);
  if(!ans) res=-1;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>S[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    boolean b = true;
    for(int i=0 ; i<n/2 ; i++){
      if(s.charAt(i)!=s.charAt(n-1-i)){
        b = false;
        break;
      }else{
        continue;
      }
    }
    if(b){
      for(int i=0 ; i<((n-1)/2)-1 ; i++){
        if(s.charAt(i)!=s.charAt(((n-1)/2)-1-i)){
          b = false;
          break;
        }else{
          continue;
        }
      }
    }
    if(b){
      for(int i=((n+3)/2)-1 ; i<(3*n+3)/4 ; i++){
        if(s.charAt(i)!=s.charAt(n-1+(n+3)/2-1-i)){
          b = false;
          break;
        }else{
          continue;
        }
      }
    }
    if(b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22996