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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  string s;
  cin >> s;

  int cnt = 0;

  rep(i, s.size()/2) {
    if (s[i] != s[s.size()-i-1]) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,n;
    scanf("%d",&n);
    int a[n];
    for(i = 0; i < n; i ++ )scanf("%d",&a[i]);
    for(i = n - 1; i >= 0; i -- ){
        printf("%d",a[i]);
        if(i != 0)printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    
   int n;
   int k;
   
   int ans=0;
   
  cin >> n >> k;
   
   vector<int> h(n);
  rep(i,n) cin >> h[i];
  
  
  
  rep(i,n){
  if(h[i] >= k){
      
      ans++;
  }
  
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int id[maxn],p[maxn],f[maxn],n,m;
int gf(int k){
	return k==f[k]? k:f[k]=gf(f[k]);
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=0; i<n; i++) {
		scanf("%d",&p[i]); p[i]--;
		id[p[i]]=i;
	}
	for (int i=0; i<n; i++) f[i]=i;
	for (int i=0; i<m; i++){
		int x,y; scanf("%d%d",&x,&y);
		int fa=gf(--x); int fb=gf(--y);
		if (fa!=fb) f[fb]=fa;
	}
	int ans=0;
	for (int i=0; i<n; i++){
		int fa=gf(i); int fb=gf(id[i]);
		if (fa==fb) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(){

  int n,m,p;

  while(cin>>n>>m>>p,n||m||p){

	vector<int> x(n+1);
	int total=0;
	
	for(int i=1;i<=n;++i){
	  cin>>x[i];
	  total+=x[i];
	}

	total=total*(100-p);

	
	if(x[m]==0)
	  cout<<0<<endl;
	else
	  cout<<total/x[m]<<endl;
	
  }

}



Measured memory_bytes: 3092
unittest
{
/*
	assert( [ "3" ].parse.expand.solve == "1 0 2 2 0 1" );
	assert( [ "100" ].parse.expand.solve == "0 0 10 0 0 10" );
	assert( [ "311114770564041497" ].parse.expand.solve == "314159265 358979323 846264338 327950288 419716939 937510582" );
*/
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( long );
	return tuple( s );
}

auto solve( long s )
{
	// 頂点Aを(0,0)に固定して、ベクトルABとACの外積÷２（＝三角形の面積）を計算
	//   s / 2 = ( bx * cy - by * cx ) / 2
	//   s = bx * cy - by * cx
	// 座標の範囲が0～10^^9なので、頂点Bを(10^^9,1)に固定する
	//   s = 10^^9 * cy - 1 * cx
	// 上記が成り立つので、後は頂点Cの座標を求めればOK
	auto bx = 10L ^^ 9;
	auto by = 1L;
	auto cy = cast( long ) ceil( s / cast( double ) bx );
	auto cx = ( bx * cy - s ) / by;
	return format( "%s %s %s %s %s %s", 0, 0, bx, 1, cx, cy );
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector< pair<int,int> >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=1000+7;
const int inf=1e18+1e9;
const int mod=998244353;
const ld eps=1e-9;

//const int MAX_MEM=1e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    assert(mpos<=MAX_MEM);
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

char a[N][N];
int dp[N][N];
int n,m;

int get_ans()
{
    for (int i=0;i<=n;++i){
        for (int j=0;j<=m;++j){
            dp[i][j]=inf;
        }
    }
    if (a[1][1]=='#')dp[1][1]=1;
    else dp[1][1]=0;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            if (i==1 && j==1)continue;
            if (a[i][j]=='#'){
                dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j]!=a[i][j-1]));
                dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i][j]!=a[i-1][j]));
            }
            else {
                dp[i][j]=min(dp[i][j],dp[i][j-1]);
                dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }
        }
    }
    return dp[n][m];
}

main ()
{
    ios;
    cin>>n>>m;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            cin>>a[i][j];
        }
    }
    int ans=get_ans();
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            if (a[i][j]=='.'){
                a[i][j]='#';
            }
            else {
                a[i][j]='.';
            }
        }
    }
    ans=min(ans,get_ans()+1);
    cout<<ans<<endl;
}


