akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;

/*
*/

struct D{
	ll y1,x1,y2,x2;
	// D(a,b,c,d){y1=a;x1=b;y2=c;x2=d};
};

int main(void){
	ll h,w,a[510][510];
	vector<D> ans;
	cin>>h>>w;
	reg(i,1,h)reg(j,1,w)cin>>a[i][j];
	reg(i,1,h){
		reg(j,1,w-1){
			if(a[i][j]%2==1){
				a[i][j]--;
				a[i][j+1]++;
				ans.push_back({i,j,i,j+1});
			}
		}
	}
	reg(i,1,h-1){
		if(a[i][w]%2==1){
			a[i][w]--;
			a[i+1][w]++;
			ans.push_back({i,w,i+1,w});
		}
	}
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		printf("%lld %lld %lld %lld\n",ans[i].y1,ans[i].x1,ans[i].y2,ans[i].x2);
	}
	return 0;
}

Measured memory_bytes: 8432
a,b,c = gets.chop.split.map(&:to_i)
k = gets.to_i
tmp = 0
if a > b && a > c
  tmp = a
  a = 0
elsif b > c
  tmp = b
  b = 0
else
  tmp = c
  c = 0
end
i = 0
while i < k
  tmp *= 2
  i += 1
end
puts a+b+c+tmp

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

long long dp[1001][1001];
const long long mod = 1e9 + 7;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> path;
	string s;
	for (int i = 0; i < h; i++) {
		cin >> s;
		path.push_back(s);
	}

	for (int i = 0; i <= h - 1; i++) {
		for (int j = 0; j <= w - 1; j++) {
			if (i == 0 && j == 0) {
				dp[i][j] = 1;
			}
			if (path[i][j] != '#') {
				dp[i][j] += (i - 1 >= 0) ? dp[i - 1][j] : 0;
				dp[i][j] %= mod;
				dp[i][j] += (j - 1 >= 0) ? dp[i][j - 1] : 0;
				dp[i][j] %= mod;
			}
		}
	}

	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

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

