akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
ll A[maxn], B[maxn];
ll f(ll a, ll b)
{
    return a % b ? b - a % b : 0;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i] >> B[i];
    ll add = 0, ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        ans += f(add + A[i], B[i]);
        add += f(add + A[i], B[i]);
        // cout<<add<<" "<<ans<<endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
  vector<bool> E(1000000, true);
  E[0] = false;
  E[1] = false;
  for (int i = 2; i*i < 1000000; ++i) {
    for (int j = i; i*j < 1000000; ++j) {
      E[i*j] = false;
    }
  }
  int a, d, n, t;
  while (cin >> a >> d >> n, a) {
    t = a;
    while (n) {
      if (E[t]) --n;
      t += d;
    }
    cout << t-d << endl;
  }
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll k = a + b;
    ll ans = (n / (a + b)) * a;
    n %= a + b;
    ans += min(a, n);
    cout << ans << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll          long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

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


int main() {

    ISO();
   // online_judge();
    int d,t,s;
    cin >> d >> t >> s;
    ll ds = s*t;
    if(ds >= d)
        cout <<"Yes\n";
    else
        cout <<"No\n";






    //cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// メモ用の DP テーブル
long long dp[100010];

long long rec(int i) {
    // DP の値が更新されていたらそのままリターン
    if (dp[i] < INF) return dp[i];

    // 足場 0 のコストは 0
    if (i == 0) return 0;

    // i-1, i-2 それぞれ試す
    long long res = INF;
    chmin(res, rec(i-1) + abs(h[i] - h[i - 1])); // 足場 i-1 から来た場合
    if (i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i - 2])); // 足場 i-2 から来た場合

    // 結果をメモしながら、返す
      return dp[i] = res;
}

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 答え
    cout << rec(N-1) << endl;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    vll a(n); rep(i, n) cin >> a[i];

    ll diff = 0;
    ll ans = 0;
    rep2(i, 1, n){
        diff = 0;
        if(a[i]<a[i-1]){
            diff = a[i-1]-a[i];
            a[i] += diff;
            ans += diff;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
int main(){
  int i,j,f=0,n;
  scanf("%d",&n);
  for(i=0;i<=n/4;i++)for(j=0;j<=n/7;j++)if(n==4*i+7*j)f=1;
  puts(f?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_three_letter_acronym(void) {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	char diff = 'A' - 'a';

	printf("%c%c%c\n", s1[0] + diff, s2[0] + diff, s3[0] + diff);
}

int main()
{
    a_three_letter_acronym();
    return 0;
}

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



int main(){
	bitset<64> bs;
	int q,k,x;
	cin >> q;
	while(q--){
		cin >> k;
		if(k==0){
			cin >> x;
			cout << bs[x] << endl;
		}else if(k==1){
			cin >> x;
			bs[x] = 1;
		}else if(k==2){
			cin >> x;
			bs[x] = 0;
		}else if(k==3){
			cin >> x;
			bs.flip(x);
		}else if(k==4){
			cout << bs.all() << endl;
		}else if(k==5){
			cout << bs.any() << endl;
		}else if(k==6){
			cout << bs.none() << endl;
		}else if(k==7){
			cout << bs.count() << endl;
		}else{
			cout << bs.to_ullong() << endl;
		}
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l;
  cin>>l;
  stack<int> st;
  vector<bool> fg(1000,false);
  for(int i=0;i<l;i++){
    int c;
    cin>>c;
    if(c>0){
      if(fg[c]){
        cout<<i+1<<'\n';
        return(0);
      }
      fg[c]=true;
      st.push(c);
    }
    else{
      if(!st.empty()){
        if(st.top()!=-c){
          cout<<i+1<<'\n';
          return(0);
        }
        st.pop();
        fg[-c]=false;
      }
      else{
        cout<<i+1<<'\n';
        return(0);
      }
    }
  }
  cout<<"OK"<<'\n';
  return(0);
}


Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int pay = 700;
    if (s[0] == 'o')
        pay = pay + 100;
    if (s[1] == 'o')
        pay = pay + 100;
    if (s[2] == 'o')
    {
        pay = pay + 100;
    }
    cout << pay << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
using namespace std;


int main() {
	long long int n, m;
	long long int f, s;
	long long int sum = 0;
	cin >> n >> m;
	
	vector<pair<long long int, long long int>> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> f >> s;
		a[i] = make_pair(f, s);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++)
	{
		if (a[i].second < m)
		{
			m -= a[i].second;
			sum += a[i].second*a[i].first;
		}
		else
		{
			sum += a[i].first*m;
			break;
		}
	}

	cout << sum << endl;



	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}




int dis[10][10];





int main()
{

	int n;
	cin >> n;

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

	int ans = 1;

	int pre = a[0];
	for (int i = 1; i < n; i++) {
		if (mode == 0) {
			if (a[i] > pre)mode = 1;
			else if (a[i] < pre)mode = -1;
		}
		else if (mode == 1) {
			if (a[i] < pre) {
				mode = 0;
				ans++;
			}
		}
		else if (mode == -1) {
			if (a[i] > pre) {
				mode = 0;
				ans++;
			}
		}

		pre = a[i];
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 640
from heapq import*
n,m=map(int,input().split())
p=sorted(map(int,input().split()))
heapify(p)
q=sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:x[1],reverse=1)

for s,t in q:
    for i in range(s):
        tmp=heappop(p)
        if t>tmp:
            heappush(p,t)
        else:
            heappush(p,tmp)
            print(sum(p))
            exit()
print(sum(p))
#    print(p,q)

Measured memory_bytes: 92184
#include <stdio.h>

int main(){
  int x, y, temp, r;

  scanf("%d %d", &x, &y);

  if(x < y){
    temp = x;
    x = y;
    y = temp;
  }

  while(1){
    r = x % y;
    x = y;
    y = r;
    if(r == 0)break;
  }

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

  return 0;
}


Measured memory_bytes: 2140
#include <iostream>

using namespace std;

int main()
{

	int r, g, b;
	cin >> r >> g >> b;

	if ((10 * g + b) % 4 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;

}

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

const int maxn = 100010;
int N,M,A[maxn];

inline int gi()
{
	int ret = 0,f = 1; char ch;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline bool check()
{
	for (int i = 1;i <= N;++i) if (A[i]&1) return false;
	return true;
}

int main()
{
	//freopen("H.in","r",stdin);
	//freopen("H.out","w",stdout);
	N = gi(); M = gi();
	for (int i = 1;i <= M;++i)
		A[gi()]++,A[gi()]++;
	if (check()) puts("YES"); else puts("NO");
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
string s; int w;
int mi[302][302][309];
char sa[333];
int main()
{
	cin>>s>>w; int ans=0,p=s.size();
	for(int i=0;i<p;++i) sa[i+1]=s[i];
	memset(mi,127/3,sizeof mi);
	for(int i=1;i<=p;++i)
		mi[i][i-1][0]=0;
	for(int i=p;i>=1;--i)
	{
		for(int j=i;j<=p;++j)
		{
			for(int k=0;k<=p;++k)
			{
				if(i==j&&k<=1)
					mi[i][j][k]=min(mi[i][j][k],0);
				else
				{
					mi[i][j][k]=min(mi[i][j][k],mi[i][j-1][k]);
					mi[i][j][k]=min(mi[i][j][k],mi[i+1][j][k]);
					mi[i][j][k+2]=min(mi[i][j][k+2],mi[i+1][j-1][k]+(sa[i]!=sa[j]));
				}
			}
		}
	}
	for(int k=p;k>=0;--k)
		if(mi[1][p][k]<=w)
		{
			printf("%d\n",k);
			return 0;
		}
}


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

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

    int cnt = 0;
    bool flag = false;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a == b)
            cnt++;
        else
            cnt = 0;

        if (cnt == 3)
            flag = true;
    }

    if (flag || cnt == 3)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll; 
const int maxs = 2000001;

// int main(){

//    ll t, i, j, a, b, c, f, s, k, l, resa, resb, resc;

//    cin>>t;

//    while(t--){
//         cin>>a>>b>>c;
//         ll res = 1000000;
//         for(i = 1;i <= b;i++){
//             for(j = 1;j <= min(a, i);j++){
//                  s = i;
//                  f = j;
//                //  cout<<f<<" "<<s<<"\n";
//                  if(s%f!=0){
//                      continue;
//                  }
//                  else{
//                    k = s;
//                    while(k <= c){
//                        k += s;
//                    }
//                    if(k != c)
//                      k -= s;
//                    res = min(res, a-f+b-s+c-k);  
//                    //cout<<f<<" "<<s<<" "<<k<<"\n";
//                    resa = f;
//                    resb = s;
//                    resc = k;


//                  }
//             }
//         }
//         cout<<res<<"\n";
//         cout<<resa<<" "<<resb<<" "<<resc<<"\n";
//    }
// }


int main(){
   ll n, i, j, k, w, res = 0;

   cin>>n>>w;

   ll in[n][2];

   for(i = 0;i < n;i++)
    cin>>in[i][0]>>in[i][1];

   ll dp[n+1][w+1];
   memset(dp, 0, sizeof(dp));

   for(i = 0 ;i < n;i++){
       for(j = 1;j <= w;j++){
            if(i == 0){
                if(j >= in[i][0]){
                    dp[i][j] = in[i][1];
                }
                else{
                    dp[i][j] = 0;
                }
            } 
            else{
                if(j-in[i][0] >= 0)
                 dp[i][j] = max(dp[i-1][j], dp[i-1][j-in[i][0]] + in[i][1]);
                else{
                    dp[i][j] = dp[i-1][j];
                } 
            }
            res = max(res, dp[i][j]);
       }
   } 
//    for(i =0 ;i < n;i++){
//        for(j = 1;j <= w;j++){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<"\n";
//    }
   cout<<dp[n-1][w];
}

Measured memory_bytes: 79104
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N, M;
vector<vector<int>> G;

void DFS(int v, vector<bool> &seen, int &res){
	bool end = true;
	//全部訪問したかをチェックする
	rep(i,seen.size()){
		if(!seen[i] && i!=v) end = false;
	}
	if(end){//全部訪問したらカウント+1
		res++;
		return;
	}
	seen[v] = true;//現在訪問した所にチャック
	for(auto nv : G[v]){
		if(seen[nv]) continue;
		DFS(nv,seen,res);
	}
	seen[v] = false;
}

int main(){
	cin >> N >> M;
	G.resize(N);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].pb(b);
		G[b].pb(a);
	}	
	
	vector<bool> seen(N,false);
	int res = 0;
	DFS(0,seen,res);
	cout << res << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def check(vec, init_pos, target_pos):
    dp = {init_pos}

    for nv in vec:
        if nv == 0:
            continue
        dp_next = set()
        for v in dp:
            dp_next.add(v - nv)
            dp_next.add(v + nv)
        dp = dp_next

    return target_pos in dp


def main():
    S = readline().strip()
    x, y = map(int, readline().split())

    L = [len(commands) for commands in S.split('T')]

    init_x = L[0]
    x_commands = L[2::2]
    y_commands = L[1::2]

    ok = check(x_commands, init_x, x) and check(y_commands, 0, y)

    if ok:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    char a;
    int w[30]={0};
    while (scanf("%c",&a)!=EOF)  {
        if (isupper(a)) w[a-'A']+=1;
        else if (islower(a)) w[a-'a']+=1;
    }
    rep(i,26)  printf("%c : %d\n",i+'a',w[i]);
    return 0;
}


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

int H, W, K;
vector<vector<char>> field(301,vector<char>(301,'.'));
vector<vector<int>> ans(301,vector<int>(301,0));

int main()
{
    cin >> H >> W >> K;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> field[i][j];
        }
    }

    long long cnt = 1;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(field[i][j] == '#')
            {
                ans[i][j] = cnt;
                int k = j+1;
                while(k < W)
                {
                    if(field[i][k] == '.') ans[i][k] = cnt;
                    else break;
                    k++;
                }
                k = j-1;
                while(k >= 0)
                {
                    if(field[i][k] == '.') ans[i][k] = cnt;
                    else break;
                    k--;
                }
                cnt++;
            }
        }
    }

    // イチゴがない行を探索
    for(int i = 0; i < H; i++)
    {
        if(ans[i][0] == 0)
        {
            bool flag = true;
            int k = i-1;
            while(k >= 0)
            {
                if(ans[k][0] != 0)
                {
                    flag = false;
                    for(int j = 0; j < W; j++)
                    {
                        ans[i][j] = ans[k][j];
                    }
                    break;
                }
                k--;
            }
            if(flag == true)
            {
                k = i+1;
                while(k < H)
                {
                    if(ans[k][0] != 0)
                    {
                        for(int j = 0; j < W; j++)
                        {
                            ans[i][j] = ans[k][j];
                        }
                        break;
                    }
                    k++;
                }
            }
        }
    }

    // output
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(j == W-1) cout << ans[i][j] << endl;
            else cout << ans[i][j] << " ";
        }
    }

    return 0;
}

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