Measured memory_bytes: 2816
from collections import deque
N,K,Q=map(int,input().split())
ls=[int(input())-1 for i in range(Q)]
que=deque(ls)
co=[0 for i in range(N)]
for j in range(Q):
  co[que.popleft()]+=1
for i in co:
  if i>Q-K:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9376
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,n,f;
	char s[205];
	char t[5][6]={'a','f','k','p','u','z',
		      'b','g','l','q','v','.',
		      'c','h','m','r','w','?',
		      'd','i','n','s','x','!',
		      'e','j','o','t','y',' '};
	while(scanf("%s",s)!=EOF){
		f=0;
		if(strlen(s)%2==1)printf("NA\n");
		else{
			for(i=0;i<strlen(s);i+=2){
				if(s[i]<'1' || s[i]>'6' ||
				   s[i+1]<'1' || s[i+1]>'5'){
					f=1;
					printf("NA");
					break;
				}
			}
			if(f==0)
			for(i=0;i<strlen(s);i+=2)
				printf("%c",t[s[i+1]-'0'-1][s[i]-'0'-1]);
			printf("\n");
		}
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0;i<N;i++){
        cin >> A[i];
    }
    int count = 0;
    int minj,v;
    for(int i = 0;i<N;i++){
        minj = i;
        v=A[i];
        for(int j = i;j<N;j++){
            if(A[j]<A[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            A[i] = A[minj];
            A[minj] = v;
            count++;
        }
    }
    
    for(int i = 0;i<N;i++){
        if(i!=N-1){
            cout << A[i] << " ";
        }else{
            cout << A[i] << endl;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3084
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		long K = sc.nextLong();
		
		long[] num = new long[100001];
		for(int i=0; i<N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			num[a] += b;
		}
		
		for(int i=1; i<100001; i++) {
			K -= num[i];
			
			if(K <= 0) {
				System.out.println(i);
				return;
			}
		}
		
		return;

	}
	
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}

}


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

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> sorted = a;

    std::sort(sorted.begin(), sorted.end(), std::greater<int>());
    int max = sorted[0], second_max = sorted[1];

    for (auto c : a) {
        std::cout << (c == max ? second_max : max) << std::endl;
    }
}


Measured memory_bytes: 3200
def main():
    K = int(input())
    def isr(x):
        a = x % 10
        x //= 10
        b = x % 10
        while x:
            if abs(a - b) > 1:
                return False
            x //= 10
            a, b = b, x % 10
        return True
    dp = [[0] * 11 for _ in range(15)]
    dp2 = [0] * 15
    dp[0][0] = 1
    t = 0

    def nxt(x):
        if x == 0:
            return [0, 1]
        if x == 9:
            return [8, 9]
        return [x - 1, x, x + 1]

    for j in range(1, 10):
        dp[0][j] = 1
        t += dp[0][j]
        if t == K:
            return j

    for i in range(1, 15):
        dp2[i] = t
        dp[i][0] = dp[i - 1][0] + dp[i - 1][1]
        for j in range(1, 10):
            dp[i][j] = sum(dp[i - 1][j - 1:j + 2])
            if t + dp[i][j] >= K:
                r = j
                K -= t
                for p in reversed(range(i)):
                    t = 0
                    for q in nxt(j):
                        if t + dp[p][q] >= K:
                            K -= t
                            r = r * 10 + q
                            j = q
                            break
                        t += dp[p][q]
                return r
            t += dp[i][j]


print(main())


