akhauriyash/Code-Regression huggingface dataset:
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    string ans;
    if(A*B % 2 == 0){
        ans = "No";
    }else{
        ans = "Yes";
    }

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

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = [int(input().rstrip('\n')) for _ in range(n)]
    d.sort(reverse=True)
    l = 10 ** 10
    cnt = 0
    for i in range(n):
        if d[i] < l:
            cnt += 1
            l = d[i]
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define ll long long
#define endl \'n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;

int a[51];
ll dp[51][2601];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, b; dp[0][0] = 1;
    cin >> n >> b; ll ans=0;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=n; i++)
    {
        for(int j=i; j>=1; j--)
        {
            for(int k=a[i]; k<=2500; k++) dp[j][k] += dp[j-1][k-a[i]];
        }
    }
    for(int i=1; i<=n; i++)
        ans += dp[i][i*b];
    cout << ans;
}

//TODO: 44


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int a;
	vector<int>inp;
	cin>>a;
	int all;
	cin>>all;
	int b;
	for(int i=0;i<a;i++)
	{
		cin>>b;
		inp.push_back(b);
	}
	sort(inp.begin(),inp.end());
	int use=0;
	for(int i=0;i<a;i++)
	{
		use+=inp[i];
	}
	all-=use;
	int ans=(all/inp[0]);
	ans+=a;
	cout<<ans;
	return 0;
 } 

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

using namespace std;
using ll = long long;

const int mx = 200000+9;

int n, m;
ll k;
ll a[mx], b[mx];

int main() {
    scanf("%d %d %lld", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]); //i tomo boi porte ki time lage
        a[i] += a[i - 1]; // a[i] = i tomo boi porjnto porte total time
    }

    for (int i = 1; i <= m; i++) {
        scanf("%lld", &b[i]);
        b[i] += b[i - 1]; //same as a[i], b stack er jonne
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (k < a[i]) break;
        int temp = i; //dhori a stack theke i ta boi porbe
        ll remaining_time = k - a[i]; //porar por baki time koto thake
        auto it = upper_bound(b + 1, b + m + 1, remaining_time); //b te baki time e koyta porte parbe
        temp += (it - (b + 1));
        ans = max(ans, temp);
    }

    //same vabe b theke age koto gula pori, a theke baki time e joto gula pora jay rki
    for (int i = 1; i <= m; i++) {
        if (k < b[i]) break;
        int temp = i;
        ll remaining_time = k - b[i];
        auto it = upper_bound(a + 1, a + n + 1, remaining_time);
        temp += (it - (a + 1));
        ans = max(ans, temp);
    }

    printf("%d\n", ans);
}


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

string s,t;
void input(){
    cin>>s>>t;
}

void src(){
    cout<<t+s;
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i=1; i<=n; i++){
        int m = i, sum = 0;
        while(m > 0){
            sum += m%10;
            m /= 10;
        }
        if(a <= sum && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int INF = 1<<20;
int n;
vector<pair<int, int> > adj[10000];
void dijkstra(){
	priority_queue<pair <int, int> > PQ;
	int color[10000];
	int d[10000];
	for(int i=0; i<n; i++){
		d[i]=INF;
		color[i]=0;
	}
	d[0]=0;
	PQ.push(make_pair(0, 0));
	color[0]=1;
	while(!PQ.empty()){
		pair<int, int> f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[u]=2;
		if(d[u]<f.first*(-1))
			continue;
		for(int j=0; j<adj[u].size(); j++){
			int v=adj[u][j].first;
			if(color[v]==2)
				continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(make_pair(d[v]*(-1), v));
				color[v]=1;
			}
		}
	}
	for(int i=0; i<n; i++)
		cout<<i<<" "<<(d[i]==INF ? -1 : d[i])<<endl;
}
int main(){
	int k,u,v,c;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>u>>k;
		for(int j=0; j<k; j++){
			cin>>v>>c;
			adj[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}


Measured memory_bytes: 8056
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    ll n,t;cin>>n>>t;
    ll dp[100000]={};
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll a,b;cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    // 時間がかからないやつから考えるのが最適
    sort(ALL(v));
    ll ans=0;
    rep(i,n){
        ll time=v[i].first,deli=v[i].second;
        for(int j=t;j>=0;j--){
            if(j==0||dp[j]>0){
                if(time+j>t&&j!=t) chmax(ans,dp[j]+deli);
                else chmax(dp[time+j],dp[j]+deli);
            }
        }
    }
    rep(i,t+1) chmax(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
import math 
import sys 
#t=int(sys.stdin.readline())
t=1
for _ in range(t):
    n,m=map(int,input().split())
    l=list(map(int,input().split()))
    l.sort()
    x=0
    for i in range(n-m):
        x+=l[i]
    print(x)    
        

Measured memory_bytes: 87372
#include <iostream>
using namespace std;
int main(void){
    int S, h, m, s; 
    cin >> S; 
    h=S / 3600; 
    m=(S-3600*h) / 60; 
    s=S % 60; 
    cout << h <<":" << m << ":" <<s << endl; 
    return 0;
}



Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            Console.WriteLine(N*N-A);
        }
    }
}


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

string get_balance(int L, int R) {
    if (L > R) {
        return string("Left");
    } else if (L == R) {
        return string("Balanced");
    } else if (L < R) {
        return string("Right");
    } else {
        throw exception();
    }
}

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;
    cout << get_balance(A + B, C + D) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '?'){
      break;
    }
    if (op == '+'){
      cout << a + b << endl;
    }
    if (op == '-'){
      cout << a - b << endl;
    }
    if (op == '*'){
      cout << a * b << endl;
    }
    if (op == '/'){
      cout << a / b << endl;
    }
  }
}


Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