signed main(){
	int n,m;
	cin>>n;
	vector<int>a(n);
	r(i,n)cin>>a[i];
	cin>>m;
	vector<int>b(m);
	r(i,m)cin>>b[i];
	cout<<lexicographical_compare(a.begin(),a.end(),b.begin(),b.end())<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	int n;
	cin >> n;
	if (n < 105) {
		cout << "0" << endl;
	}
	else if (n < 135) {
		cout << "1" << endl;
	}
	else if (n < 165) {
		cout << "2" << endl;
	}
	else if (n < 189) {
		cout << "3" << endl;
	}
	else if(n<195){
		cout << "4" << endl;
	}
	else {
		cout << "5" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
vector<int> ch(26);

bool calc_4(int a) {  // aの処理
  for (int i = 0; i < ch.size(); i++) {
    if (ch[i] >= 4 && a > 0) {
      int tmp = min(ch[i] - (ch[i] % 4), a);
      a -= tmp;
      ch[i] -= tmp;
    }
  }
  if (a != 0) {
		//cerr << "a:false" << endl;
    return false;
  } else {
    return true;
  }
}

bool calc_2(int b) {  // bの処理
  for (int i = 0; i < ch.size(); i++) {
    if (ch[i] >= 2 && b > 0) {
      int tmp = min(ch[i] - (ch[i] % 2), b);
      b -= tmp;
      ch[i] -= tmp;
    }
  }
  if (b != 0) {
		//cerr << "b:false" << endl;
    return false;
  } else {
    return true;
  }
}

int main() {
  int h, w;

  bool ans = true;

  cin >> h >> w;

  for (int i = 0; i < 26; i++) {
    ch[i] = 0;
  }

  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < w; j++) {
      ch[s[j] - 'a']++;
    }
  }
  sort(ch.begin(), ch.end());
  reverse(ch.begin(), ch.end());
  int cnt = 0;

  for (int i = 0; i < 26; i++) {
    if (ch[i] != 0) {
      cnt++;
    }
  }
  ch.erase(ch.begin() + cnt, ch.end());

  for (int i = 0; i < ch.size(); i++) {
    //cerr << ch[i] << " ";
  }
  //cerr << endl;

	if (h % 2 == 1 && w % 2 == 1) {  //奇奇

		int cnttt = 0;

		for (int i = 0; i < ch.size(); i++) {
			if(ch[i] % 2 == 1){
				ch[i]--;
				cnttt++;
			}
		}
		
    int a = (h - 1) * (w - 1);
    int b = h - 1;
    int c = w - 1;
    ans = calc_4(a);
    ans = calc_2(b);
    ans = calc_2(c);

    int sum = accumulate(ch.begin(), ch.end(), 0);
    if (sum != 0) {
      ans = false;
		}
		if(cnttt > 1){
			ans = false;
		}

  } else if (h % 2 == 0 && w % 2 == 1) {  //偶奇
    int a = h * (w - 1);
    int b = h;
    ans = calc_4(a);
		ans = calc_2(b);
		int sum = accumulate(ch.begin(), ch.end(), 0);
    if (sum != 0) {
      ans = false;
    }

  } else if (h % 2 == 1 && w % 2 == 0) {  //奇偶
    int a = (h - 1) * w;
    int b = w;
    ans = calc_4(a);
		ans = calc_2(b);
		int sum = accumulate(ch.begin(), ch.end(), 0);
    if (sum != 0) {
      ans = false;
    }


  } else {  //偶偶
    int a = h * w;
    ans = calc_4(a);
    // for (int i = 0; i < ch.size(); i++) {
    //   if (ch[i] % 4 != 0) {
    //     ans = false;
    //   }
    // }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 15;
int n, m, x, c[MX], a[MX][MX], aux[MX], res = 1e9;

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

	cin >> n >> m >> x;
	forn (i, n) {
		cin >> c[i];
		forn (j, m)
			cin >> a[i][j];
	}

	for (int i = 1; i < (1 << n); i++) {
		memset(aux, 0, sizeof(aux));
		int s = 0;

		forn (j, n) if (i & (1 << j)) {
			forn (k, m) aux[k] += a[j][k];
			s += c[j];
		}

		int f = 1;
		forn (i, m) if (aux[i] < x) f = 0;

		if (f) res = min(res, s);
	}

	if (res == 1e9) cout << -1 << endl;
	else cout << res << endl;

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int n;
    vector<pair<int,int>> even(100010,{0,0}),odd(100010,{0,0});

    cin >> n;
    vector<int> a(n,0);
    rep(i,n){
        cin >> a[i];
        if(i%2==0){
            even[a[i]].first++;
            even[a[i]].second=a[i];
        }
        else{
            odd[a[i]].first++;
            odd[a[i]].second=a[i];
        }    
    }

    sort(even.begin(),even.end());
    reverse(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    reverse(odd.begin(),odd.end());

    int e1=even[0].first,e2=even[1].first;
    int o1=odd[0].first,o2=odd[1].first;

    if(even[0].second!=odd[0].second){
        cout << n-e1-o1;
    }else{
        cout << n-max(e1+o2,e2+o1);
    }   
    return 0;
}

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

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		int mDistance = 1000000;
		int data[n];
		for(int i = 0; i < n; i++){
			int a = 0;
			cin >> a;
			data[i] = a;
		}
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				if(abs(data[i] - data[j]) < mDistance){
					mDistance = abs(data[i] - data[j]);
				}
			}
		}
		cout << mDistance << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
