akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>

int main(){
    int n,m,x;
    
    while(std::cin >> n >> m){
        
        //nとmが両方0ならbreak
        if(n == 0 && m == 0)
            break;
        
        int flag = 0;
        int num = 0;
        std::vector<int> v;
        std::string line;
    
        std::getline(std::cin, line);
    
        if(std::getline(std::cin, line)){
            std::istringstream ss(line);
            while(ss >> x){
                v.push_back(x);
            }
        }
        
        //野菜を値段で降順ソート
        sort(v.rbegin(),v.rend());
    
        for(int y = 0;y < n;++y){
            ++flag;
            if(flag != m){
                num += v[y];
            }
            else
                flag = 0;
        }
        std::cout << num << std::endl;
    }
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] tgts = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
				'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
		// int[] cnts = new int[tgts.length];
		char[] chars = new char[1200];
		String str = " ";

		 while(sc.hasNext()){
			str += sc.nextLine();

			chars = str.toCharArray();

			chars = switch_l(chars);
		 }


		for (int i = 0; i < tgts.length; i++) {
			System.out.println( tgts[i] + " : " + cnt_char(chars, tgts[i]) );
		}

		sc.close();

	}

	private static int cnt_char(char[] chars, char c) {
		int cnt = 0;

		for (int i = 0; i < chars.length; i++) {
			if ( chars[i] == c ){
				cnt++;
			}
		}

		return cnt;
	}

	private static char[] switch_l(char[] chars) {

		char[] chars_switch = new char[chars.length];
		for (int i = 0; i < chars.length; i++) {
				chars_switch[i] = Character.toLowerCase(chars[i]);
		}
		return chars_switch;
	}

}


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

#include <cmath>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long A, long long B, long long N) {
    ll x = min(N, B - 1);
    cout << floor(A * x / B) - A * floor(x / B) << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long N;
    scanf("%lld", &N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3852
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.BoxCount = (int)inpt[0];
        this.ChildCount = inpt[1];

        long[] items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.NumCount.Add(0, 1);
        this.Box = new long[items.Length];
        for (int i = 0; i < items.Length; i++) {
            long num = items[i];
            if(i > 0) {
                num += this.Box[i - 1];
            }
            this.Box[i] = num;
            num = num % ChildCount;
            if(NumCount.ContainsKey(num)) {
                NumCount[num]++;
            } else {
                NumCount.Add(num, 1);
            }
        }

        long ans = 0;

        foreach(long key in NumCount.Keys) {
            ans += NumCount[key] * (NumCount[key] - 1) / 2;
        }
        Console.WriteLine(ans);
    }

    private Dictionary<long, long> NumCount = new Dictionary<long, long>();
    int BoxCount;
    long ChildCount;

    long[] Box;


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


13 17
29 7 5 7 9 51 7 13 8 55 42 9 81

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 23904
S = input()
ans = 0
S = S.replace("><", ">,<").split(",")
for s in S:
  a = s.count(">")
  b = s.count("<")
  ans += a * (a - 1) // 2 + b * (b - 1) // 2 + max(a, b)
print(ans)