int h, w;
void solve() {
	cin >> h >> w;
	vector<vector<int>> v(h);
	rep(i, h) {
		rep(j, w) {
			char t; cin >> t;
			if (t == 'B') {
				v[i].push_back(j);
			}
		}
		if (v[i].size() > 2) {
			v[i] = vector<int>{ v[i][0],v[i].back() };
		}
	}
	int ans = 0;
	rep(i, h) {
		Rep(j, i, h) {
			rep(k, v[i].size()) {
				rep(l, v[j].size()) {
					int dist = j - i + abs(v[i][k] - v[j][l]);
					ans = max(ans, dist);
				}
			}
		}
	}
	cout << ans << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}





Measured memory_bytes: 3212
#include<cstdio>
using namespace std;
typedef long long ll;
ll i,j,k,n,ans,A,B,ch,ff;
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
ll Js(ll A,ll B,int k) {
	if (A<=1 && B>=(1ll<<k)-1) return B-A+1;
	if ((A&1ll<<k)==(B&1ll<<k)) return Js(A&((1<<k)-1),B&((1<<k)-1),k-1);
	
}
int main() {
	R(A);R(B);
	if (A==B) return puts("1"),0;
	n=60;
	while ((A&1ll<<n)==(B&1ll<<n)) n--;
	if (!n) return puts("2"),0;
	ans=(1ll<<n)-(A&((1ll<<n)-1));
	for (i=n-1;i>=0;i--) {
		if (B&1ll<<i) {
			ans+=1ll<<(i+1);
			break;
		}
		else {
			if (A&1ll<<i) {
				ans+=(1ll<<i)-(A&((1ll<<i)-1));
				for (j=i-1;j>=0;j--) if (B&1ll<<j) {
					ans+=1ll<<(j+1);
					break;
				}
				if (j<0) ans++;
				break;
			}
			ans+=(1ll<<i);
		}
	}
	W(ans);puts("");
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int num = accumulate(all(A),0);
    vector<int> B;
    for (int i = 1; i*i <= num; i++) {
        if (num % i == 0) {
            B.emplace_back(i);
            B.emplace_back(num/i);
        }
    }
    sort(all(B));

    int ans = 0;
    vector<int> C(N);
    for (auto x : B) {
        rep(i,N) C[i] = A[i] % x;
        sort(all(C));
        reverse(all(C));
        int sum = accumulate(all(C),0);
        int k = sum/x;
        ll cnt = 0; 
        rep(i,k) cnt += x - C[i];
        if (cnt <= K) ans = x;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
void Solve()
{
    char S[50];
    int N,i,count=0;
    scanf("%d",&N);
    scanf("%s",&S);
    for(i=0;i<N-2;i++)
    {
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
        {
            count++;
        }
    }
    printf("%d\n",count);
}

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


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#define re(i,a,b) for(int i=a;i<=b;i++)
#define _re(i,a,b) for(int i=a;i>=b;i--)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
#define ll long long
#define maxn 200005
#define inf 1e9
using namespace std;
inline int read(){char c = getchar();int ans = 0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){ans = ans*10 + c - '0';c = getchar();}return f*ans;}
//____________________________________________________________________________________________________________________________________________________________________
int a[maxn],sum[maxn],cnt[maxn],n,m;
int main()
{
	n = read();m = read();
	re(i,1,n)
		cnt[ a[i] = read() ]++;
	int ans = 0;
	re(i,1,n)
	{
		sum[ max(i-cnt[i]+1,1) ]++;
		sum[i+1]--;
	}
	re(i,1,n)
	{
		sum[i] += sum[i-1];
		if(sum[i]) ans++;
	}
	re(i,1,m)
	{
		int pos = read() , x = a[pos] , y=read();
		a[pos] = y;
		if(x-cnt[x]+1>0)
		{
			sum[x-cnt[x]+1]--;
			if( !sum[x-cnt[x]+1] ) ans--;
		}
		cnt[x]--;
		
		cnt[y]++;
		if(y-cnt[y]+1>0)
		{
			if(!sum[y-cnt[y]+1]) ans++;
			sum[y-cnt[y]+1]++;
		}
		//re(i,1,n)printf("%d ",sum[i]);putchar('\n');
		printf("%d\n",n-ans);
	}
	
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    for (int i = 0; i < s.size(); i++)
    {
        const int iter = ('z' - s[i] + 1) % 26;
        if (iter <= k)
        {
            k -= iter;
            s[i] = 'a';
        }
    }
    k %= 26;
    s.back() = static_cast<char>((s.back() - 'a' + k) % 26 + 'a');

    cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * 26; 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * 26;
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <iostream>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 1350851717672992089
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define vi vector<ll>
#define vp vector<pair<ll, ll>>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define F first
#define S second
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++)
        cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for (int i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),
        dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, M;
  cin >> N >> M;
  int a[M];
  int b[M];
  int f[M]{};
  int t = 0;
  int flag[N]{};
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      cin >> t;
      t--;
      flag[t] = 1;
      f[i] += (1<<t);
    }
  }
  // 全ての宝箱を開けることができるかをチェック
  for (int i = 0; i < N; i++) {
    if (flag[i] == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  int l = (1<<N);
  int dp[l];
  int inf = 100000000;
  fill(dp, dp + l, inf);
  dp[0] = 0;

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      int t = (1<<j);
      // 鍵束iに宝箱jが含まれるかどうか
      //if ((f[i] & t) == 0) continue;
      for (int k = 0; k < l; k++) {
        int idx = k | f[i];
        dp[idx] = min(dp[idx], dp[k] + a[i]);
      }
    }
  }
  cout << dp[l - 1] << "\n";
  return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // int k=1;
    // while(t--){
    //     int n;cin>>n;
        
    // }
    int k;cin>>k;
    vi a;
    queue<int> q;
    for(int i=1;i<10;i++)q.push(i);
    while(!q.empty()){
        int n=q.front();
        q.pop();
        a.pb(n);
        int d=n%10;
        if(n*10<3234566667){
            if(d!=0){
                q.push(n*10+d-1);
            }
            q.push(n*10+d);
            if(d!=9){
                q.push(n*10+d+1);
            }
        }
    }
    sort(a.begin(),a.end());
    cout<<a[k-1]<<endl;    
    return 0;
}