N = int(input())
a = list(map(int,input().split()))
i = 0
a = sorted(a)
b = []
num = 0
ins = 1
while i < len(a):
    while ins == a[i]:
        num += 1
        if ins == num:
            b.append(ins)
        i += 1
        if len(a) == i:
            break
    if len(a) != i:
        ins = a[i]
    i += 1
    num = 1
print(len(a)-sum(b))

Measured memory_bytes: 14268
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
int n,ans=0;
  cin>>n;
  vector<int> b(n);
  REP(i,n){cin>>b[i];}
  ans+=(b[0]+b[n-2]);
  REP(i,n-1){
  ans+=min(b[i],b[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
# exclude the largest distance between consecutive positions.
# (also considering going around the circle).

K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
largest_diff = 0
for idx in range(N-1):
  diff = A[idx+1]-A[idx]
  largest_diff = max(diff, largest_diff)
diff = A[0] + K - A[N-1]
largest_diff = max(diff, largest_diff)
print(K - largest_diff)

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  vll p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];

  sort(all(p));
  sort(all(q));
  reverse(all(p));
  reverse(all(q));

  priority_queue<ll> qp, qq, qr;
  rep(i, min(a, x)) qp.push(p[i]);
  rep(i, min(b, y)) qq.push(q[i]);
  rep(i, c) qr.push(r[i]);
  qp.push(0);
  qq.push(0);
  qr.push(0);

  ll ans = 0;

  rep(i, x + y) {
    ll mx = 0;
    chmax(mx, qp.top());
    chmax(mx, qq.top());
    chmax(mx, qr.top());

    ans += mx;

    if (mx == qp.top())
      qp.pop();
    else if (mx == qq.top())
      qq.pop();
    else
      qr.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8652
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int m=0, f=0, r=0, i;
    for(i=0; ; i++){
        scanf("%d %d %d", &m, &f, &r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        else if(m==-1 || f==-1){printf("F\n");
        }else if(m+f>=80){printf("A\n");
        }else if(m+f>=65){printf("B\n");
        }else if(m+f>=50){printf("C\n");
        }else if(m+f>=30 && r>=50){printf("C\n");
        }else if(m+f>=30){printf("D\n");
        }else{printf("F\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	set<char> s;
	string ss;
	cin >> ss;
	f(i,0,4){
		s.insert(ss[i]);
	}
	if((int)s.size()==2){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,t[100005],m,p,x,sum,sum2;
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&t[i]);
			sum=sum+t[i];
		}
		scanf("%d",&m);
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&p);
			scanf("%d",&x);
			sum2=sum+x-t[p];
			printf("%d\n",sum2);
		}
		    
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	string s;
	cin >> s;
	if (s.size() == 2) {
		cout << s;
	}
	else {
		cout << s[2] << s[1] << s[0];
	}
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> piipi;
int x[20], y[20], p[20];
long long dp[20][20];
long long cost[20], cost1[20][20], cost2[20], cost3[20];
long long ans[20];
piipi p2[20];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<=n;i++) ans[i] = 1e18;
    vector<int> v;
    for(int i=1;i<=n;i++){
        scanf("%d%d%d", &x[i], &y[i], &p[i]);
        v.emplace_back(y[i]);
        p2[i] = make_pair(make_pair(x[i], y[i]), p[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    sort(p2+1, p2+1+n);
    for(int i=1;i<=n;i++){
        x[i] = p2[i].first.first, y[i] = p2[i].first.second, p[i] = p2[i].second;
    }

    sort(p2+1, p2+1+n);
    int m = v.size();
    for(int i=0;i<(1<<m);i++){
        vector<int> Y;
        int b = __builtin_popcount(i);
        for(int j=0;j<m;j++){
            if((i>>j)&1){
                Y.emplace_back(v[j]);
            }
        }

        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++) dp[i][j] = 1e18;
        }
        memset(cost, 0, sizeof(cost));
        memset(cost1, 0, sizeof(cost1));
        memset(cost2, 0, sizeof(cost2));
        memset(cost3, 0, sizeof(cost3));
        for(int i=1;i<=n;i++){
            cost[i] = min(abs(x[i]), abs(y[i]));
            for(int j=0;j<Y.size();j++){
                cost[i] = min(cost[i], abs(y[i]-Y[j])*1ll);
            }
            cost[i] *= p[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=i+1;k<=j-1;k++){
                    cost1[i][j] += min(cost[k], min(x[k]-x[i], x[j]-x[k])*1ll*p[k]);
                }
            }
        }

        for(int i=1;i<=n;i++){
            for(int j=i;j>=1;j--){
                cost2[i] += min(cost[j], (x[i]-x[j])*1ll*p[j]);
            }
            for(int j=i;j<=n;j++){
                cost3[i] += min(cost[j], (x[j]-x[i])*1ll*p[j]);
            }
        }

        dp[0][0] = 0;
        for(int i=1;i<=n;i++) dp[0][0] += cost[i];
        for(int i=1;i<=n;i++){
            dp[i][1] = cost2[i] + cost3[i];
        }
        ans[b] = min(ans[b], dp[0][0]);

        for(int i=1;i<=n;i++){
            for(int j=i-1;j>=1;j--){
                for(int k=1;k<=n;k++){
                    if(dp[j][k] == 1e18) continue;
                    long long res = dp[j][k] - cost3[j] + cost1[j][i] + cost3[i];
                    dp[i][k+1] = min(dp[i][k+1], res);
                }
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(b+j <= n) ans[b+j] = min(ans[b+j], dp[i][j]);
            }
        }
    }

    for(int i=0;i<=n;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 3788
H,W = map(int, input().split())
map =[]
for _ in range(H):
     a = list(input())
     map.append([int(x !='.') for x in a ])
memo = []
for i in range(H):
    if sum(map[i]) == 0:
        memo.append(i)
while memo:
    del map[memo[-1]]
    del memo[-1]
    H -= 1
for j in range(W):
    color = [map[x][j] for x in range(H)]
    if sum(color) == 0:
        memo.append(j)
while memo:
    for k in range(H):
        del map[k][memo[-1]]
    del memo[-1]
    W = -1
for j in map:
    a = ["." if ab == 0 else "#" for ab in j]
    print("".join(a))

Measured memory_bytes: 3188
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include <array>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template<class c> typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
		cerr << boolalpha << i; return *this;
	}

	template<class c, int=0> typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
		return *this << range(begin(i), end(i));
	}

sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define watch(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL > VPL;
typedef vector<PII > VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef long double ld;

const LL MOD = 998244353;


void solve(int ks) {
	int a, b;
	scanf("%d %d", &a, &b);
	int c = a + b;
	c = MAX(c, a - b);
	c = MAX(c, a * b);
	printf("%d\n", c);
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif


	if (0) {
		int T;
		scanf("%d", &T);
		//AIN(T, 1, 25);
		for (int ks = 1; ks <= T; ks++) {
			solve(ks);
			fprintf(stderr, "%d done\n", ks);
		}
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

M_f = M * 2 + 1
if M % 2 != 0:
    for i in range(0, M // 2):
        print(i + 1, (M) - i)
    for i in range(0, M // 2 + 1):
        print(M + 1 + i, M_f - i)
else:
    for i in range(0, M // 2):
        print(i + 1, (M + 1) - i)
    for i in range(0, M // 2):
        print(M + 2 + i, M_f - i)

Measured memory_bytes: 9188
# coding: utf-8
# Your code here!

def main():
    s = list(input())
    gusu_count = 0
    kisu_count = 0
    
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
                kisu_count += 1
                
        else:
            if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
                gusu_count += 1
                
    if len(s) % 2 != 0:
        if gusu_count == len(s) // 2 and kisu_count == ((len(s) // 2 ) + 1):
            print('Yes')
    
        else:
            print('No')
            
    else:
        if gusu_count == len(s) // 2 and kisu_count == (len(s) // 2):
            print('Yes')
            
        else:
            print('No')
    
    return 0
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#!/usr/bin/env python3
import math
import sys
sys.setrecursionlimit(10**6)
q = int(input())


def is_prime(n):
    if n <= 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


a = []
b = []
c = []
for i in range(0, 10**5+5):
    a_tmp = is_prime(i)

    if i % 2 == 0:
        b_tmp = False
    else:
        b_tmp = is_prime((i+1)//2)

    a.append(a_tmp)
    b.append(b_tmp)
    c.append(a_tmp*b_tmp)

c_sum = [0]
for i in range(1, len(c)):
    c_sum.append(c[i]+c_sum[-1])
# print(c)
# print(c_sum)


for i in range(q):
    l, r = list(map(int, input().split()))
    print(c_sum[r]-c_sum[l-1])


Measured memory_bytes: 14360
#include <iostream>

int main() {
  int N, A, B, C, D;
  std::cin >> N >> A >> B >> C >> D;

  --A;
  --B;
  --C;
  --D;

  std::string S;
  std::cin >> S;

  int oikosi;
  int owari;
  if (C > D) {
    // 岩チェック
    for (int i = A; i < C; ++i) {
      if ((S[i] == '#') && (S[i + 1] == '#')) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    // 追い越しチェック
    for (int i = B; i <= D; ++i) {
      if (S.substr(i - 1, 3) == "...") {
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
    // 無理なら無理
    std::cout << "No" << std::endl;
    return 0;
  } else {
    // 岩チェック
    for (int i = A; i < D; ++i) {
      if ((S[i] == '#') && (S[i + 1] == '#')) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    // 問題なし
    std::cout << "Yes" << std::endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 640
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> H,W,K;
  invec<string> c(H);
  ll rest = 0;
 for (auto&& i : c)
      rest += count(i.cbegin(), i.cend(), '#');


  auto solve = [&](auto f, int rest, int hei, int wid, vector <string> c) -> ll{
      ll res = 0;
    if (hei<H) {
      res += f(f, rest, hei+1, wid, c);
      rest -= count(c[hei].cbegin(), c[hei].cend(), '#');
      c[hei] = "";
      res += f(f, rest, hei+1, wid, move(c));
    }
    else if (wid < W){
      res += f(f, rest, hei, wid+1, c);
      for (auto&& i : c)
        if (i.length() > wid && i[wid] == '#')
      		rest--;
      res += f(f, rest, hei, wid+1, move(c));

    }
    else {
      return (rest == K ? 1 : 0);
    }
    
    return res;
  };
  return solve(solve, rest, 0, 0, c);
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

#define MAXN 100000
int N, K;

int gcd(int a, int b) {
  if(b == 0) return a;
  else return gcd(b, a % b);
}

int main() {
  scanf("%d%d", &N, &K);
  int g; bool x = false;
  for(int i = 0; i < N; ++i) {
    int A; scanf("%d", &A);
    if(i == 0) g = A; else g = gcd(g, A);
    if(A >= K) x = true;
  }
  printf("%s\n", x && K % g == 0 ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 256