Measured memory_bytes: 3064
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    n = list(input())
    k = get_int()
    ln = len(n)
    ans = 0
    def solve(nz, ind, locked = False):
        if nz == 0: return 1
        if ind>=ln: return 0
        num = int(n[ind])
        ans = 0
        for index in range(ind,ln):
            if locked and ind==index:
                if nz==1: ans += 1
                else:
                    for i in range(index+1, ln):
                        if int(n[i])>0:
                            ans += solve(nz-1, i, True)
                            break
                ans += solve(nz-1, index+1)*(num-1)
            else: ans += solve(nz-1, index+1)*9
            #print(index, ans)
        #print(nz, ind, locked, ans)
        return ans

    ans = solve(k,0, True)
    print(ans)


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,x,y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<ll> v[n];
  for (ll i = 0; i < n-1; i++) {
    v[i].push_back(i+1);
    v[i+1].push_back(i);
  }
  v[x].push_back(y);
  v[y].push_back(x);
  ll ans[n]={0};
  for (ll i = 0; i < n; i++) {
    ll vis[n];
    memset(vis,0,sizeof(vis));
    ll dis[n];
    queue<ll> q;
    q.push(i);
    vis[i]=1;
    dis[i]=0;
    while(!q.empty())
    {
      ll temp = q.front();
      q.pop();
      for (ll j = 0; j < v[temp].size(); j++) {
        if(vis[v[temp][j]]==0)
        {
          vis[v[temp][j]]=1;
          dis[v[temp][j]]=dis[temp]+1;
          q.push(v[temp][j]);
        }
      }
    }
    for (ll i = 0; i < n; i++) {
      ans[dis[i]]++;
    }
  }
  for (ll i = 1; i < n; i++) {
    cout << ans[i]/2 << endl;
  }


}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<cstring>
#define SF scanf
#define PF printf
#define MAXN 1100
using namespace std;
int n,wt,ht; 
int xs1[MAXN],ys1[MAXN],xs2[MAXN],ys2[MAXN];
int fld[MAXN*2][MAXN*2];
int w[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int compress(int *x1,int *x2,int w){
	vector<int> xs;
	for(int i=0;i<n;i++){
		int t1=x1[i];
		int t2=x2[i];
		if(1<=t1&&t1<w) xs.push_back(t1);
		if(1<=t2&&t2<w) xs.push_back(t2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());//°´×?±?????£¬?\??
	for(int i=0;i<n;i++){
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();//£¨????????find??????±?????????£?£?£?????×?±? 
	} 
	return xs.size()-1;//?????????¶?§ 
} 
void bfs(int x,int y){
	queue<pair<int,int> > q;
	q.push(make_pair(x,y));
	while(!q.empty()){
		pair<int,int> nxt=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int x1=nxt.first+w[i][0];
			int y1=nxt.second+w[i][1];
			if(x1>=0&&x1<wt&&y1>=0&&y1<=ht&&fld[x1][y1]==0){
				fld[x1][y1]=1;
				q.push(make_pair(x1,y1));
			}
		}
	}
}
int main(){
	while(SF("%d %d",&wt,&ht)!=EOF){
		memset(fld,0,sizeof fld);
		if(wt==0||ht==0)
			break;
		SF("%d",&n);
		for(int i=0;i<n;i++)
			SF("%d%d%d%d",&xs1[i],&ys1[i],&xs2[i],&ys2[i]);
		wt=compress(xs1,xs2,wt);
		ht=compress(ys1,ys2,ht);
		//????????????imos£¬????????????????£¬????????????????´????°×???
		//??°×??????????sum????±?????????£¬??°´??×???????????´?´????°×??? 
		for(int i=0;i<n;i++){
			fld[xs1[i]][ys1[i]]++;
			fld[xs2[i]][ys1[i]]--;
			fld[xs1[i]][ys2[i]]--;
			fld[xs2[i]][ys2[i]]++;
		} 
		for(int i=0;i<wt;i++)
			for(int j=1;j<ht;j++)
				fld[i][j]+=fld[i][j-1];
		for(int i=1;i<wt;i++)
			for(int j=0;j<ht;j++)
				fld[i][j]+=fld[i-1][j];
		int tot=0;
		for(int i=0;i<wt;i++)
			for(int j=0;j<ht;j++)
				if(fld[i][j]==0){
					//dfs(i,j); 
					//±??????????´??bfs?£?£?±??±¬????´???????????
					bfs(i,j);
					tot++;
				}
		PF("%d\n",tot);
	}
	
}

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

const int INF = 0x3f3f3f3f;
ll H, W;

void solve()
{
	if(H%3==0 || W%3==0) cout << 0 << '\n';
	else{
		ll ans = 1e18;
		for(int w=1;w<W;++w){
			ll a1 = w*H, a2 = (W-w)*(H/2), a3 = H*W-a1-a2;
			ll mx = max(a1,max(a2,a3));
			ll mi = min(a1,min(a2,a3));
			ans=min(ans, mx-mi);
			a2 = H*((W-w)/2), a3 = H*W-a1-a2;
			mx = max(a1,max(a2,a3));
			mi = min(a1,min(a2,a3));
			ans = min(ans, mx-mi);
		}
		swap(H,W);
		for(int w=1;w<W;++w){
			ll a1 = w*H, a2 = (W-w)*(H/2), a3 = H*W-a1-a2;
			ll mx = max(a1,max(a2,a3));
			ll mi = min(a1,min(a2,a3));
			ans=min(ans, mx-mi);
			a2 = H*((W-w)/2), a3 = H*W-a1-a2;
			mx = max(a1,max(a2,a3));
			mi = min(a1,min(a2,a3));
			ans = min(ans, mx-mi);
		}
		cout << ans << '\n';
	}
}

int main()
{
	cin >> H >> W;
	solve();
	return 0;
}

Measured memory_bytes: 3656
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline


def inpl(): return list(map(int, input().split()))


def solve(N, V):
    v_even = [V[i] for i in range(0, N, 2)]
    v_odd = [V[i] for i in range(1, N, 2)]

    # 出現回数の多い上位2つの要素と出現回数を取得
    v_even_most = Counter(v_even).most_common()[:2]
    v_odd_most = Counter(v_odd).most_common()[:2]

    # 最頻値が被っていなければそのまま採用
    if v_even_most[0][0] != v_odd_most[0][0]:
        return N - v_even_most[0][1] - v_odd_most[0][1]
    else:
        # 数字が1種類しか登場しない場合は、0を追加
        # list index out of range対策
        if len(v_even_most) == 1 or len(v_odd_most) == 1:
            v_even_most.append((0, 0))
            v_odd_most.append((0, 0))

        # 書き換え回数が少ない方を採用
        return N - max(v_even_most[0][1] + v_odd_most[1][1],
                       v_even_most[1][1] + v_odd_most[0][1])


N = int(input())
V = inpl()
print(solve(N, V))


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

int main(){
  int n, w;
  cin >> n >> w;
  vector<ll> dp(w+1);
  for(int i = 0; i < n; i++){
  	ll weight, value;
  	cin >> weight >> value;
  	for(int wa = w - weight; wa >= 0; wa--){
			dp[wa + weight] = max(dp[wa + weight], dp[wa] + value); 		
  	}
  }
  cout << dp[w] << endl;
	return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(){
    int H,W;
    cin >> H >> W;
    vector< string > sv;
    VVI mv(H, VI(W,0));
    
    int minh,maxh,minw,maxw = 0;
    bool flg = true;
    FOR(i,0,H){
        string a;
        cin >> a;
        sv.push_back(a);
    }
    FOR(i,0,H){
        if( sv[i].find('#') == string::npos){
            FOR(j,0,W){
                mv[i][j] = 1;
            }
        }
    }

    FOR(j,0,W){
        bool tflg = true;
        FOR(i,0,H){
            if( sv[i].at(j)=='#')
                tflg = false;
        }
        if(tflg){
            FOR(i,0,H){
                mv[i][j] = 1;
            }
        }
    }
          
    FOR(i,0,H){
        bool tmp = false;
        FOR(j,0,W){
            if( mv[i][j] != 1 || sv[i].at(j) == '#'){
                cout << sv[i].at(j);
                tmp = true;
            }
        }
        if(tmp)cout << endl;
    }

    /* 
          FOR(j,0,W){
          FOR(i,0,H){
              if(minh <= i && maxh >= i
                 && minw <= j && maxw >= j )
                  cout << sv[i].at(j);
          }
          cout << endl;
      }    
     */
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll now_max = A[0];
    ll ans = 0;
    REP(i, 1, N) {
        if (now_max > A[i]) {
            ans += now_max - A[i] ;
        }
        else {
            now_max = A[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
#include<stdio.h>

int selectionSort(int[],int);

int main(){
  int A[100];
  int i,n,count;

  scanf("%d",&n);
  if(n>=1&&n<=100){
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
  
  count=selectionSort(A,n);

  for(i=0;i<n;i++) {
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  }
}


int selectionSort(int A[],int N){
  int i,j,minj,num,count=0;

  for(i=0;i<N-1;i++) {
    minj = i;  
    for(j=i+1;j<N;j++) {
      if(A[j] < A[minj]) {
	minj = j;
      }  
    }    
    num = A[minj];
    A[minj] = A[i];
    A[i] = num;
    
    if(i!=minj){
      count++;
    }
  }
 
  return count;
}



Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    if(!cin) return;
    cout << H * W - h * W - w * H + h*w << endl;
    
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void head(char s[]) {
  if (s[0] >= 97 && s[0] <= 122) {
    s[0] -= 32;
  }
  printf("%c", s[0]);
}

int main(void) {
  char s1[10], s2[10], s3[10];
  scanf("%s %s %s", s1, s2, s3);
  head(s1);
  head(s2);
  head(s3);
  printf("\n");
  return 0;
}

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

int main(void) {
	string S;
	cin >> S;

	int len = S.length();
	string ans = "No";
	if (len % 2 == 0) {
		int k = len / 2;
		string t = "";
		for (int i = 0; i < k; ++i)
			t += "hi";
		if (S == t)
			ans = "Yes";
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
@p = gets.chomp.split(" ").map{|i| i.to_f/100}
@q = gets.chomp.split(" ").map{|i| i.to_f/100}

def f(x)
  sum = 0
  for i in 0...6
    sum += [x * @p[i], (1-x) * @q[i]].max
  end
  return sum
end

def g(x)
  sum = 0
  for i in 0...6
    sum += [x * @p[i], (1-x) * @q[i]].max
  end
  return sum
end


kouho = [0, 1]

for i in 0...6
  if @p[i] + @q[i] == 0
    next
  end
  kouho << @q[i]/(@p[i] + @q[i])
end

mini = 10000
mini_x = 0

kouho.each{|x|
  #puts f(x)
  if mini > f(x)
    mini = f(x)
    mini_x = x
  end
  mini = [mini, f(x)].min
}

# p mini_x

printf("%.12f\n", g(mini_x))



Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N;
	cin >> N;

	ll bn = INF;

	vector<ll> A(5);
	for (ll i = 0; i < 5; ++i)
	{
		cin >> A[i];
		chmin(bn, A[i]);
	}

	ll times = (N / bn);

	if (N % bn != 0) ++times;
	if (times <= 0) times = 1;

	cout << times + 4 << endl;

	//system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using P1 = array<char, 26>;
using P2 = array<char, 365>;

struct state{
    array<char, 26> prv;
    array<char, 365> ans;
    int val;
    bool operator<(const state &a) const { return val > a.val; }
    state(P1 a, P2 b, int x) : prv(a), ans(b), val(x) {};
};


int main() {
    int d;
    cin >> d;
    array<int, 26> A{};
    for (auto &&k : A) cin >> k;
    vector<array<int, 26>> v(d);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    vector<int> ans(d);
    int W = 400;
    vector<state> a;
    a.emplace_back(P1{}, P2{}, 0);
    fill(a[0].prv.begin(),a[0].prv.end(), -1);
    for (int i = 0; i < d; ++i) {
        priority_queue<state> Q;
        for (auto &&s : a){
            for (int l = 0; l < 26; ++l) {
                s.val -= (i-s.prv[l])*A[l];
            }
            for (int k = 0; k < 26; ++k) {
                state ss(s);
                ss.ans[i] = k;
                ss.val += v[i][k]+s.prv[k]*A[k];
                ss.prv[k] = i;
                ss.val -= s.prv[k]*A[k];
                Q.emplace(ss);
                if(Q.size() > W) Q.pop();
            }
        }
        a.clear();
        while(!Q.empty()) a.emplace_back(Q.top()), Q.pop();
    }
    for (auto &&m : a.back().ans) {
        printf("%d\n", m+1);
    }
    return 0;
}

Measured memory_bytes: 3944
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL ans = 0;
	rep(i, N)
	{
		rep(j, N)
		{
			if (A[i] > A[j])
			{
				if (i < j) (ans += (K * (K + 1)) / 2) %= mod;
				else (ans += (K * (K - 1)) / 2) %= mod;
			}
		}
	}

	out << ans << std::endl;
}


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

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		sc.close();

		int point = partition(arr, 0, n-1);

		StringJoiner sj = new StringJoiner(" ");
		for (int i = 0; i < n; i++) {
			String val = String.valueOf(arr[i]);
			if(i == point) val = "[" + val + "]";
			sj.add(val);
		}

		System.out.println(sj);

	}

	private static int partition(int[] arr, int p, int r) {

		int x = arr[r];
		int i = p-1;
		for (int j = p; j < r; j++) {
			if (arr[j] <= x) {
				i++;
				int tmp;
				tmp = arr[j];
				arr[j] = arr[i];
				arr[i] = tmp;
			}
		}

		int tmp;
		tmp = arr[r];
		arr[r] = arr[i+1];
		arr[i+1] = tmp;

		return i + 1;

	}
}

Measured memory_bytes: 69684
#include <stdio.h>

int main(void)
{
    unsigned long long int X[100000] = {0};
    unsigned long long int K, count = 0;
    int l = -1;
    scanf("%llu", &K);

    for (int i = 0; i < 9; i++)
    {
        X[i] = i+1;
    }

    for (unsigned long long int j = 9; j < K; j++)
    {   
        X[j] = X[count]*10 + (X[count]%10) + l;
        l++;

        if (X[count]%10 == 0)
        {
            X[j] ++;
            if (l == 1)
            {
                count++;
                l = -1;
            }
            
        }
        

        if (l == 1 && X[count]%10 == 9)
        {
            l = -1;
            count++;
        }
        
        if (l==2)
        {
            l = -1;
            count++;
        }

                
    }
    
    printf("%llu", X[K-1]);
    
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,mi=1;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		if(now==mi){
			mi++;
			continue;
		}
		if(now%mi!=0){
			ans+=now/mi;
		}
		else{
			ans+=(now-1)/mi;
		}
		if(mi==1){
			mi++;
		}
		//cout << i <<" "<<mi<<" "<<ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int M = max(a,max(b,c));
  cout << a+b+c-M+M*pow(2,k) << endl;
}      
       





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

vector<int> ans;
vector<vector<int>> to(200005, vector<int>());

void dfs(int v, int p=-1){
    for(int u: to[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int N,Q;
    cin >> N >> Q;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(N);
    rep(i, Q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 23552
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>
 
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define if_range(x, w, h) if (w <= x && x <= h)
#define BitCheck(a,b)   (a >> b) & 1
#define BitSet(a,b)       a |= (1 << b)
#define BitunSet(a,b)    a &= ~(1 << b)
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
 
int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }
 
int main() {
    int n, m, a, dp[1002][1002] = { 0 };
    char s[1001], t[1001];
    scanf("%d", &a);
    for (int k = 0; a > k; k++) {
        scanf("%s %s", s, t);
        n = strlen(s);
        m = strlen(t);
        for (int i = 1; n >= i; i++) {
            for (int j = 1; m >= j; j++) {
                if (s[i - 1] == t[j - 1])dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        printf("%d\n", dp[n][m]);
    }
    return 0;
}

Measured memory_bytes: 5124
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read freopen("blue.txt","r",stdin);
#define write freopen("red.txt","w",stdout);
#define pie 2*acos(0.0);

typedef long long ll;

using namespace std;


int  main()
{
    fastio;
    string s;
    cin>>s;
    if(s[1]=='B')
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <stdlib.h>
//#include <codio.h>
using namespace std;
int n, k, c, a[100003], res;
int cp(const void *a, const void *b){
	return (*(int*)a - *(int*)b);
}
void pro(){
	int i, j, kt, co;
	co = 1;
	kt = a[0] + k;
	i = 1;
	res = 0;
	while (i < n){
		if (a[i]>kt || co == c){
			co = 1;
			kt = a[i] + k;
			res++;
		}
		else co++;
		i++;
	}
	if (co>0) res++;
}
int main(){
	int i, j;
	cin >> n >> c >> k;
	for (i = 0; i < n; i++) cin >> a[i];
	qsort(a, n, sizeof(int), cp);
	pro();
	cout << res;
//	_etch
	return 0;
}

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

int N,M;
int a[55],b[55];
int list[55][55];
int visited[55];
int ans;

void dfs(int cur)
{
	visited[cur]=1;
	for(int i=0;i<N;i++)
		if(visited[i]==0 && list[cur][i]==1)
			dfs(i);
	return;
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		list[a[i]][b[i]]=1;
		list[b[i]][a[i]]=1;
	}
	
	for(int i=0;i<M;i++)
	{
		list[a[i]][b[i]]=0;
		list[b[i]][a[i]]=0;
		
		dfs(0);
		
		for(int i=0;i<N;i++)
		{
			if(visited[i]==0)
			{
				ans++;
				break;
			}
		}
		for(int i=0;i<N;i++)
			visited[i]=0;
		list[a[i]][b[i]]=1;
		list[b[i]][a[i]]=1;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

public class ABC167A {
	private static void Main(string[] args) {
		var s = ReadStr();
		var t = ReadStr();

		var answer = (s == ExcludeTail(t)) ? "Yes" : "No";
		Console.WriteLine(answer);
	}

	private static string ReadStr() => Console.ReadLine().Trim();
	private static string ExcludeTail(string str) => str.Substring(0, str.Length - 1);
}

Measured memory_bytes: 25788
#!/usr/bin/env python3
#dp6 #Longest-Path

import sys
sys.setrecursionlimit(10000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
def g():
    def dfs(x):
        #既に最長パスがわかっている頂点はそれを返す
        if dp[x] != None:
            return dp[x]
        #移動できる頂点がないとき0
        if len(Graph[x]) == 0:
            dp[x] = 0
            return 0
        else:
            res = 0
            #移動できる頂点の中で最大パスをもつものを探す
            for y in Graph[x]:
                res = max(res,dfs(y)+1)
            dp[x] = res
            return dp[x]

    n,m = LI()
    #dpで各頂点を始点とした最大パスを管理
    dp = [None for _ in range(n)]
    Graph = [[] for _ in range(n)]
    for _ in range(m):
        x,y = LI()
        Graph[x-1].append(y-1)
    #各頂点を始点として最大パスを探す
    for i in range(n):
        dfs(i)
    print(max(dp))
if __name__ == '__main__':
    g()


Measured memory_bytes: 113576
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ll long long int
#define PI 3.141592653589793
using namespace std;

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a/g*b;
}

int main(void){
    int N;
    ll T, ans=1;
    
    cin >> N;

    REP(i,N) {
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	static int n;
	static int m;
	static char[][] map;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if(n == 0 && m == 0) break;
			map = new char[m][];
			for(int i = 0; i < m; i++) {
				map[i] = sc.next().toCharArray();
			}
			int gx = 0;
			int gy = 0;
			IN:for(int i = 0; i < m; i++) {
				for(int j = 0; j < n; j++) {
					if(map[i][j] == '&') {
						gx = j;
						gy = i;
						break IN;
					}
				}
			}
			
			solv(gy,gx);
			
			int min = Integer.MAX_VALUE;
			
			for(int j = 0; j < n; j++) {
					min = Math.min(costMap[0][j], min);
					min = Math.min(costMap[m-1][j], min);
			}
			for(int j = 0; j < m; j++) {
				min = Math.min(costMap[j][0], min);
				min = Math.min(costMap[j][n-1], min);
			}
			System.out.println(min);
			
		}
	}
	
	static class Data {
		int x;
		int y;
		int c;
		
		Data(int d, int e, int f) {
			y = d;
			x = e;
			c = f;
		}
	}
	
	static int[] vx = new int[] {1,0,-1,0};
	static int[] vy = new int[] {0,1,0,-1};
	static ArrayDeque<Data> queue = new ArrayDeque<Data>();
	static int[][] costMap = new int[m][n];
	
	
	static void solv(int gy, int gx) {
		costMap = new int[m][n];
		costMap[gy][gx] = 0;
		
		for(int i = 0; i < m; i++) {
			Arrays.fill(costMap[i], 2 << 27);
		}
		queue.addLast(new Data(gy,gx,0));
		while(!queue.isEmpty()) {
			BFS(queue.pollFirst());
		}
	}
	
	static void BFS(Data a) {
		if(!rangeCheck(a.y,a.x)) return;
		if(costMap[a.y][a.x] <= a.c) return;
		costMap[a.y][a.x] = a.c;
		for(int i = 0; i < 4; i++) {
			if(!rangeCheck(a.y+ vy[i],a.x+ vx[i])) continue;
			if((map[a.y][a.x] == '.' || map[a.y][a.x] == '&') && map[a.y + vy[i]][a.x + vx[i]] == '#') {
				queue.addLast(new Data(a.y + vy[i],a.x + vx[i], a.c+1));
			}
			else {
				queue.addLast(new Data(a.y + vy[i],a.x + vx[i], a.c));
			}
		}
	}
	
	static boolean rangeCheck(int a, int b) {
		if(a < 0 || b < 0 || a >= m || b >= n) return false;
		return true;
	}
	
		
}

Measured memory_bytes: 48788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    vector<double> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n) {
        h[i] = t - h[i]*0.006;
        h[i] = abs(a-h[i]);
    }
    int mn = 0;
    rep(i,n) {
        if (h[mn] > h[i]) mn = i;
    }
    cout << mn+1 << endl;
    return 0;
}

Measured memory_bytes: 3664
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,m;
    R(n,m);
    W((n-1)*(m-1));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int ans = 0;
int N, M; 
void check(vector<vector<bool>> &G, vector<int> &v) {
    bool tmp = true;
    rep(i,0,N-1) {
        if (G[v[i]][v[i+1]]) {
            continue;
        }
        else {
            tmp = false;
        }
    }
    if (tmp) {
        ans++;
    }
}

int main (){
   
    cin >> N >> M;
    vector<vector<bool>> G(N,vector<bool>(N,false));

    int a,b;
    rep(i,0,M) {
        cin >> a >> b;
        a--;
        b--;
        G[a][b] = true;
        G[b][a] = true;
    }
    vector<int> v = {};
    rep(i,0,N) {
        v.push_back(i);
    }

    do {
        if (v[0]!=0) {
            continue;
        }
        check(G,v);
    } while (std::next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N]; // 頂点0からの距離

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] && d[v] == INFTY) {
                // 未訪問
                q.push(v);
                d[v] = d[u] + 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;
    cin >> n;
    // 初期化
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


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

template<typename T, typename E> struct LazySegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;
  using P = function<E(E, int)>;

  int n;
  T ti;
  E ei;
  F f;
  G g;
  H h;
  P p;
  vector<T> data;
  vector<E> lazy;

  LazySegmentTree(int n_, F f, G g, H h, T ti = INT_MAX, E ei = INT_MAX,
                  P p = [](E a, int b) { return a; })
      : f(f), g(g), h(h), ti(ti), ei(ei), p(p) {
    init(n_);
  }
  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    data.assign(n * 2 - 1, ti);
    lazy.assign(n * 2 - 1, ei);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  inline void eval(int len, int k) {
    if (lazy[k] == ei) return;
    if (k * 2 + 1 < n * 2 - 1) {
      lazy[k * 2 + 1] = h(lazy[k * 2 + 1], lazy[k]);
      lazy[k * 2 + 2] = h(lazy[k * 2 + 2], lazy[k]);
    }
    data[k] = g(data[k], p(lazy[k], len));
    lazy[k] = ei;
  }
  T update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return data[k];
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      return g(data[k], p(lazy[k], r - l));
    }
    T vl = update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    T vr = update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    return data[k] = f(vl, vr);
  }
  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return ti;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

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

  LazySegmentTree<int, int>::F f = plus<int>();
  LazySegmentTree<int, int>::G g = plus<int>();
  LazySegmentTree<int, int>::H h = plus<int>();
  LazySegmentTree<int, int>::P p = multiplies<int>();

  int n, q; cin >> n >> q;
  LazySegmentTree<int, int> seg(n, f, g, h, 0, 0, p);

  while (q--) {
    int com; cin >> com;
    if (com) {
      int i; cin >> i;
      cout << seg.query(i - 1, i) << endl;
    } else {
      int s, t, x; cin >> s >> t >> x;
      seg.update(s - 1, t, x);
    }
  }
  return 0;
}



Measured memory_bytes: 4952
n=int(input())
if n!=0:
    string="<=Started"

    while n!=1:
        if abs(n)%2==0:
            string="0"+string
            n=int(n/(-2))
        else:
            string="1"+string
            n=int((n-1)/(-2))
    base2="1"+string
    wanted=base2[:-9]
    print(int(wanted))
if n==0:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,a,b;
    cin >> n >> a >> b;
    int ans = min(a*n,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764