Measured memory_bytes: 1784
def saiki(i,cost,score_list):
    if i == N:
        if min(score_list) >= X:
            ans.append(cost)
    else:
        temp = [score_list[j]+book_lists[i][j+1] for j in range(M)]
        saiki(i+1,cost,score_list)
        saiki(i+1,cost+book_lists[i][0],temp)
 
N,M,X = map(int,input().split())
book_lists = [list(map(int, input().split())) for _ in range(N)]
ans=[]
saiki(0,0,[0]*M)
print(min(ans) if len(ans)!=0 else -1)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k,s;
	cin >> k >> s;
	int count=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-i-j >=0 && s-i-j <= k){
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var c = 0
    val xs = readLine()!!.split(' ').map {
        val x = it.toLong()
        if (x < 0) {
            c++
            -x
        } else {
            x
        }
    }.sortedDescending()

    var ans = xs.sum()

    if (c % 2 == 1) {
        ans -= (xs[n - 1] * 2)
    }

    println(ans)
}

Measured memory_bytes: 74692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, m;
    cin >> n >> m;
    map<int, int> sc;
    rep(i, m){
        int s, c;
        cin >> s >> c;
        s = n - s + 1;
        if (sc.count(s) != 0 && sc[s] != c){
            cout << -1 << endl;
            return 0;
        }
        sc[s] = c;
    }

    if (sc.count(n) == 1 && sc[n] == 0 && n != 1){
        cout << -1 << endl;
        return 0;
    }

    if (m == 0 && n == 1){
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = n; i > 0; i--){
        int val;
        if (sc.count(i) != 0){
            val = sc[i];
        }
        else{
            if (i == n){
                val = 1;
            }else{
                val = 0;
            }
        }
        for(int j = 1; j < i; j++){
            val *= 10;
        }
        ans += val;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
const unsigned long long oo= (1ull<<63)-1;
const int maxn= 1000 + 10;

LL  p[4]; 
LL f[1010];


int main(){


	scanf("%lld%lld%lld%lld",&p[0] , &p[1], &p[2], &p[3]);
	LL N;
	
	scanf("%lld", &N); N *= 4;
	f[0] = 0;
	for (int i=1; i<=1000; i++) f[i] = oo;
	
	for (int i=0; i<4; i++)
		for (int j= 1<<i  ; j<=1000; j++) f[j] = min( f[j], f[j-(1<<i)]+ p[i]);
	LL ans= oo;
	for (int low=0; low <4; low++)
	for (int i=0; i<=1000; i++)
		if ( (N-i)%(1<<low)==0 && N>=i) ans = min(ans, f[i] + (N-i)/(1<<low)* p[low]);
	printf("%lld\n", ans);
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int mizuyari(int l, int r, int *h) {
	if (l > r) return 0;
	if (l == r) return h[l];

	int i, min = 100, count;

	for (i = l; i <= r; i++) {
		if (h[i] < min) min = h[i];
	}

	count = min;

	for (i = l; i <= r; i++) {
		h[i] = h[i] - min;
		if (h[i] == 0) {
			count = count + mizuyari(l, i - 1, h);
			l = i + 1;
		}
	}

	count = count + mizuyari(l, r, h);

	return count;
}

int main() {
	int N, h[100], i, ans;

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

	ans = mizuyari(0, N - 1, h);

	printf("%d", ans);

	return 0;
}

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

int main(){
  int A, B, N;
  int count = 0;
  cin >> N >> A >> B;
  for(int i = 1; i <= N; i++){
    int sum = 0;
    sum += i / 10000;
    sum += (i / 1000) % 10;
    sum += (i / 100) % 10;
    sum += (i / 10) % 10;
    sum += i % 10;
    if(sum >= A && sum <= B) count += i;
  }
  cout << count;
  return 0;
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    while(a>0&&c>0){
        c-=b;
        if(c<=0)break;
        a-=d;
    }

    cout << (a>0?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
int main()
{
	int a,b,p=0,s,i,m;
	double res=0;
	scanf("%d %d",&a,&b);
	s=a;
	m=b;
	while(m>=1)//p为b的位数
	{
		m/=10;
		p++;
	}
	for(i=1;i<=p;i++)
		s*=10;
	s+=b;
	res=int(sqrt(s));
	if(res*res==s)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
N = list(map(int,input()))

count = 0
for i in range(-(-(len(N))//2)):
	if N[2*i] == 1:
		count += 1

for i in range(len(N)//2):
	if N[2*i+1] == 0:
		count += 1

print(min(count,len(N)-count))

Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>

using namespace std;

long long A[300003], X[300003];

int main() {
	int i, j, n, m, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if (a + b > n + 1 || (long long)a * b < n) {
		puts("-1");
		return 0;
	}
	n -= a + b - 1;
	m = 0;
	for (i = 0; i < a; i++) for (j = 0; j < b; j++) {
		if (i == 0 || j == 0 || n) {
			A[m] = X[m] = (long long)i * 1000000 - j;
			m++;
			if (i && j) n--;
		}
		else break;
	}
	sort(X, X + m);
	for (i = 0; i < m; i++) printf("%d ", upper_bound(X, X + m, A[i]) - X);
	return 0;
}


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

int main(void) {
	int N, K;
	cin >> N >> K;
	vector <int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H.begin(), H.end());
	long long  ans = 0;
	for (int i = 0; i < N-K; i++) {
		ans += H[i];
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n = gets(chomp:true).to_i

nums = []
n.times do
  nums << gets(chomp:true).to_i
end

count = 0

nums.each do |num|

  num != 2 && num.even? && next

  if num == 2 
    count += 1
    next 
  end

  flag = true
  (2..Math.sqrt(num).to_i).each do |sqrtnum|
    sqrtnum == 0 && next
    if num % sqrtnum == 0
      flag = false
    end
  end

   flag && count += 1
  
end

puts count


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

int a, b, c, d;

int main()
{
	cin >> a >> b >> c >> d;

	while (a > 0 && c > 0) {
		c -= b;

		if (c <= 0)
			break;
		else
			a -= d;
	}

	if(a > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

int a;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans << '\n';
}





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

#define SZ(v) ((int)(v).size())
using ll = long long;

ll solve(void);

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

	int nb_tests;
	cin >> nb_tests;

	for (int i(0); i < nb_tests; ++i)
		solve();
}

ll N, A, B, C, D;
map<ll, ll> cst;

ll calc(ll cur)
{
	if (!cur) return 0;
	if (cst.count(cur))
		return cst[cur];
	ll ret = 4e18;
	if (cur <= ret/D)
		ret = min(ret, cur * D);
	if (cur%2==0)
		ret = min(ret, calc(cur/2) + A);
	else
	{
		ret = min(ret, calc(cur/2) + A + D);
		if (1 + cur/2 < cur)
			ret = min(ret, calc(cur/2 + 1) + D + A);	
	}

	if (cur%3==0)
		ret = min(ret, calc(cur/3) + B);
	else
	{
		ret = min(ret, calc(cur/3) + B + D * (cur%3));
		if (cur > cur/3 + 1)
			ret = min(ret, calc(cur/3 + 1) + B + D * (3-cur%3));
	}

	if (cur%5==0)
		ret = min(ret, calc(cur/5) + C);
	else
	{
		ret = min(ret, calc(cur/5) + C + D * (cur%5));
		if (cur > cur/5 + 1)
			ret = min(ret, calc(cur/5 + 1) + C + D * (5 - cur%5));
	}
	cst[cur] = ret;
	return ret;
}

ll solve(void)
{
	cin >> N >> A >> B >> C >> D;
	cst.clear();
	cout << calc(N) << endl;	

	return 0;
}



Measured memory_bytes: 4388
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  
  ll s;
  cin >> s;
  ll a;
  a=s/1000000000;
  ll x0, x1, x2, y0, y1, y2;
  x0=0;
  y0=0;
  x2=1000000000;
  y1=a+1;
  ll x1y2;
  x1y2 = y1*x2-s;
  y2=1;
  x1=x1y2;
  if(s==1000000000000000000){
    y1=0;
    y2=1000000000;
  }

  cout<<x0<<' '<<y0<<' '<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char s[11], de[2] = {'h','i'};
int len,flag;

int main() {
	cin >> s;
	len = strlen(s);
	if (len % 2)
		printf("No");
	else {
		for (int i = 0; i < len; ++i) {
			if (s[i] != de[i % 2]) {
				flag = 1;
				break;
			}
		}
		if (flag)
			printf("No");
		if (!flag)
			printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ques = [0] * N
ans = 0
pen = 0
for i in range(M):
    a, b = map(str, input().split())
    if ques[int(a)-1] >= 0 and b == "WA":
        ques[int(a)-1] += 1
    elif ques[int(a)-1] >= 0 and b == "AC":
        ans += 1
        pen += ques[int(a)-1]
        ques[int(a)-1] = -1
        
print(ans, pen)

Measured memory_bytes: 3828
#include "bits/stdc++.h"
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
ll dp[3005][3005][5];
ll r[200006],c[200006],k[200005];
set<P>S[3005];
signed main(){
	ll R,C,K;cin>>R>>C>>K;
	rep(i,K){
		cin>>r[i]>>c[i]>>k[i];
		S[r[i]-1].insert(P(c[i]-1,k[i]));
		if(r[i]==1&&c[i]==1){
			dp[0][0][1]=k[i];
		}
	}
	
	rep(i,R){
		rep(j,C){
			rep(l,4){
				if(i!=R-1){
					dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]);
					auto itr=S[i+1].lower_bound(P(j,-1));
					if(itr!=S[i+1].end()&&itr->first==j){
						dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][l]+itr->second);
					}
				}
				if(j!=C-1){
					dp[i][j+1][l]=max(dp[i][j][l],dp[i][j+1][l]);
					auto itr=S[i].lower_bound(P(j+1,-1));
					if(itr!=S[i].end()&&itr->first==j+1){
						dp[i][j+1][l+1]=max(dp[i][j+1][l+1],dp[i][j][l]+itr->second);
					}
				}
			}
		}
	}
	cout<<max({dp[R-1][C-1][0],dp[R-1][C-1][1],dp[R-1][C-1][2],dp[R-1][C-1][3]})<<endl;
}

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

using namespace std;

const int N = 100005;

int n, m;
int a[N], b[N];
int par[N];
bool vis[N];
long long sum[N], res[N];
vector<int> G[N];

int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); }

void join(int u, int v) { par[find(u)] = find(v); }

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		par[i] = i, sum[i] = b[i], res[i] = max(a[i], b[i]);
	}
	for (int i = 1; i <= m; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v), G[v].push_back(u);
	}
	vector<int> vec;
	for (int i = 1; i <= n; ++i) vec.push_back(i);
	sort(vec.begin(), vec.end(), [&] (int x, int y) {
		return a[x] - b[x] < a[y] - b[y];
	});
	for (auto i : vec) {
		set<int> s;
		for (auto j : G[i]) {
			if (vis[j]) s.insert(find(j));
		}
		for (auto j : s) {
			join(j, i), sum[i] += sum[j];
		}
		if (s.size()) {
			long long mn = 1e18;
			for (auto j : s) {
				mn = min(mn, max(0LL + a[i] - b[i], res[j]) + sum[i] - sum[j]);
			}
			res[i] = mn;
		}
		vis[i] = 1;
	}
	cout << res[find(vec.back())];
}

Measured memory_bytes: 10740
/* kop Chy_Chy*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll , ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define si(x)   scanf("%d", &x)
#define sl(x)   scanf("%lld", &x)
#define pi(x)   printf("%d\n", x)
#define pl(x)   printf("%lld\n", x)
#define deb(x)  cout<< #x << " = " << x << endl // debugging kop 
#define mp      make_pair
#define pb      push_back
#define MOD     1000000007
#define PI      acos(-1)
#define ff      first
#define ss      second
#define newline printf("\n")
ll binpow(ll a, ll b); // binary exponentiation kop
void prime_factorization(ll n, vll &prime_factors); // prime factorization kop
ll gcd(ll a, ll b); // greatest common divisor kop. Use LONG LONG
void speedup() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
void func(string s , string t){
    int a = s.size();
    int b = t.size();
    int m = (int)1e9;
    int cnt = 0;
    for(int i = 0; i <= a-b; i++){
        for(int j = 0; j < b; j++){
            if(s[j+i] != t[j]){
                cnt++;
            }
        }
        // cout<< cnt << "\n";
        m = min(cnt, m);
        cnt = 0;
    }
    cout<< m << "\n";
}
int main(){
    speedup();
    int t = 1;
    // cin>> t;
    while(t--){
        // khela final Mamooo
        int n; cin>> n;
        vll a(n);
        for(int i = 0; i < n; i++) cin>> a[i];
        vll sum(n);
        for(int i = n -2; i >= 0; i--){
            sum[i] = sum[i+1] + a[i+1];
            sum[i] %= MOD;
        }
        ll ans = 0;
        for(int i = 0; i < n-1; i++){
            ans += (sum[i] * a[i]) % MOD;
            ans %= MOD;
            
        }
        cout<< ans << "\n";
        
        
    }
    // kop kop return 
    return 0;
}


// kop kop functions:
ll binpow(ll a, ll b){
    a = a % MOD; ll res = 1;
    while(b > 0){
        if(b & 1) res *= a % MOD;
        a = a* a % MOD;b = b >> 1;}
    return res;
}
/*---------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
/*---------------------------------------------------------------------------------------------------------------*/
void prime_factorization(ll n, vll &prime_factors){
    // first two step taking care of composite number
    // taking care of 2
    while(n%2 == 0){
        prime_factors.pb(2);
        n = n / 2;
    }
    // now n must be odd. And the remaining prime divisors are odd. so we start from 3 and increamenting 2
    for(ll i = 3; i <= sqrt(n); i = i + 2){
        while(n%i == 0){
            prime_factors.pb(i);
            n = n / i;
        }
    }
    // now we are taking care of  n is prime number and greater than 2
    if(n > 2){
        prime_factors.pb(n);
    }
}
/*---------------------------------------------------------------------------------------------------------------*/















Measured memory_bytes: 6376
#include <stdio.h>
#define N 2000
#define Q 2000
#define TRUE 1
#define FALSE -1
int flag, n;
int A[N];

int solve(int i, int m){
  if(i > n) return FALSE;
  else if(m < 0) return FALSE;
  else if(m == 0 || m-A[i+1] == 0){
    flag = TRUE;
    return TRUE;
  }
  else{
    solve( i + 1, m);
    solve( i + 1, m - A[i]);
  }
}

int main(){
  int i, q;
  int  M;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &M);
    flag = FALSE;
    solve(-1, M);
  if(flag == TRUE)printf("yes\n");
  else printf("no\n");
  }
   
  return 0;
}

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