int main(){

    string s;
    cin >> s;

    int ans = 0, pos = 0;
    char lbuf, rbuf;
    int lpos, rpos;
    lpos = 0;
    rpos = 1;
    vector<int> lpos_mem;
    while (rpos<s.size()){
        lbuf = s.at(lpos);
        rbuf = s.at(rpos);

        if (lbuf != rbuf){
            ans += 2;
            if(lpos_mem.size() != 0){
                rpos++;
                lpos = lpos_mem.at(lpos_mem.size()-1);
                lpos_mem.pop_back();
            }
            else{
                rpos += 2;
                lpos = rpos-1;
            }
        }
        else{
            lpos_mem.push_back(lpos);
            rpos++;
            lpos = rpos-1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int main() {
	string s;
	cin >> s;
	int a, z;
	a = s.find_first_of('A');
	z = s.find_last_of('Z');
	cout << z - a + 1 << endl;
	return 0;
}

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

using namespace std;

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  vector<long long> seen(n,1);
  vector<long long>ans={1};
  long long a;
  long long b;
  long long c=1;
  long long d=1;
  long long count=0;
  
  while(d==1){
    if(seen.at(c-1)==1){
    ans.push_back(vec.at(c-1));
      seen.at(c-1)=0;
      c=vec.at(c-1);
      count++;
    }
    else{
      b=count;
      for(long long j=0;j<b;j++){
        if(ans.at(j)==c){
          a=j;
          break;
        }
      }
      d=0;
    
   }
  }
 
    if(k<a){
      cout<<ans.at(k)<<endl;
    }
    else{
     long long e=(k-a)%(b-a);
      cout<<ans.at(a+e)<<endl;
    }
  
  
  


  
}

Measured memory_bytes: 8496
n, m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

mod = 10**9+7

SX = 0
for i in range(n):
    SX += i*X[i] - (n-1-i)*X[i]
SX %= mod

SY = 0
for i in range(m):
    SY += i*Y[i] - (m-1-i)*Y[i]
SY %= mod

ans = SX*SY
print(ans%mod)

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

int main(){
    int N,sum = 0;
    cin >> N;
    vector<int> B(N-1);

    rep(i, N-1){
        cin >> B.at(i);
    }
    
    rep(i, N-2){
        sum += min(B.at(i), B.at(i+1));
    }
    cout << sum + B.at(0) + B.at(N-2) << endl;

}

Measured memory_bytes: 256
#include<cstdio>
int main (){
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	switch(c){
		case '+': printf("%d\n",a+b);break;
		case '-': printf("%d\n",a-b);break;
		case '*': printf("%d\n",a*b);break;
		case '/': printf("%d\n",a/b);break;
	}
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N;
	cin >> N;
	double ans = 0;
	fx(N) {
		double a;
		cin >> a;
		ans += 1 / a;
	}
	cout << fixed << setprecision(10) << 1/ans << endl;
    return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 R, G, B, N;
	int64 res = 0;
	cin >> R >> G >> B >> N;
	REP(i, N+1) {
		REP(j, N+1) {
			if (i*R+j*G <= N && (N-i*R-j*G) % B == 0) {
				res++;
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int cnt[550][550];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 101; i += 4) {
		for (int j = 0; j < 101; j += 7) {
			if (i + j == n) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// AtCoder Grand Contest 037
int main(){
    
    string s; 
    cin >> s;

    int ans = 1;
    char now = s[0];
    for(int i = 1; i < (int)s.size(); i++){
        if(s[i] == now){
            i++;
            now = '*';
            if(i >= (int)s.size())break;
        } else {
            now = s[i];
        }
        ans++;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int card[100500];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<l_l> v;
    ll ans = 0;
    ll N, M;
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        ll in;
        cin >> in;
        v.push_back({in, 1});
    }
    while(M--) {
        ll b, c;
        cin >> b >> c;
        v.push_back({c, b});
    }
    sort(v.begin(), v.end());
    while(N > 0) {
        l_l now = v.back();
        v.pop_back();
        ll num = min(now.second, N);
        cerr << now.first << " " << now.second << endl;
        ans += num * now.first;
        N -= num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int L[][];
	static char X[];
	static char Y[];
	//Halla la longitd de la subsecuencia comun más larga
	static int max(int a, int b) {
		return Math.max(a, b);
	}
	static int lcs1(String s1, String s2) {
		X = s1.toCharArray();
		Y = s2.toCharArray();
		int m = X.length, n = Y.length;
		L = new int[m+1][n+1];
		
		/*
		 * Se llena la matriz L. L[i][j] = lcs(X[0...i-1],Y[0...j-1])
		 */
		for(int i=0; i<=m; i++) {
			for(int j =0; j<=n; j++) {
				if(j==0 || i==0) {
					L[i][j] = 0;
				}
				else if (X[i-1]==Y[j-1]) {
					L[i][j] = L[i-1][j-1]+1;
				}
				else {
					L[i][j] = max(L[i-1][j],L[i][j-1]);
				}
			}
		}
		return L[m][n];
	}
	//Reconstruye la subsecuencia comun más larga
	static String lcs2(String s1, String s2) {
		int index = lcs1(s1,s2);
		//System.out.println(index);
		char [] rta = new char[index];
		int i =X.length,  j = Y.length;
		while(i>0 && j>0 && index>0) {
			if(X[i-1]==Y[j-1]) {
				
				rta[index-1] = X[i-1];
				i--; j--; index--;
			}
			else if(L[i-1][j]>L[i][j-1]) {
				i--;
			}
			else {
				j--;
			}
		}
		return new String(rta);
		
	}
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s1 = bf.readLine();
		String s2 = bf.readLine();
		String lcs = lcs2(s1,s2);
		System.out.println(lcs);
	}
}


Measured memory_bytes: 80084
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

double dist(double a, double b){
    return sqrt(a * a + b * b);
}
void solve(){
    int n;
    string s;
    cin >> n >> s;
    int reds = 0, whites = 0;
    int ans = 0, a2 = 0;
    for(auto c : s){
        reds += (c=='R');
    }
    whites = n - reds;
    for(int i = 0; i < reds; ++i){
        ans += (s[i] == 'W');
    }
    for(int i = n - 1; i >= n - 1 - whites + 1; --i){
        a2 += (s[i] == 'R');
    }
    cout << min(ans, a2) << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

int main() {
  int n;
  cin >> n;
  vector<int> X(n),Y(n),H(n);
  int i,hmax=0;
  for(i=0; i<n; i++){
    cin >> X[i] >> Y[i] >> H[i];
    hmax=max(hmax,H[i]);
  }
  
  int x=0,y=0,h=0,k=0;
  for(x=0; x<101; x++){
    for(y=0; y<101; y++){
      for(h=hmax; h<hmax+203; h++){
        int j=0;
        for(i=0; i<n; i++){
          if(max(0,h-abs(X[i]-x)-abs(Y[i]-y)) == H[i]){
            j++;
          }
        }
        if(j==n){
          k++; break;
        }
      }
      if(k!=0)break;
    }
    if(k!=0)break;
  }
  cout << x << ' ' << y << ' ' << h;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 15;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int ga[N][N];
int n,m;
int f[1<<N];
int g[N][1<<N];
int a[N],b[N];
int rep[1<<N];

int val[1<<N][N];

int main(){
   memset(ga,0,sizeof ga);
   scanf("%d%d",&n,&m);
   fr(i,1,m){
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      --a; --b;
      ga[a][b] = ga[b][a] = c;
   }

   fr(i,0,(1<<n)-1){
      int ctv = 0;
      fr(j,0,n-1){
         fr(k,j+1,n-1){
            if(((i >> j)&1) && ((i >> k)&1))ctv += ga[j][k];
         }
      }

      fr(j,0,n-1){
         if((i >> j)&1)continue ;
         int sme = 0;
         fr(k,0,n-1){
            if((i >> k)&1)sme += ga[j][k];
         }
         val[i][j] = sme+ctv;
      }
   }

   int ans = 0;

   fr(i,0,(1<<(n-2))-1){
      int ct = 0;
      int ctl = 0;
      fr(j,1,n-2)if((i >> (j-1))&1)a[ct++] = j;
      fr(j,0,ct-1)memset(g[j],0,1<<(ct+2));

      fr(j,0,ct-1){
         g[j][1<<j] = ga[0][a[j]];
      }

      fr(j,1,(1<<ct)-2){
         fr(k,0,ct-1){
            if(!((j >> k)&1))continue ;
            fr(z,0,ct-1){
               if((j >> z)&1)continue ;
               if(ga[a[k]][a[z]] == 0)continue ;
               g[z][j|(1<<z)] = max(g[z][j|(1<<z)],g[k][j]+ga[a[k]][a[z]]);
            }
         }
      }

      fr(j,1,n-2){
         if((i >> (j-1))&1)continue ;
         b[ctl++] = j;
      }

      fr(j,0,(1<<ctl)-1){
         int msk = 0;
         fr(k,0,ctl-1){
            msk |= ((j >> k)&1)<<b[k];
         }
         rep[j] = msk;
         f[j] = val[rep[j]][0];
      }

      fr(j,0,ct-1){
         nfr(k,(1<<ctl)-1,0){
            int z = k;
            for(;z;z = (z-1)&k){
               f[k] = max(f[k],f[k^z]+val[rep[z]][a[j]]);
            }
         }
      }
      nfr(k,(1<<ctl)-1,0){
         int z = k;
         for(;z;z = (z-1)&k){
            f[k] = max(f[k],f[k^z]+val[rep[z]][n-1]);
         }
      }

      int cur = 0;
      if(i == 0){
         if(ga[0][n-1] == 0)continue ;
         cur = f[(1<<ctl)-1]+ga[0][n-1];
      }
      fr(j,0,ct-1){
         if(ga[a[j]][n-1] == 0 || g[j][(1<<ct)-1] == 0)continue ;
         cur = max(cur,f[(1<<ctl)-1]+g[j][(1<<ct)-1]+ga[a[j]][n-1]);
      }
      ans = max(cur,ans);
   }
   
   int sum = 0;
   fr(i,0,n-1)
      fr(j,i+1,n-1){
         sum += ga[i][j];
      }

   printf("%d\n",sum-ans);
   return 0;
}
/*
15 22
8 13 33418
14 15 55849
7 10 15207
4 6 64328
6 9 86902
15 7 46978
8 14 53526
1 2 8720
14 12 37748
8 3 61543
6 5 32425
4 11 20932
3 12 55123
8 2 45333
9 12 77796
3 9 71922
12 15 70793
2 4 25485
11 6 1436
2 7 81563
7 11 97843
3 1 40491
*/


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	string o, e;
	cin >> o >> e;
	string pass = "";
	
		rep(i, e.size()) {
			pass += o[i];
			pass += e[i];
		}
	
	if (o.size() > e.size()) pass += o.back();
	cout << pass << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> sw(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >>s ;
            s--;
            sw[i].push_back(s);
        }
    }
    vector<int> P(M);
    rep(i, M) cin >> P[i];
    ll ans = 0;
    rep(i, 1 << N) {
        int cnt = 0;
        rep(j, M) {
            int tmp = 0;
            rep(k, sw[j].size()) {
                if ((i & (1 << sw[j][k]))) {
                    tmp ++;
                }
            }
            if (tmp % 2 == P[j]) cnt++;
        }
        if (cnt == M) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int main() {
    int N;

    vector<int> arr;
    vector<int> ordered;
    cin >> N;

    for (int i { 0 }; i < N; ++i) {
        int tmp;
        cin >> tmp;
        arr.push_back(tmp);
        ordered.push_back(tmp);
    }

    sort(ordered.begin(), ordered.end(), std::greater<int>());
    int top = ordered.at(0);
    int second = ordered.at(1);

    for (int a : arr) {
        if (a == top) {
            cout << second << endl;
        } else {
            cout << top << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int R,G,B,K;
  cin>>R>>G>>B>>K;
  int i = 0;
  while(G <= R)
  {
    G *= 2;
    i++;
  }
  while(B <= G)
  {
    B *= 2;
    i++;
  }
  if(i <= K)
    cout<<"Yes"<<"\n";
  else
    cout<<"No"<<"\n";
}

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

int64_t sheets[50] {1};
int64_t patties[50] {1};

int64_t f(int64_t n, int64_t x)
{
  return x <= 0 ? 0 : n <= 0 ? 1 :
    x <= sheets[n - 1] + 1 ?
    f(n - 1, x - 1) :
    patties[n - 1] + 1 + f(n - 1, x - 2 - sheets[n - 1]);
}

int main()
{
  int64_t n, x;
  cin >> n >> x;
  for (auto i = 1; i < n; i++) {
    sheets[i] = sheets[i - 1] * 2 + 3;
    patties[i] = patties[i - 1] * 2 + 1;
  }
  cout << f(n, x) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
  vector<vector<bool>>d(5001,vector<bool>(5001));
int main(){
  ll a,b,x,c,y;cin>>a>>b>>c>>x>>y;
  ll ans=0,z=x;
  if(a+b>c*2)ans+=min(x,y)*c*2;
  else ans+=min(x,y)*(a+b);
  x=max((ll)0,x-y);
  y=max(y-z,(ll)0);
  if(y==0){
    if(a>c*2)ans+=x*2*c;
    else ans+=x*a;
  }
  else
  {
    if(b>c*2)ans+=y*2*c;
    else ans+=y*b;
  }
  cout<<ans;
}



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

AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b))

fights = AB[:]

fights = sorted(fights, reverse=True)

import bisect


bridges = []
for a,b in fights:
    a_position = bisect.bisect(bridges, a)
    b_position = bisect.bisect(bridges, b)
    
    if a_position == b_position:
        bisect.insort(bridges, a+1)
        #print(bridges)

print(len(bridges))


Measured memory_bytes: 18568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

struct UnionFind {
  struct Node {
    ll parent;
    ll size;
  };
  vector<Node> tree;

  UnionFind(ll size) : tree(size) {
    for (ll i = 0; i < size; i++) {
      tree[i].parent = i;
      tree[i].size = 1;
    }
  }

  ll find(ll x) {
    if (tree[x].parent == x) {
      return x;
    } else {
      return tree[x].parent = find(tree[x].parent);
    }
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (tree[x].size < tree[y].size)
      swap(x, y);

    tree[y].parent = x;
    tree[x].size += tree[y].size;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};

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

  ll n, m;
  cin >> n >> m;
  vl a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  reverse(all(a));
  reverse(all(b));

  UnionFind uf(n);
  ll ans = n*(n-1)/2;
  vl vec;
  rep(i, m) {
    vec.push_back(ans);
    if (!uf.same(a[i], b[i])) {
      ll x = uf.find(a[i]);
      ll y = uf.find(b[i]);
      ans -= uf.tree[x].size * uf.tree[y].size;
    }
    uf.unite(a[i], b[i]);
  }

  reverse(all(vec));
  for (auto&& i : vec) {
    cout << i << endl;
  }
}


Measured memory_bytes: 5364
program main
	implicit none
    integer::a,lenn
    character(10)::s
    read(*,*)a
    read(*,*)s
    lenn=len_trim(s)
    if(a>=3200)then
    	write(*,*) s(1:lenn)
    else
    	write(*,*) 'red'
    end if
    stop
end program main



Measured memory_bytes: 2828
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DPeopleOnALine {
public:
	void solve(std::istream& in, std::ostream& out) {
        struct node {
            int to, cost;
            node(int to, int cost): to(to),cost(cost){}
        };
        int n, m, l, r, d;
        vector<node> v[100010];
        in >> n >> m;
        rep(i, m){
            in >> l >> r >> d;
            v[l].push_back(node(r, d));
            v[r].push_back(node(l, -d));
        }

        vector<ll> dist(n+1, inf);
        vector<int> visit(n+1, 0);

        function<bool(int)> dfs = [&](int u){
            visit[u] = 1;
            for(auto const& e : v[u]){
                if(dist[u] != inf && dist[e.to] != inf){
                    if(dist[u] + e.cost != dist[e.to]) return false;
                }else if(dist[u] != inf) dist[e.to] = dist[u] + e.cost;
                else if(dist[e.to] != inf) dist[u] = dist[e.to] - e.cost;

                if(visit[e.to]) continue;
                bool res = dfs(e.to);
                if(!res) return false;
            }
            return true;
        };

        bool res = true;
        reps(i, 1, n){
            if(visit[i]) continue;
            dist[i] = 0;
            res = dfs(i);
            if(!res) break;
        }

        if(res) out << "Yes" << endl;
        else out << "No" << endl;
	}
};


int main() {
	DPeopleOnALine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14592
#A
S = input()
T = input()
Slist = list(S)
Tlist = list(T)
count = 0
for k in range (len(Slist)):
    if Slist[k] == Tlist[k]:
        count += 1
if count == len(Slist):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9120
import copy

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

min_w_per_v = [10**11] * (10**5+3)
min_w_per_v[0] = 0

for i in range(N):
    w, v = wv[i]
    tmp = copy.deepcopy(min_w_per_v)
    for j in range(v, len(min_w_per_v)):
        min_w_per_v[j] = min(tmp[j], tmp[j-v]+w)
        
for n, i in enumerate(min_w_per_v[::-1]):
    if i <= W:
        print(10**5+3-n-1)
        break

Measured memory_bytes: 202292
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    // スペース区切りの整数の入力
	int a;
	int i;
	double dsum=0;

	for (i=0; i<N; i++) {
    	cin >> a ;
		dsum += 1/((double)a);
	}

    // 出力
	printf("%lg\n", 1/dsum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>
 
using namespace std;
 
const int len = 100010;
const long long maxn = 1e9;
int n,a,b,s[len];
 
 bool pd(long long k) {
    long long sum = 0;
    long long ssum;
    long long t = a-b;
    for (int i=1;i<=n;i++) {
        ssum = 1LL*s[i]-1LL*b*k;
        //cout << ssum << endl;
        if (ssum > 0) {
            sum += (ssum%t==0) ? (ssum/t) : (ssum/t+1);
        }
    }
    //cout << "sum=" << sum << endl;
    return sum <= k;
}
 
long long ans(long long l,long long r) {
    long long mid;
    long long aans;
    while (l<=r) {
        mid = (l+r)/2;
        //cout << f1 << f2 << endl;
        if (pd(mid)) aans=mid,r=mid-1;
          else l=mid+1;
    }
    return aans;
}
 
int main() {
    //freopen("test.in","r",stdin);
    scanf("%d%d%d",&n,&a,&b);
    for (int i=1;i<=n;i++) {
        scanf("%d",&s[i]);
    }
    //int i = 2;
    //long long j = i - i*maxn;
    //cout << j << endl;
    printf("%lld",ans(1,maxn));
    return 0;
}

Measured memory_bytes: 640
#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 A, B;
    cin >> A >> B;

    char b = '#', w = '.';
    vector<vector<char>> res(100, vector<char>(100));
    rep(i, 50) rep(j, 100) res[i][j] = b;
    for(int i=50; i<100; i++) rep(j, 100) res[i][j] = w;
    A--; B--;
    int lw = 0, lb = 51;
    while(A>0 || B>0) {
        int t = 0;
        while(t < 100) {
            if(A>0) res[lw][t] = w;
            if(B>0) res[lb][t] = b;
            t += 2;
            A--; B--;
            if(A<=0 && B<=0) break;
        }
        lw+=2;
        lb+=2;
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100) {
        rep(j, 100) {
            cout << res[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  	int A, B, res = 0;
  	cin >> A >> B;
  	if(A >= B){
    	res += A;
      	A--;
    }else{
    	res += B;
      	B--;
    }
  
  	if(A >= B){
    	res += A;
      	A--;
    }else{
    	res += B;
      	B--;
    }
  
  	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
class RMaxQ:
    
    __slots__ = ["n", "data"]
    
    def __init__(self, li):
        self.n = len(li)
        self.data = li*2
        for i in range(self.n - 1, 0, -1):
            self.data[i] = max(self.data[2*i], self.data[2*i+1])
    
    def update(self, i, a):
        i += self.n
        self.data[i] = a
        while i > 1:
            i //= 2
            self.data[i] = max(self.data[2*i], self.data[2*i+1])
    
    def add(self, i, a):
        i += self.n
        self.data[i] += a
        while i > 1:
            i //= 2
            self.data[i] = max(self.data[2*i], self.data[2*i+1])
    
    def fold(self, l, r):
        l += self.n
        r += self.n
        res = 0
        while l < r:
            if l % 2:
                res = max(self.data[l], res)
                l += 1
            if r % 2:
                r -= 1
                res = max(res, self.data[r])
            l //= 2
            r //= 2
        return res

import sys
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
A = list(map(int, input().split()))
seg = RMaxQ(A)
for _ in range(q):
    t, x, v = map(int, input().split())
    x -= 1
    if t == 1:
        seg.update(x, v)
    elif t == 2:
        print(seg.fold(x, v))
    else:
        ng = x
        ok = n+1
        while ok - ng > 1:
            mid = (ok+ng)//2
            if seg.fold(x, mid) >= v:
                ok = mid
            else:
                ng = mid
        print(ok)

Measured memory_bytes: 95796
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
	int k;
	cin>>k;
	while(k--){
		cout<<"ACL";
	}
	cout<<endl;

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
// abc150_c
#include <iostream>
#include <math.h>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

UL facctorialMethod(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(int argc, char const *argv[])
{
    US n;
    UL a = 0, b = 0;
    cin >> n;
    vector<US> tmpa, tmpb;
    for (US i = 0; i < n; i++)
    {
        tmpa.push_back(i + 1);
        tmpb.push_back(i + 1);
    }

    for (US i = 0; i < n; i++)
    {
        US t;
        cin >> t;
        auto itr = find(tmpa.begin(), tmpa.end(), t);
        a += facctorialMethod(n - i - 1) * distance(tmpa.begin(), itr);
        tmpa.erase(itr);
    }
    for (US i = 0; i < n; i++)
    {
        US t;
        cin >> t;
        auto itr = find(tmpb.begin(), tmpb.end(), t);
        b += facctorialMethod(n - i - 1) * distance(tmpb.begin(), itr);
        tmpb.erase(itr);
    }
    cout << labs(a - b) << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
ll n,a,b;
cin>>n>>a>>b;

ll cnt = b - a;
if(cnt % 2 == 0){
   cout<<cnt / 2<<endl;
}else
{
   cout<<min(a-1,n-b) + 1 + (cnt - 1) / 2<<endl;
}


   return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <string>

using namespace std;

constexpr int SURFACE_NUM = 6;
enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};

class Dice {
private:
    array<int, SURFACE_NUM> m_surface;

public:
    // constructor
    Dice(array<int, SURFACE_NUM> surface)
        : m_surface(surface) {}

    // getter
    int surface(int i) const
    {
        return m_surface.at(i);
    }

    // roll
    void roll(char direction)
    {
        switch (direction) {
        case 'N':
            roll(TOP, FRONT, BOTTOM, BACK);
            break;
        case 'S':
            roll(TOP, BACK, BOTTOM, FRONT);
            break;
        case 'E':
            roll(TOP, LEFT, BOTTOM, RIGHT);
            break;
        case 'W':
            roll(TOP, RIGHT, BOTTOM, LEFT);
            break;
        }
    }

    void roll(int i, int j, int k, int l)
    {
        int tmp = m_surface.at(i);
        m_surface.at(i) = m_surface.at(j);
        m_surface.at(j) = m_surface.at(k);
        m_surface.at(k) = m_surface.at(l);
        m_surface.at(l) = tmp;
    }

    // debug
    void printDice() const
    {
        cout << surface(TOP) << surface(FRONT)
             << surface(RIGHT) << surface(LEFT)
             << surface(BACK) << surface(BOTTOM) << endl;
    }
};

int main()
{
    array <int, SURFACE_NUM> init;
    for (auto i = 0; i < SURFACE_NUM; i++) {
        cin >> init.at(i);
    }
    Dice one(init);

    string op;
    cin >> op;
    for (auto i = 0; i < op.size(); i++) {
        char direction = op.at(i);
        one.roll(direction);
    }

    cout << one.surface(TOP) << endl;;
}

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

int main()
{
	ll N, M;
	cin >> N >> M;

	priority_queue<ll> pq;
	rep(i, N) {
		ll A;
		cin >> A;
		pq.push(A);
	}
	rep(i, M) {
		ll now = pq.top(); pq.pop();
		now /= 2;
		pq.push(now);
	}

	ll res = 0;
	while (!pq.empty()) {
		res += pq.top(); pq.pop();
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1400
N = int(input())
V = list(map(int,(input().split())))
C = list(map(int,(input().split())))

X = [0]*N
for i in range(N):
    X[i] = V[i] - C[i]

ans = 0
for i in range(N):
    if X[i] > 0:
        ans += X[i]

print(ans)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
		int D;
	cin >> D;
	vec(C);
	fx(26) {
		vecp(C);
	}
	fx(D) {
		int maxi = 0, index = 0;
		fy(26) {
			cin >> table[x][y];
			if (maxi < table[x][y]) {
				maxi = table[x][y];
				index = y;
			}
			
		}
		ce(index+1)
	}
    return 0;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<deque>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (300000)


int n, m;
vector<int>e[N];
long long d[N];
bool used[N];
bool us[N];
int a[N];
int b[N];
char c[N+1];

void init(void){
	memset(used, 0, sizeof(used));
	memset(us, true, sizeof(us));
	f(i, N)a[i] = 0;
	f(i, N)b[i] = 0;
	return;
}

void dele(int k){
	us[k] = false; 
	if (c[k] == 'A'){
		f(i, e[k].size()){
			a[e[k][i]]--;
			if (a[e[k][i]] <= 0){
				if(us[e[k][i]])dele(e[k][i]);
			}
		}
	}
	else{
		f(i, e[k].size()){
			b[e[k][i]]--;
			if (b[e[k][i]] <= 0){
				if (us[e[k][i]])dele(e[k][i]);
			}
		}
	}
	return;
}

void dfs(int k){
	used[k] = true;
	f(i, e[k].size()){
		if (!used[e[k][i]]){
			dfs(e[k][i]);
		}
		if (c[e[k][i]] == 'A')a[k]++;
		else b[k]++;
	}
	return;
}
void dfs2(int k){
	used[k] = true;
	if (a[k] == 0 || b[k] == 0){
		if (us[k])dele(k);
	}
	return;
}


int main(void){
	int x, y;
	scanf("%d %d", &n, &m);
	scanf("%s", c);
	init();
	f(i, m){
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	f(i, n){
		if (!used[i])dfs(i);
	}
	memset(used, 0, sizeof(used));
	f(i, n){
		if (!used[i])dfs2(i);
	}
	bool v = false;
	f(i, n){
		if (us[i])v = true;
	}

	if(v)printf("Yes\n");
	else printf("No\n");

	return 0;
}


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

typedef complex<double> P;

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

vector<P> ps(3);
P p;

bool isIn() {
  for(int i = 0; i < ps.size(); ++i) {
    P q = ps[i];
    P r = ps[(i+1)%ps.size()];
    if(cross(r-q, p-q) < 0.0) return false;
  }
  return true;
}

int main() {
  while(cin >> ps[0].real() >> ps[0].imag()) {
    for(int i = 1; i < ps.size(); ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    cin >> p.real() >> p.imag();
    bool flag = false;
    if(isIn() || ( swap(ps[0], ps[1]), isIn() )) {
      cout << "YES" << endl;    
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef pair<int,int> pint;
typedef pair<tint,tint> ptint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele(a*a, b/2);
	}else{
		return a*ele(a*a, b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

void solve(){
	tint H,W,h,w;
	cin>>H>>W>>h>>w;
	tint tab[H+2][W+2];
	tint casi=h*w;
	tint INF=1e8;
	tint grande = INF/h;
	tint su=0;
	if( (H%h)==0 && (W%w)==0 ){
		cout<<"No"<<endl;
		return;
	}
	forn(i, H){
		forn(j, W){
			tab[i][j]=0;
		}
	}
	if(w>1){
		forn(i, h){
			tab[i][0]=grande;
			su+=grande;
		}
		tab[h-1][w-1]=-INF-1;
		for(int i=h-1; i>=0; i--){
			for(int j=w-1; j>=0; j--){
				if(j!=0 && (i!=h-1 || j!=w-1)){
					tab[i][j]=INF-su;
					su+=tab[i][j];
				}
			}
		}
	}else{
		forn(i, h-1){
			tab[i][0]=(INF/(h-1));
			su+=(INF/(h-1));
		}
		tab[h-1][w-1]=-INF-1;
		for(int i=h-1; i>=0; i--){
			for(int j=w-1; j>=0; j--){
				if(j!=0 && (i!=h-1 || j!=w-1)){
					tab[i][j]=INF-su;
					su+=tab[i][j];
				}
			}
		}
	}
	forn(i, H){
		forn(j, W){
			if(i>=h){
				tab[i][j]=tab[i-h][j];
				//cout<<"seteo "<<i<<"  "<<j<<endl;
			}else if(j>=w){
				tab[i][j]=tab[i][j-w];
				//cout<<"seteo col "<<i<<"  "<<j<<endl;
			}
		}
	}
	su=0;
	forn(i, H){
		forn(j, W){
			su+=tab[i][j];
		}
	}
	if(su>0){
		cout<<"Yes"<<endl;
		forn(i, H){
			forn(j, W){
				cout<<tab[i][j]<<" ";
			}
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
			
				
			
}




int main (){
	int T;
	T=1;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 4736