Measured memory_bytes: 19360
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mod = (int)1e9 + 7;
const int maxn = (int)2e5 + 10;
LL f[maxn];
LL qp(LL a, int b){
    LL res = 1;
    while(b){
        if(b & 1) (res *= a) %= mod;
        b >>= 1; (a *= a) %= mod;
    }
    return res;
}
inline LL inv(LL a){
    return qp(a, mod - 2);
}
LL fac[maxn], ifac[maxn];
inline LL C(int n, int m){
    if(n >= m && m >= 0) return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
    else return 0;
}
int siz[maxn];
vector <int> edg[maxn];
void dfs1(int u, int fa){
    siz[u] = 1; f[u] = 1;
    for(auto v : edg[u]){
        if(v != fa){
            dfs1(v, u);
            siz[u] += siz[v];
        }
    }
    int s = siz[u] - 1;
    for(auto v : edg[u]){
        if(v != fa){
            (f[u] *= C(s, siz[v]) * f[v] % mod) %= mod;
            s -= siz[v];
        }
    }
}
LL ans[maxn];
void dfs2(int u, int fa){
    LL oldfu = f[u], oldsu = siz[u];
    ans[u] = f[u];
    for(auto v : edg[u]){
        if(v != fa){
            (f[u] *= inv(C(siz[u] - 1, siz[v])) * inv(f[v]) % mod) %= mod;
            LL oldfv = f[v], oldsv = siz[v];
            siz[u] = siz[u] - siz[v];
            siz[v] += siz[u];
            (f[v] *= C(siz[v] - 1, siz[u]) * f[u] % mod) %= mod;
            dfs2(v, u);
            f[v] = oldfv; siz[v] = oldsv;
            f[u] = oldfu; siz[u] = oldsu;
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    int n; cin>>n;
    fac[0] = 1; ifac[0] = 1;
    for(int i = 1; i <= n; i++){
        fac[i] = (fac[i - 1] * i) % mod;
        ifac[i] = inv(fac[i]);
    }
    for(int i = 1; i < n; i++){
        int a, b; cin>>a>>b;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    dfs1(1, 0);
    dfs2(1, 0);
    for(int i = 1; i <= n; i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 21768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf (ll)1e18

int main(){
	int n,k;
	cin >> n >> k;
	ll h[n];
	for (int i = 0; i < n; ++i) cin >> h[i];
	ll dp[n];
	for (int i = 0; i < n; ++i) dp[i] = inf;
	dp[0] = 0;
	for (int i = 1; i < n; ++i){
		for (int j = 1; j <= k; ++j){
			if (i - j < 0) break;
			dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n-1] << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int n,a[100000],i,x[100000];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]); x[a[i]]=i;
	}
	for(i=1;i<=n;i++) printf("%d ",x[i]);
	return 0;
}

Measured memory_bytes: 2456
#include <stdio.h>
#include <stdlib.h>

int sort(const void *a, const void *b) {
  return *(int*)a - *(int*)b;
}

int main(){

    int N;	
	scanf("%d", &N);

	int d[N];
	for( int i=0; i<N; i++ ){
		scanf("%d", &d[i]);
	}

    qsort( d, N, sizeof(int), sort );

    int cnt=1;

    for( int i=0; i<N-1; i++ ){
        if( d[i]!=d[i+1] ){
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [0]+list(map(int, input().split()))+[0]
d = []
for i in range(n+1):
    d.append(abs(a[i]-a[i+1]))
total = sum(d)
n = n+2
for i in range(1, n-1):
    print(total+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])))


Measured memory_bytes: 20376
/*
ID: techiah1
PROG: test
LANG: C++
*/
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))
#pragma comment(linker, "/STACK:102400000,102400000")

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <iomanip>

//#define Local

using namespace std;
long long gcd(long long x, long long y)
{
	return y ? gcd(y, x%y) : x;
}

long long lcm(long long x, long long y)
{
	return x / gcd(x, y)*y;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input1.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);

		int n;
		cin >> n;
		long long res = 1;
		while (n--)
		{
			long long tmp;
			cin >> tmp;
			res = lcm(res, tmp);
		}
		cout << res << endl;
		return 0;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long> ans(N,0);
  int x=1;
  int y=1;
  int z=1;

    for(x=1;x*x+y*y+z*z+x*y+y*z+z*x<=N;x++){
      for(y=1;x*x+y*y+z*z+x*y+y*z+z*x<=N;y++){
        for(z=1;x*x+y*y+z*z+x*y+y*z+z*x<=N;z++){
        ans.at(x*x+y*y+z*z+x*y+y*z+z*x-1) ++;
        }
        z = 1;
      }
      y = 1;
    }
    x =1;

  for(int i=0;i<N;i++){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n,K;
  cin>>n>>K;
  vector<int> x(n), y(n);
  rep(i,n) cin>>x[i]>>y[i];

  long ans = LLONG_MAX;
  rep(i,n)rep(ii,n)rep(j,n)rep(jj,n){
    int cnt = 0;
    int lx = x[i];
    int ux = x[ii];
    int ly = y[j];
    int uy = y[jj];
    if(lx >= ux || ly >= uy) continue;
    rep(k,n) if(lx<=x[k] && x[k]<=ux && ly<=y[k] && y[k]<=uy) cnt++;
    if(cnt>=K){
      ans = min(ans, (long)(ux-lx)*(uy-ly));
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string X = S + T;
  
  for (int i = 0; i < N; i++){
    cout << S.at(i) << T.at(i);
  }
    
}


Measured memory_bytes: 256
def main():

    N = int(input())
    H = [int(h) for h in input().split()]

    count = 1

    for n in range(1, N):
        flag = True
        for m in range(n):
            if H[m] > H[n]:
                flag = False
        if flag:
            count += 1

    print(count)


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> >v(10000);
main()
{
	int n,x,y,s,min;
	cin>>n>>x>>y;
	vector<int> a(n+1,0);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<i;j++)
		{
			s=abs(i-j);
			min=abs(i-x)+abs(y-j)+1;
			if(s<min)
			min=s;
			if(abs(i-y)+abs(x-j)+1<min)
			min=abs(i-y)+abs(x-j)+1;
			a[min]++;
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<a[i]<<"\n";
	}
}


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

int counter(int bits) {
  if (bits == 0)
    return 0;
  return counter(bits >> 1) + (bits & 1);
}
string show_bits(int bits) {
  string ret = "";
  int num;
  while (bits > 0) {
    num = bits & 1;
    bits = bits >> 1;

    if (num == 1)
      ret = "1" + ret;
    else
      ret = "0" + ret;
  }
  return ret;
}

int main() {
  int N;
  int A[20];
  int x[20][20];
  int y[20][20];

  // cin
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if (!((bits >> (i - 1)) & 1)) {
        // cout << "i = " << i << ", bits = " << show_bits(bits) << ":
        // countinue"
        //      << endl;
        // cout << "!((bits >> (i - 1)) & 1)" << !((bits >> (i - 1)) & 1) <<
        // endl;
        continue;
      }
      for (int j = 1; j <= A[i]; j++) {
        // cout << "bits, i, A[i], j = " << show_bits(bits) << ", " << i << ", "
        //      << A[i] << ", " << j << endl;
        // x[i][j]桁目の数　が　yと一致していればするー．
        // 一致していなければ，
        if (((bits >> (x[i][j] - 1)) & 1) != y[i][j]) {
          // cout << "bad: ((bits >> (x[i][j] - 1)) & 1) = "
          //      << ((bits >> (x[i][j] - 1)) & 1) << ", y[i][j] = " << y[i][j]
          //      << endl;
          ok = false;
        }
        //  else {
        //   cout << "ok" << endl;
        // }
      }
    }
    if (ok) {
      ans = max(ans, counter(bits));
      // cout << "bits, ans = " << show_bits(bits) << ", " << ans << endl;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
x=min(A)
noend=True
while noend:
  a=x
  for i in range(n):
    if A[i]%x!=0 and A[i]%x<x:
      x=A[i]%x
      break
  if x==a:
    noend=False
print(x)
      

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main() {
  string s;
  cin >> s;
  int n = s.size();

  if (s[0] == s[n-1]) {
    if (n % 2 == 0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
  } else {
    if (n % 2 == 0) {
      cout << "Second" << endl;
    } else {
      cout << "First" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, ans[100005][5];
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a >> b >> c;
		ans[i][1] = a + max(ans[i-1][2],ans[i-1][3]);
		ans[i][2] = b + max(ans[i-1][1],ans[i-1][3]);
		ans[i][3] = c + max(ans[i-1][1],ans[i-1][2]);
	}
	cout << max(ans[n][1], max(ans[n][2], ans[n][3]));
return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#define Max 500000
#define term 1000000000

int Left[(Max/2)+2], Right[(Max/2)+2];
int c=0;


void merge(int e[], int n, int left, int mid, int right){
  int i,j,k;

  int x = (mid-left);
  int y = (right-mid);

  for ( i=0; i<x; i++ )
   Left[i] = e[left+i];
  for ( i=0; i<y; i++ )
   Right[i] = e[mid+i];

  Left[x]= Right[y] = term;
  i = j = 0;
  for ( k=left; k<right; k++){
    c++;
    if ( Left[i]<=Right[j] ){
      e[k] = Left[i++];
    } else {
      e[k] = Right[j++];
    }
  }
}

void mergeSort(int e[], int n, int left, int right ){
  int mid;
  if ( left+1<right ){
    mid=(left + right)/2;
    mergeSort(e, n, left, mid);
    mergeSort(e, n, mid, right);
    merge(e, n, left, mid, right);
  }
}

int main(){
  int e[Max], n, i;
  scanf("%d", &n);
  for ( i=0; i<n; i++) {
    scanf("%d", &e[i]);
    if (e[i]>=term ){
      return 1;
    }
  }
  mergeSort(e,n,0,n);

  for ( i=0; i<n; i++) {
    if ( i !=0 ) 
    printf(" ");

    printf("%d", e[i]);
    }
  printf("\n");

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


  return 0;
}




Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N,K=0;
    string s;
    char x,y;
    cin >> N >> s;
    for(int i = 0; i < N-1;i++){
        x=s.at(i+1);
        y=s.at(i);
        if(x!=y){
            K++;
        }
    }
    cout << K+1 << endl;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] inputs = line.split("/");

		String ans;
		if(Integer.parseInt(inputs[1]) > 4){
			ans = "TBD";
		}else{
			ans = "Heisei";
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#define ll long long

using namespace std;

int main(){
  int N;
  cin >> N;
  int a = N / 100;
  int b = (N - 100*a) / 10;
  int c = (N - 100*a - 10*b);
  if(a == 7 || b == 7 || c == 7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
       cout << "H" << endl;
     }else{
       cout << "D" << endl;
     }
  }else if(a=='D'){
     if(b=='H'){
       cout << "D" << endl;
     }else{
       cout << "H" << endl;
     }}
} 

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().strip().split()))
rev = 0
counter = 0
while(rev >= 0):
    for i in range(1, N):
        if(a[i-1] > a[i]):
            a[i-1], a[i] = a[i], a[i-1]
            rev += 1
            counter += 1
    if(rev == 0):
        for j in range(0, N-1):
            print(a[j], end=" ")
        print(a[N-1])
        print(counter)
        break
    rev = 0


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull H;
	cin >> H;
	
	ull ans = 0;
	ull enm = 1;
	
	while(H > 0) {
		ans += enm;
		H /= 2;
		enm *= 2;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        String S = next();

        String[] list = S.split("");

        String before = "";
        int count = 0;
        for(int i=0; i<S.length(); i++){
            String now = list[i];
            String next = i != S.length()-1 ? list[i+1] : "";
            if(now.equals(before)){
                before = now+next;
                i++;
                if(i == S.length()){
                    count--;
                }
            }else{
                before = now;
            }
            count++;
        }

        println(count);
    }

    //各桁の和
    public static int sumDigits(long n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;//合計を返す
    }

    //最大公約数gcd
    static long gcd (long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }
    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 52844
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  if(n % 2 == 1) ok = false;
  for(int i = 0; i < n; i += 2) {
    if(s[i] != 'h') ok = false;
    if(s[i + 1] != 'i') ok = false;
  }
  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main(){
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    int n = A/K;
    int m = B/K;
    if(A%K==0){
        cout << "OK";
    }else if(n<m){
        cout << "OK";
    }else{
        cout << "NG";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s,t; ci(s>>t)
    SORT(s);
    SORT(t);
    REV(t);
  if(s<t) co("Yes")
    else co("No")
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll dp[100005];

void solve(){
    int n;
    cin>>n;
    vector<ll>h(n);
    rep(i,n)cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    rep(i,n-2)dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
    cout<<dp[n-1]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	int k;
	cin >> s >> k;
	
	rep(i,(int)s.size()-1){
		if(s[i] != 'a' && k > 'z'-s[i]){
			k -= ('z'-s[i])+1;
			s[i] = 'a';
		}
	}
	
	k %= 26;
	while(k > 0){
		if(s[s.size()-1] != 'z')s[s.size()-1] ++;
		else s[s.size()-1] = 'a';
		k --;
	}
	
	cout << s << endl;
}



Measured memory_bytes: 512
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        if (a==1)
            System.out.println("Hello World");
        else if (a==2) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            System.out.println(b+c);
        }
    }
}


Measured memory_bytes: 35668
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


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


const int MAX_N = 100010;
int a[8];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, 4)a[i] = s[i] - '0';
	rep(bit, 1 << 4) {
		int sum = a[0];
		rep(i, 3) {
			if (bit&(1 << i)) {
				sum += a[i+1];
			}
			else {
				sum -= a[i+1];
			}
		}
		if (sum == 7) {
			cout << a[0];
			rep(i, 3) {
				if (bit & (1 << i)) {
					cout << "+";
				}
				else {
					cout << "-";
				}
				cout << a[i + 1];
			}
			cout << "=7" << endl; return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private class Box {
        int bolls;
        boolean isRed;

        public Box() {
            bolls = 1;
            isRed = false;
        }

        public void add(Box src) {
            this.isRed |= src.isRed;
            this.bolls += 1;

            src.bolls -= 1;
            if (src.bolls == 0) {
                src.isRed = false;
            }
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        Box boxs[] = new Box[n];
        for (int i = 0; i < n; i++) {
            boxs[i] = new Box();
        }

        boxs[0].isRed = true;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            boxs[y - 1].add(boxs[x - 1]);
        }

        System.out.println(Arrays.stream(boxs).mapToInt(box -> box.isRed ? 1 : 0).sum());
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 87876
n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

score = -10**18
for st in range(n):
    lap_sc = sum_sc = 0
    nx = st
    for lap_cn in range(1, max(n, k)+1):
        lap_sc += C[nx]
        nx = P[nx]
        if nx == st: break
    lap_sc = max(0, lap_sc)

    for k_cn in range(1, k+1):
        sum_sc += C[nx]
        score = max(score, sum_sc + lap_sc * ((k - k_cn) // lap_cn))
        nx = P[nx]
        if nx == st: break

print(score)


Measured memory_bytes: 74284
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <strings.h>
using namespace std;

int main()
{
    string s;
    getline(cin,s);
    for(int i = 0; i < s.size(); i++)
    {
        if (isupper(s[i]))
            s[i] = tolower(s[i]);
        else if (islower(s[i]))
            s[i] = toupper(s[i]);
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3144
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == 0:
        M = A[0]
    else:
        if A[i] > M:
            M = A[i]
        else:
            ans = ans + M - A[i]
print(ans)


Measured memory_bytes: 32152
#include<iostream>
using namespace std;
int main(){
 int n,x,y;
  cin>>n>>x>>y;
  int ans[n];
  for(int i=1;i<n;++i){
    ans[i]=0;
  }
  for(int i=1;i<=n;i++){
   for(int j=i+1;j<=n;j++){
     ans[min(abs(i-j),abs(i-x)+1+abs(j-y))]++;
   }
  }
  for(int i=1;i<=n-1;i++) cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 256
#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 D;
    cin >> D;
    vector<int> c(26), t(D);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26)), last(D + 1, vector<int>(26, 0));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    ll p = 0;
    rep(d, D) {
        ll q, r, maxq = -1e18;
        rep(j, 26) {
            q = s[d][j];
            rep(i, 26) last[d + 1][i] = last[d][i];
            last[d + 1][j] = d + 1;
            rep(i, 26) {
                q -= c[i] * (d + 1 - last[d + 1][i]);
            }
            if (q > maxq) {
                maxq = q;
                r = j;
            }
        }
        cout << r + 1 << "\n";
        p += q;
    }
}

Measured memory_bytes: 3728
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N; cin >> N;

    ll K = N;
    ll ans = 0;
    vector<int> A;
    for (ll i = 2; i*i <= N; i++) {
        if (K%i==0) {
            int cnt = 0;
            while (K%i==0) {
                K/=i;
                cnt++;
            }
            A.emplace_back(cnt);
        }
    }
    if (K != 1) ans++;
    for (auto& i : A) {
        int cur = 1;
        while (i >= cur) {
            i -= cur;
            ans++;
            cur++;
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 3656
use std::io;

fn abc(n:i32) -> String {
    let mut s_n:i32 = 0;
    let str_n:String = n.to_string();

    for x in str_n.chars() {
        let x_int:i32 = x as i32 - 48;
        s_n += x_int; 
    }

    if n % s_n == 0 {
        return "Yes".to_string();
    }
    else {
        return "No".to_string();
    }
}


fn main() {
    /*
    assert_eq!(abc(12), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */

    let stdin = io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line).ok();
    let txt:Vec<_> = line.trim().split(' ').collect();
    let n:i32 = txt[0].parse().unwrap();

    let result = abc(n);
    println!("{}", result);
}



Measured memory_bytes: 4352
n,q = map(int, input().split())
group = [[i] for i in range(n)]
key = [i for i in range(n)]
for j in range(q):
    com, x, y = map(int, input().split())
    if com == 1:
        if key[x] == key[y]:
            print(1)
        else:
            print(0)
    else:
        if key[x] != key[y]:
            v = key[y]
            group[key[x]] += group[v]
            for i in group[v]:
                key[i] = key[x]
            group[v] = []


Measured memory_bytes: 7488
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int N = S.size();
    int M = T.size();

    vector<vector<int>> dp(N+1, vector<int>(M+1));
    rep(i,M+1) dp[0][i] = i;
    rep(i,N+1) dp[i][0] = i;
    rep(i,N) {
        rep(j,M) {
            if (S[i] == T[j]) dp[i+1][j+1] = dp[i][j];
            else dp[i+1][j+1] = min({dp[i][j]+1,dp[i][j+1]+1,dp[i+1][j]+1});
        }
    }

    cout << dp[N][M] << endl;
}


Measured memory_bytes: 6752
#include <iostream>
#include <utility>
#include <vector>
#include <tuple>
#include <cstdint>

using namespace std;

// Type aliases
using i8  =  int8_t; using  u8 =  uint8_t;
using i16 = int16_t; using u16 = uint16_t;
using i32 = int32_t; using u32 = uint32_t;
using i64 = int64_t; using u64 = uint64_t;

template <class T> using V = vector<T>;

// Loops
#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, n, m) for (int i = n; i < m; ++i)
#define FORR(i, n, m) for (int i = m - 1; i >= n; --i)

// Input
template <class T>
T read() {
    T t;
    cin >> t;
    return t;
}

template <class T>
vector<T> read(const int length) {
    vector<T> ts(length);
    for (auto& t: ts) {
        cin >> t;
    }
    return ts;
}

// Output
namespace debug {
    template <class F, class S>
    ostream &operator<<(ostream& stream, const pair<F, S> &pair) {
        stream << "{" << pair.first << ", " << pair.second << "}";
        return stream;
    }
    template <class Arg, class ...Args>
    void output(ostream& stream, tuple<Arg, Args...> tuple) {
        stream << get<1>(tuple) << ", ";
        // TODO
    }
    template <class Arg>
    void output(ostream& stream, tuple<Arg> tuple) {
        stream << get<1>(tuple);
    }
    template <class ...Args>
    ostream &operator<<(ostream& stream, const tuple<Args...> &tuple) {
        stream << "{";
        output(stream, tuple);
        stream << "}";
        return stream;
    }

    template <class T, class Alloc>
    ostream &operator<<(ostream& stream, const vector<T, Alloc> &vector) {
        stream << "[";

        for (auto i = 0; i < vector.size(); i++) {
            stream << vector[i];

            if (i != vector.size() - 1) {
                stream << "," << ((i % 10 == 9) ? "\n " : "\t");
            }
        }

        stream << "]";
        return stream;
    }
}

// Body
void body() {
    auto N = read<u16>();
    auto M = read<u16>();

    vector<u16> r(N, 0);

    REP(i, M) {
        auto a_i = read<u16>();
        auto b_i = read<u16>();

        
        r[a_i - 1] += 1;
        r[b_i - 1] += 1;
    }

    for (auto &x: r) {
        cout << x << endl;
    }
}

// main function (DO NOT EDIT)
int main () {
    ios_base::sync_with_stdio(false);
    body();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,W,H;
  cin>>N>>W>>H;
  int imosH[H+2], imosW[W+2];
  CLR(imosH);
  CLR(imosW);
  FOR(i,0,N){
    int x,y,w;
    cin>>x>>y>>w;
    imosW[max(0,x-w)]++;
    imosW[min(W,x+w)]--;
    imosH[max(0,y-w)]++;
    imosH[min(H,y+w)]--;
  }
  bool ok = false;
  FOR(i,0,H+1){
    if(i) imosH[i] += imosH[i-1];
    if(imosH[i]==0&&i!=H) {
      break;
    }
    if(i==H) ok = true;
  }
  FOR(i,0,W+1){
    if(i) imosW[i] += imosW[i-1];
    if(imosW[i]==0&&i!=W) {
      break;
    }
    if(i==W) ok = true;
    
  }
  cout<<(ok?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=1e5+10;
const int mod=1e9+7;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,a[N],in[N],ans=1,cnt[N],fa[N],f[N],pre[N];
bool vis[N];
vi vec[N];

int getf(int x) {
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}

void No() {
	cout<<0;exit(0);
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++) a[i]=gi(),++in[a[i]],fa[getf(i)]=getf(a[i]);
	for(int i=1;i<=n;i++) if(in[i]>2) No();
	for(int i=1;i<=n;i++) vec[getf(i)].pb(i);
	for(int u=1;u<=n;u++)
		if(getf(u)==u) {
			bool fl=1;int sz=0;
			for(auto x:vec[u]) {
				++sz;
				if(in[x]!=1) fl=0;
			}
			//cerr<<u<<' '<<fl<<' '<<sz<<'\n';
			if(fl) ++cnt[sz];
			else {
				int now=u;
				while(!vis[now]) vis[now]=1,now=a[now];
				for(auto x:vec[u]) vis[x]=0;
				while(!vis[now]) vis[now]=1,pre[a[now]]=now,now=a[now];
				for(auto x:vec[u])
					if(in[x]>1&&!vis[x]) No();
				for(auto x:vec[u])
					if(!in[x]) {
						int now=x,l1=0,l2=0;
						while(!vis[now]) ++l1,now=a[now];
						++l2;now=pre[now];
						while(in[now]==1) ++l2,now=pre[now];
						//cerr<<l1<<' '<<l2<<'\n';
						if(l1>l2) No();
						if(l1<l2) ans=2ll*ans%mod;
					}
			}
		}
	for(int k=1;k<=n;k++) {
		for(int i=0;i<=cnt[k];i++) f[i]=0;
		f[0]=1;
		for(int i=1;i<=cnt[k];i++) {
			f[i]=f[i-1]*((k&1)&&k>1?2:1)%mod;
			if(i>1) f[i]=(f[i]+1ll*f[i-2]*(i-1)%mod*k)%mod;
		}
		ans=1ll*ans*f[cnt[k]]%mod;
		//cerr<<"k,cnt[k]="<<k<<' '<<cnt[k]<<'\n';
	}
	cout<<ans;
	return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> table(H,vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  vector<vector<char>> table2(0,vector<char>(W));
  int Hnew = H;
  
  for (int i = 0; i < H; i++) {
    bool keep = false;
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '#') {
        keep = true;
        break;
      }
      if (j == W-1) {
        Hnew--;
      }
    }
    if (keep) {
      table2.push_back(table.at(i));
    }
  }
  
  vector<vector<char>> table3(Hnew);
  int Wnew = W;
  
  for (int j = 0; j < W; j++) {
    bool keep = false;
    for(int i = 0; i < Hnew; i++) {
      if (table2.at(i).at(j) == '#') {
        keep = true;
        break;
      }
      if (i == Hnew-1) {
        Wnew--;
      }
    }
    if (keep) {
      for (int i = 0; i < Hnew; i++) {
        table3.at(i).push_back(table2.at(i).at(j));
      }
    }
  }
  
  for (int i = 0; i < Hnew; i++) {
    for (int j = 0; j < Wnew; j++) {
      cout << table3.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3660
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

X, Y = map(int, input().split())
for i in range(X+1):
	if i*4 + (X-i)*2 == Y:
		print('Yes')
		sys.exit()
print('No')

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;
const ll MAX_N = 3e3 + 10;
ll dp[MAX_N][MAX_N];

// 整数を2進法表記した文字列（0埋めしてk桁にする）を返す
string tobin(ll n, ll k) {
	string out = "";
	ll len = 1;
	ll div = 1;
	while (1) {
		if (n / div < 2) {
			break;
		}
		len++;
		div *= 2;
	}
	for (ll i = 0; i < len; i++) {
		if (n / div >= 1) {
			out = out + "1";
			n -= div;
		}
		else {
			out = out + "0";
		}
		div /= 2;
	}
	if (out.length() <= k) {
		out = string(k - out.length(), '0') + out;
	}

	return out;
}

int main(){
    ll i, j;
    ll N;
    cin>>N;
    vll A(N);
    for(auto &e: A)cin>>e;
    ll a = -1, b = -1, c = -1;
    a = A[0];
    ll nt = 1;
    bool ok = true;

    for(i=1; i<N;i++){
        if(A[i] != a){
            if(nt == 1){
                b = A[i];
                nt++;
            }
            else if(A[i] != b){
                if(nt == 2){
                    c = A[i];
                    nt++;
                }
                else if(A[i] != c){
                    ok = false;
                    break;
                }
            }

        }
    }

    if(nt == 1 && A[0] == 0){
        cout<<"Yes"<<endl;
        return 0;
    }

    if(N%3 != 0){
        cout<<"No"<<endl;
        return 0;
    }

    if (!ok){
        cout<<"No"<<endl;
        return 0;
    }

    ll na = 0, nb = 0, nc = 0;
    for(auto e: A){
        if(e==a){
            na++;
        }
        else if(e==b){
            nb++;
        }
        else if(e==c){
            nc++;
        }
    }
    if(na != nb || nb != nc){
        if(na != nb * 2 && nb != na * 2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(na == nb * 2){
        c = a;
    }
    if(nb == na * 2){
        c = b;
    }

    string sa = tobin(a, 50);
    string sb = tobin(b, 50);
    string sc = tobin(c, 50);
    for(i = 0; i<50; i++){
        if(sa[i] == sb[i]){
            if(sc[i] != '0'){
                ok = false;
            }
        }
        if(sa[i] != sb[i]){
            if(sc[i] != '1'){
                ok = false;
            }
        }
    }
    if(!ok){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define fore(i, x) for (auto &i : n)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

int dp[201010];

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> P(n);
    rep(i, n) cin >> P[i];

    int ans = 0;
    rep(i, n) {
        int p = P[i];
        dp[p] = dp[p - 1] + 1;
        chmax(ans, dp[p]);
    }

    cout << n - ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
// finish date: 2018/04/09

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S=="abc") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256