int main() {
   
long long n,k,q,i;
  cin>>n>>k>>q;
  long long b[n+1]={0};
  
  long long a[q];
  for(i=0;i<q;i++)
 { cin>>a[i]; b[a[i]]++;}
  for(i=1;i<=n;i++)
  {
     if((b[i]+k)>q)
     cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
  }
  
	return 0;
}

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

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int n,l,r,ret=0;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++) {
    	cin>>l>>r;
    	ret=ret+(r-l+1);
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 256
from collections import deque
n, q = map(int,raw_input().split())
queue = deque([])
for i in range(n):
    queue.append(map(str,raw_input().split()))

queue = deque(map(lambda x : [x[0],int(x[1])], queue)) 

time = 0

while len(queue) > 0:
    xqt = queue.popleft()
    res_time = xqt[1] - q
    if res_time <= 0:
        time = time + xqt[1]
        print xqt[0], time
    else:
        time = time + q
        xqt[1] = res_time
        queue.append(xqt)

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

int main(){
    string S;
    cin >> S;
    int res=0;
    int S_length=S.length();
    for(int i=0; i<S_length-1;++i){
        if(S[i]==S[i+1]){
            if(S[i]=='0'){
                S[i+1]='1';
                ++res;
            }    
            else{
                S[i+1]='0';
                ++res;
            }
        }                
    }
    cout << res;
}

Measured memory_bytes: 512
N = int(input())
c = list(input())

l = 0
r = N-1
ans=0

while True:
    while c[l] == 'R':
        l += 1
        if l==N:
            break

    while c[r] == 'W':
        r -= 1
        if r==-1:
            break

    if l-r == 1:
        print(ans)
        break
    else:
        c[l] = 'R'
        c[r] = 'W'
        ans += 1


Measured memory_bytes: 10748
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  if (N * 2 < M) {
    // c あまりの時
    ll rest = M - (N * 2);
    ll created = rest / 4;
    cout << (N + created) << endl;
  } else if (N * 2 > M) {
    // s あまりの時 (ばらせない)
    ll ret = M / 2;
    cout << ret << endl;
  } else {
    // 割合ピッタリ
    cout << N << endl;
  }
}

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

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

    int q;
    cin >> q;

    deque<int> dq;
    for(int i = 0; i < q; i++){
        int n;
        cin >> n;
        if(n == 0){
            int d, x;
            cin >> d >> x;
            if(d == 0) dq.push_front(x);
            else dq.push_back(x);
        }else if(n == 1){
            int p;
            cin >> p;
            cout << dq[p] << endl;
        }else{
            int d;
            cin >> d;
            if(d == 0) dq.pop_front();
            else dq.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 4600
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }
    rep(i, n-1){
        if(h[i] < h[i+1]){
            h[i+1]--;
        }
    }
    rep(i, n-1){
        if(h[i] > h[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

void input(vector<string>& rvsColor, int& rnRemain)
{
  int nySiz, nxSiz;
  cin >> nySiz >> nxSiz >> rnRemain;
  rvsColor.resize(nySiz);

  for (string& rsColor : rvsColor)
    cin >> rsColor;
}

int calcNumOfCase(const vector<string>& cnrvsColor, int nRemain)
{
  int nNumOfCase = 0;

  for (int nyCtl = 0; nyCtl < ( 1 << cnrvsColor.size() ); nyCtl++)
    for (int nxCtl = 0; nxCtl < ( 1 << cnrvsColor[0].size() ); nxCtl++)
    {
      int nCntTrg = 0;

      for (int nyEach = 0; nyEach < cnrvsColor.size(); nyEach++)
      {
        if (nyCtl & ( 1 << nyEach )) continue;

        for (int nxEach = 0; nxEach < cnrvsColor[nyEach].size(); nxEach++)
        {
          if (nxCtl & ( 1 << nxEach )) continue;
          if (cnrvsColor[nyEach][nxEach] == '#') nCntTrg++;
        }
      }
      if (nCntTrg == nRemain) nNumOfCase++;
    }

  return nNumOfCase;
}
 
int main()
{
  vector<string> vsColor;
  int nRemain;

  input(vsColor, nRemain);
  cout << calcNumOfCase(vsColor, nRemain) << endl;

  return 0;
}

Measured memory_bytes: 3612
// amigos y no más
// dile a la jardinera que traigo flores
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define MOD 998244353LL
#define MOD1 1000000007LL
#define LIM 262150
 
using namespace std;
 
typedef long long ll ;
 
int H,W;

int sqA[100][100];
int sqB[100][100];
bool dp[85][85][6405*2] = {0};




int main() {
	fastio;
	
	cin>>H>>W;
	
	for(int i=1; i<=H ; i++ ) {
		for(int j=1; j<=W ; j++ ) {
			cin>>sqA[i][j];
		}
	}
	
	for(int i=1; i<=H ; i++ ) {
		for(int j=1; j<=W ; j++ ) {
			cin>>sqB[i][j];
		}
	}
	
	dp[1][1][abs(sqA[1][1] - sqB[1][1])] = 1;
	
	for(int i=1; i<=H ; i++ ){
		for(int j=1; j<=W ; j++ ){
			for(int k=0; k<=6400*2;k++){
				if(dp[i][j][k]){
					dp[i+1][j][ abs(k + abs(sqA[i+1][j] - sqB[i+1][j]))] = 1;
					dp[i+1][j][ abs(k - abs(sqA[i+1][j] - sqB[i+1][j]))] = 1;
					dp[i][j+1][ abs(k + abs(sqA[i][j+1] - sqB[i][j+1]))] = 1;
					dp[i][j+1][ abs(k - abs(sqA[i][j+1] - sqB[i][j+1]))] = 1;
				}
			}
			
		}
	}
	
	for(int i=0; i<=6400*2;i++){
		if(dp[H][W][i]) {
			cout<<i<<"\n";
			break;
		}
	}
	
	return 0;
}


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

using namespace std;

#define int long long

char c[5] = {'M', 'A', 'R', 'C', 'H'};
int cnt[30];
int n, ans;

int32_t main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
	string s;
	cin >> s;
	cnt[s[0] - 'A']++;
    }
    for (auto i : c)
	for (auto j : c)
	    for (auto k : c)
		if (i != j && j != k && k != i)
		    ans += cnt[i - 'A'] * cnt[j - 'A'] * cnt[k - 'A'];
    return cout << ans / 6, 0;
}

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

template <class T1> void write(T1 e)
{
    cout << e << endl;
}
template <class T1,class T2> void write(T1 e1,T2 e2)
{
    cout << e1 << " "<< e2 << endl;
}
template <class T1,class T2,class T3> void write(T1 e1,T2 e2,T3 e3)
{
    cout << e1 << " " << e2 << " " << e3 << endl;
}

#define oo          (1<<30)
#define SZ(a)       (int)a.size()
#define LL          long long int
#define ULL         unsigned long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector <string>
#define VI          vector <int>
#define VD          vector <double>
#define VLL         vector <long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fs          first
#define sc          second
#define pii         pair < int , int >

#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define BE(a)       a.begin(),a.end()
#define RBE(a)      a.rbegin(),a.rend()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define Round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;

#define makeint(n,s)  istringstream(s)>>n
#define string_to_int(str) atoll(str.c_str());

#define LCM(A,B)    ((__gcd(A,B))/A)*B
#define GCD(A,B)     __gcd(A,B)

#define YES     write("YES")
#define Yes     write("Yes")
#define yes     write("yes")
#define NO      write("NO")
#define No      write("No")
#define no      write("no")

#define read()      freopen("test.txt","r",stdin)
#define write_file()     freopen("WA.txt", "w", stdout);
#define Faster      {ios_base::sync_with_stdio(false); cin.tie(0);}

#define PI          3.141592653589793
#define pi          2*acos(0)
#define gama        0.57721566490
#define ERR         1e-5
#define PRE         1e-8
#define MAX         1000009

#define Scan(A)         scanf("%lld", &A)
#define Scan2(A, B) 	scanf("%lld %lld",&A, &B)
#define Scan3(A, B, C) 	scanf("%lld %lld %lld",&A, &B, &C)
#define Scan4(A, B, C, D) 	scanf("%lld %lld %lld %lld",&A, &B, &C, &D)

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

bool isvowel(char ch)
{
    ch = tolower(ch);
    return ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u';
}

struct myStruct
{
    LL Sum;
    string name;
    string Party;
};

bool cmp(myStruct a, myStruct b)
{
    return a.Sum > b.Sum ? 0 : 1;
}

map <char, int> Mp;

void Method()
{
    int j = 0;
    for(char i = 'a'; i <= 'z'; i++)
    {
        char temp = (char) i;
        Mp[temp] = j;
        j++;
    }
}

int main()
{
    LL N;
    while(cin >> N)
    {
        set <int> St;
        for(int i = 0; i < N; i++)
        {
            int temp;
            cin >> temp;
            St.insert(temp);
        }
        write(St.size());
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
 
 
 
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))
 
 
#define MOD 1000000007
 
typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int N,W;
vector<P> p;
vector<ll> g[4];
vector<ll> sum[4];//

int main() {
	cin>>N>>W;
	ll a,b;
	cin>>a>>b;
	ll t=a;
	g[a-t].push_back(b);
	rep(i,N-1){
		cin>>a>>b;
		g[a-t].push_back(b);//
	}
	rep(i,4){
		sort(g[i].begin(),g[i].end());
		reverse(g[i].begin(),g[i].end());//
		sum[i].push_back(0);
		rep(j,g[i].size()){
			sum[i].push_back(g[i][j]+sum[i][j]);
		}

	}
	ll val;
	ll ans=0LL;
	rep(i,sum[0].size()){
		rep(j,sum[1].size()){
			rep(k,sum[2].size()){
				rep(l,sum[3].size()){
					val=sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l];
					if(t*i+(t+1)*j+(t+2)*k+(t+3)*l > W)
						continue;
					ans=max(ans,val);
				}
			}
		}
	}
	cout<<ans<< endl;
	return 0;
}




Measured memory_bytes: 256
import math
a, b, C = map(int, input().split())
r = math.radians(C)
l = math.sqrt(a**2+b**2-2*a*b*math.cos(r)) # 残り１辺の長さ
h = b * math.sin(r) # 三角形の高さ
print("{0:.4f} {1:.4f} {2:.4f}".format(a*h/2, a+b+l, h))



Measured memory_bytes: 5712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()


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

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

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

		ll ans = 1LL;
		for (int i = 0; i < N; i++) {
				ans = lcm(ans, T[i]);	
		}

		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256