akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

// i: index, n: size, a: start, b: end
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

// x: container(array, vector etc..)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5

#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int f_rank = 1;
  int passed = 0;
  REP(i, s.length()) {
    if (s[i] == 'a') {
      if (passed < a + b) {
        cout << "Yes" << endl;
        passed++;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i] == 'b') {
      if (passed < a + b && f_rank <= b) {
        cout << "Yes" << endl;
        f_rank++;
        passed++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int dp[51][51][2510];

signed main(){
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, 0, n) cin >> x[i];
    int ans = 0;
    dp[0][0][0] = 1;
    rep(i, 0, n){
        rep(j, 0, n){
            rep(k, 0, 2501){
                if(k + x[i] < 2501){
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                }
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }
    rep(i, 1, n + 1){
        rep(j, 0, 2501){
            if(j % i == 0 && j / i == a) ans += dp[n][i][j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 50304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll s = 1000001;
static const ll MOD = 1e9 + 7;
ll f[s] = {};
ll POW(ll e, ll n) {
	//cout << e << " " << n << endl;
	if (n == 0) return 1;
	if (n == 1) return e;

	ll t = POW(e, n / 2) % MOD;

	if (n & 1)return ((t * t) % MOD)* e % MOD;
	else return t * t % MOD;
}

void fact() {
	f[0] = 1;
	rep(i, 1, s) f[i] = i * f[i - 1] % MOD;
}
ll nCr(ll n, ll r) {
	return ((f[n] * POW(f[r], MOD - 2) % MOD) * POW(f[n - r], MOD - 2) % MOD) % MOD;
}

map<ll, ll> mp;
int main()
{
	fact();
	ll n, m; cin >> n >> m;

	ll t = m;
	for (int i = 2; i*i <= m; i++) {
		while (!(t % i)) {
			mp[i]++;
			t /= i;
		}
	}
	if (t != 1) {
		mp[t]++;
	}

	ll ans = 1;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		ans = ans * nCr(it->second + n - 1, n - 1) % MOD;
	}

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

Measured memory_bytes: 8192
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    double a, b;
    cin >> a >> b;
    int h, m;
    cin >> h >> m;
    double a_ang = (double)2 * M_PI / (double)12 * ( h + m / (double)60) - ( M_PI / (double)2 );
    double b_ang = (double)2 * M_PI / (double)60 * m - ( M_PI /(double)2 );

    if ( a_ang > (double)2 * M_PI ) {
        a_ang -= (double)2 * M_PI;
    }
    
    if ( b_ang > (double)2 * M_PI ) {
        b_ang -= (double)2 * M_PI;
    }

//    cout << a_ang << " " << b_ang << endl;
//    cout << a_ang * (double)360 / ( (double)2 * M_PI ) << " " << b_ang * (double)360 / ( (double)2 * M_PI ) << endl;

    double a_x = a * cos(a_ang);
    double a_y = a * sin(a_ang);

    double b_x = b * cos(b_ang);
    double b_y = b * sin(b_ang);

    double ans = sqrt((a_x - b_x) * (a_x - b_x) + (a_y - b_y) * (a_y - b_y));

    printf("%.10lf\n", ans);

    return 0;
}


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

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

  ll N,white=0,ans=0;
  N=S.size();
  
  for(ll i=0;i<N;i++){
   if(S[i]=='W'){
     white+=1; 
     ans+=(i+1-white);
   }
  }
  
  cout<< ans;
}

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

int solver(string N, int K) {
    int n = N.length();
    if (N[0] == '0') {
        if (n == 1) {
            return 0;
        } else {
            return solver(N.substr(1), K);
        }
    } else if (K == 1) {
        return N[0] - '0' + (n-1) * 9;
    } else if(K == 2) {
        if (n == 1) {
            return 0;
        } else if (n == 2) {
            return ((N[0] - '0') - 1) * 9 + N[1] - '0';
        } else {
            return 9 * 9 * (n-1) * (n-2) / 2 + (N[0] - '0' - 1) * 9 * (n-1) + solver(N.substr(1), 1);
        }
    } else if (K == 3) {
        if (n <= 2) {
            return 0;
        } else if (n == 3) {
            if (N[1] == '0') {
                return ((N[0] - '0') - 1) * 9 * 9;
            } else {
                return ((N[0] - '0') - 1) * 9 * 9 + ((N[1] - '0') - 1) * 9 + N[2] - '0';
            }
        } else {
            return 9 * 9 * 9 * (n-1) * (n-2) * (n-3) / 6 + max(0, N[0] - '0' - 1) * 9 * 9 * (n-1) * (n-2) / 2 + solver(N.substr(1), 2);
        }
    }
    return 0;
}

int main() {
    string N; cin >> N;
    int K; cin >> K;
    cout << solver(N, K) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

int main() {
    int n;
    cin >> n;
    vector<ll> h(n,0);
    rep(i,n)cin >> h[i];
    vector<ll> dp(n,LONG_LONG_MAX);
    dp[0] = 0;
    for(int i = 1;i<= n;i++){
        chmin(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
        if(i != 1)chmin(dp[i],dp[i-2]+abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<String> result = new ArrayList<String>();
		
		int n = stdIn.nextInt();
		stdIn.nextLine();
		for(int i = 0; i < n; i++){
			String str = stdIn.nextLine();
			String after = str.replaceAll("Hoshino", "Hoshina");
			result.add(after);
		}
		
		for(String ans : result){
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=100009;
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int a,b;
	string s,t,u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(u==s)cout << a-1 << " " << b;
	else cout<< a << " " << b-1;
}

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

#define int long long
#define pb push_back
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
using namespace std;

const int maxn=2e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int a[maxn];
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int ans=0;
    for(int i=2;i<=n;++i){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
}
/**
1
3 1
1 3
**/


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


using namespace std;

int n, m, x;
const int INF = 1e9;

int now = 0;
void Calc(int c[], vector<vector<int>> a, vector<int>& rikai, int& res,int n,int x, int i)
{
    if (i == n)
    {
        int ch = 0;
        for (int j = 0; j < m; j++)
        {
            if (rikai[j] < x)
            {
                ch++;
            }
        }
        if (ch == 0)
        {
                if (now < res)
                {
                    /*cout << now << endl;
                    
                    for (int j = 0; j < m; j++)
                    {
                        cout << rikai[j] << " ";
                        if (j == m - 1)
                            cout << endl;
                    }*/
                    
                    res = now;
                    return;
                }
        }
        else
        {
            return;
        }
    }
    else
    {
        for (int j = 0; j < 2; j++)
        {
            if (j == 0)
            {
                Calc(c, a, rikai, res, n,x, i + 1);
            }
            else
            {
                now += c[i];
                for (int p = 0; p < m; p++)
                    rikai[p] += a[i][p];

                Calc(c, a, rikai, res, n,x, i + 1);

                now -= c[i];
                for (int p = 0; p < m; p++)
                    rikai[p] -= a[i][p];
            }
        }
    }
}

int main()
{
    cin >> n >> m >> x;
    int *c=new int[n];
    vector<vector<int>> a(n, vector<int>(0));
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            int b;
            cin >> b;
            a[i].push_back(b);
        }
    }
    vector<int> rikai(m, 0);
    int res = INF;
    
    Calc(c, a, rikai, res, n,x,0);
    if (res == INF)
        res = -1;
    cout << res << endl;

}



Measured memory_bytes: 3640
S = input()
year = int(S[:2])
month = int(S[2:])
if (month <= 12 and month >=1) and (year >= 1 and year <= 12):
    print('AMBIGUOUS')
elif (month <= 12 and month >= 1) and ((year >= 13 and year <= 99) or (year==0)):
    print('YYMM')
elif (year <= 12 and year >= 1) and ((month >= 13 and month <= 99) or (month==0)):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{


    public class Program
    {
        public static void Main(string[] args)
        {
            string[] ABString = Console.ReadLine().Split(' ');
            long A = long.Parse(ABString[0]);
            long B = long.Parse(ABString[1]);
            long ans = 1;

            long gcd = Gcd(A, B);

            Dictionary<long, long> elements = FindElements(gcd);

            ans += elements.Count;
            
            Console.WriteLine(ans);
            Console.ReadLine();
        }


        static Dictionary<long,long> FindElements(long N)
        {
            long curN = N;
            Dictionary<long, long> elements = new Dictionary<long, long>();
           
            for (int i = 2; i <= (long)Math.Sqrt(N); i++)
            {
                while (curN%i==0)
                {
                    curN /= i;
                    if (elements.ContainsKey(i)) elements[i]++;
                    else elements.Add(i, 1);
                }
            }
            if(curN!=1)elements.Add(curN, 1);
            return elements;
        }


        /// <summary>
        /// 最大公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }


}


Measured memory_bytes: 13268
#include <unistd.h>
#include <cstdio>
#include <algorithm>

typedef long long ll;

int mat[3000][3000];

ll dp0[3000];
ll ymm[4];

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = v;
    }
    for (int y = 0; y < rr; y++) {
        ymm[0] = ymm[1] = ymm[2] = ymm[3] = 0;
        for (int x = 0; x < cc; x++) {
            ymm[0] = std::max(ymm[0], dp0[x]);
            int v = mat[y][x];
            for (int c = 3; c > 0; c--) {
                ymm[c] = std::max(ymm[c], ymm[c - 1] + v);
            }
            dp0[x] = std::max(std::max(ymm[0], ymm[1]), std::max(ymm[2], ymm[3]));
        }
    }
    std::printf("%lld\n", dp0[cc - 1]);
    return 0;
}

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

main()
{
    int h,w,k; cin>>h>>w>>k;
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    sx--,sy--,tx--,ty--;
    vector<string> grd(h);
    for(auto &r: grd) cin>>r;
    const int inf=1e7;
    vector dist(h,vector<int>(w,inf));
    const int dx[4]={1,0,-1,0};
    const int dy[4]={0,1,0,-1};
    queue<pair<int,int>> qu;
    qu.emplace(sx,sy);
    dist[sx][sy]=0;
    while(!qu.empty())
    {
        auto [nox,noy]=qu.front();
        qu.pop();
        for(int i=0; i<4; i++)
        {
            int tox=nox;
            int toy=noy;
            for(int j=1; j<=k; j++)
            {
                tox+=dx[i];
                toy+=dy[i];
                if(tox<0 or toy<0 or tox>=h or toy>=w) break;
                if(grd[tox][toy]=='@' or dist[tox][toy]<=dist[nox][noy]) break;
                if(dist[tox][toy]==inf)
                {
                    qu.emplace(tox,toy);
                    dist[tox][toy]=dist[nox][noy]+1;
                }
            }
        }
    }
    if(dist[tx][ty]!=inf) cout << dist[tx][ty] << "\n";
    else cout << -1 << "\n";
}

Measured memory_bytes: 12160
list1 = []
for i in range(1, 11):
    list1.append(input())


for x in range(1, 11):
    for y in range(0, 9):
        if int(list1[y]) < int(list1[y+1]):
            temp = list1[y]
            list1[y] = list1[y+1]
            list1[y+1] = temp

print(list1[0])
print(list1[1])
print(list1[2])


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main() {

  int m, n;

  while(cin >> m >> n) {

    if(m == 0 || n == 0) break;
  
    int x = 1;
    int y = 1;

    string command;
    int offset;

    int direction = 0;
    
    while(cin >> command) {

      if(command == "STOP") {

	cout << x << " " << y << endl;
	break;

      }

      if(command == "LEFT") {

	direction += 1;
	direction %= 4;

      }

      if(command == "RIGHT") {

	direction -= 1;
	if(direction == -1) direction = 3;
	direction %= 4;

      }

      if(command == "FORWARD") {

	cin >> offset;
	
	switch(direction) {

	case 0:
	  if(y + offset > n) y = n;

	  else y += offset;

	  break;

	case 1:
	  if(x - offset < 1) x = 1;

	  else x -= offset;

	  break;

	case 2:
	  if(y - offset < 1) y = 1;

	  else y -= offset;

	  break;

	case 3:
	  if(x + offset > m) x = m;

	  else x += offset;

	  break;

	}

      }

      if(command == "BACKWARD") {

	cin >> offset;
	
	switch(direction) {

	case 0:
	  if(y - offset < 1) y = 1;

	  else y -= offset;

	  break;

	case 1:
	  if(x + offset > m) x = m;

	  else x += offset;

	  break;

	case 2:
	  if(y + offset > n) y = n;

	  else y += offset;

	  break;

	case 3:
	  if(x - offset < 1) x = 1;

	  else x -= offset;

	  break;

	}
	
      }

      //cout << x << " " << y << " " << direction << endl;

    }
  }
  
  
  return 0;

}

Measured memory_bytes: 1212
import sys
readline = sys.stdin.readline
import numpy as np

N = int(readline())
A = np.array(readline().split(),dtype=int)
DIV = 10 ** 9 + 7

# 各桁の1と0の数を数えて、((1の数) * (0の数)) * (2 ** i桁目(1桁目を0とする))を数える

K = max(A)
  
j = 0
ans = 0
while K:
  bits = (A >> j) & 1
  one = np.count_nonzero(bits)
  ans += (one % DIV) * ((N - one) % DIV) * pow(2,j,DIV)
  ans %= DIV
  j += 1
  K >>= 1

print(ans)

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

int main() {
   int K,N;
   cin >> K >> N;
   vector<int>V(N);
   for (int i=0 ; i<N ; i++){
       cin >> V.at(i);
   }
   int X,Y=0,Z;
   X=V.at(N-1)-V.at(0);
   for (int i=0 ; i<N-1 ; i++){
       if (Y<V.at(i+1)-V.at(i)){
           Y=V.at(i+1)-V.at(i);
       }
   }
   Z=K-Y;
   cout << min(X,Z) << endl;
}

Measured memory_bytes: 1024
def eval(A, B, S):
	if len(S) != A + B + 1:
		return False
	if S[A] != '-':
		return False
	for i in range(A):
		if not S[i].isdigit():
			return False
	for i in range(B):
		if not S[i + A + 1].isdigit():
			return False
	return True


A, B = map(int, raw_input().split())
S = raw_input()
if eval(A, B, S):
	print "Yes"
else:
	print "No"



Measured memory_bytes: 2568
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
print((n + 1) // 2)

Measured memory_bytes: 5180
import java.util.*;

public class Main {

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

        long n = sc.nextLong();
        long d = sc.nextLong();

        long dis = d * d;

        long ans = 0;

        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();

            if (x*x + y*y <= dis) {
                ans++;
            }

        }

        System.out.println(ans);



        sc.close();

        }

    }



Measured memory_bytes: 59100
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    char A[N][N], B[M][M];

    for (int h = 0; h < N; ++h)
    {
        for (int w = 0; w < N; ++w){
            cin >> A[h][w];
        }
    }

    for (int h = 0; h < M; ++h)
    {
        for (int w = 0; w < M; ++w)
        {
            cin >> B[h][w];
        }
    }

    bool ans = false;
    for (int ly = 0; ly < N; ++ly){
        for (int lx = 0; lx < N; ++lx){
            if (ly + M - 1 >= N or lx + M - 1 >= N)
                continue;

            bool match = true;
            for (int y = 0; y < M; ++y)
            {
                for (int x = 0; x < M; ++x)
                {
                    if (A[ly + y][lx + x] != B[y][x])
                        match = false;
                }
            }
            if (match)
                ans = true;
        }
    }

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

    return 0;
}

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

using namespace std;

vector<int> midN;

priority_queue<int, vector<int>, greater<int>> leftN;

priority_queue<int> rightN;

vector<long> savedLeft;
vector<long> savedRight;

int main(){
  int N=0;
  cin>>N;
  int head=0;
  int tail=N-1;
  long sumLeft=0;
  long sumRight=0;
  long res=0;
  
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    leftN.push(tmp);
    sumLeft+=tmp;
  }

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

  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    rightN.push(tmp);
    sumRight+=tmp;
  }

  res=sumLeft-sumRight;
  sumLeft=sumRight=0;
  savedLeft.push_back(sumLeft);
  savedRight.push_back(sumRight);
  
  for(int i=0;i<N;i++){
    int opA=midN[i]-leftN.top();
    if(opA>0){
      leftN.pop();
      leftN.push(midN[i]);
      sumLeft+=opA;
    }
    savedLeft.push_back(sumLeft);
  }

  for(int i=N-1;i>=0;i--){
    int opB=rightN.top()-midN[i];
    if(opB>0){
      rightN.pop();
      rightN.push(midN[i]);
      sumRight+=opB;
    }
    savedRight.push_back(sumRight);
  }
  
  long maxSum=0;
  for(int i=0;i<=N;i++){
    long tmp=savedLeft[i]+savedRight[N-i];
    if(tmp>maxSum)
      maxSum=tmp;
  }

  cout<<res+maxSum<<endl;
  
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;
int N, T;

void solve() {
    Int t0, t1;
    Int sumTime = 0;
    cin >> N >> T;
    t0 = -T - 1;
    REP(i, N){
        cin >> t1;
        if (t1 - t0 >= T){
            sumTime += T;
        } else {
            sumTime += t1 - t0;
        }
        t0 = t1;
    }
    cout << sumTime << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 256
s = input()
for _ in range(int(input())):
    code=input().split()
    if code[0]=='print'  :
        print("".join(s[int(code[1]):int(code[2])+1]))
    elif code[0]=='reverse':
        s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
    elif code[0]=='replace':
        s = s[:int(code[1])] + code[3] + s[int(code[2])+1:]

Measured memory_bytes: 7688
#include<bits/stdc++.h>
using namespace std;
void rec(int data){
	if(data==0)return ;
	int next=abs(data)%2;
	if(data<0)next=(2-next)%2;
	rec((data-next)/-2);
	cout<<next;
}
int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	rec(n);
	cout<<endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int h,w, k;
string s[22];
void solve(){
	cin >> h >> w >> k;
	int cnt = 0;
	for(int i = 0; i < h; i++){
		cin >> s[i];
		for(int j = 0; j < w; j++){
			cnt += (s[i][j]=='1');
		}
	}
	
	
	int ans = INF;
	for(int i = 0; i < (1<<(h-1)); i++){
		int c[22] = {0};
		int a = 0;
		for(int ii = 0; ii < h-1; ii++) if(i>>ii & 1) a++;
		for(int j = 0; j < w; j++){
			int d = 0;
			int aa = a;
			for(int ii = -1; ii < h-1; ii++){
				if(ii == -1){
					d = 0;
					c[d] += (s[0][j] == '1');
					if(c[d] > k){
						a++;
						if(a-aa > max(w,h)){
							a = INF;
							break;
						}
						fill(c,c+11,0);
						ii = -2;
					}
					continue;
				}
				if(i>>ii & 1) d++;
				c[d] += (s[ii+1][j] == '1');
				if(c[d] > k){
					a++;
					if(a-aa > max(w,h)){
						a = INF;
						break;
					}
					fill(c,c+11,0);
					ii = -2;
					continue;
				}
			}
			if(a == INF) break;
		}
		chmin(ans, a);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
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;
}

int main()
{   
    int n,x,y; cin >> n >> x >> y;
    map<int,ll> mp;
    for(int i=1;i<= n;i++){
        for(int j=i+1;j<= n;j++){
            int res = min(j-i,abs(x-i)+abs(y-j)+1);
            mp[res]++;
        }
    }
    for(int k=1;k<n;k++) cout << mp[k] << endl;
}
    

Measured memory_bytes: 384
use std::io;
use std::str::FromStr;
use std::cmp;

fn init_vec(n: i64) -> Vec<(i64,i64)> {
   let mut vec = Vec::<(i64,i64)>::new();
   let mut i = 0;
   while i < n {
     vec.push((i,i));
     i = i + 1;
   }
   vec
}

fn get_pair() -> (i64,i64) {
   let mut buf = String::new();
   io::stdin().read_line(&mut buf).ok();
   let mut iter = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
   let (n, m) = (iter.next().unwrap(), iter.next().unwrap());
   (n,m)
}

fn main() {
   let (n, m) = get_pair();
   let mut vec = init_vec(n);

   let mut inp = Vec::<(i64,i64)>::new();
   for _i in 0..m {
      let (mut s,mut t) = get_pair();
      s -= 1;
      t -= 1;
      inp.push((s,t));
   }
   inp.sort();
   for i in 0..m {
      //let mut x = inp[i as usize].0;
      //let mut y = inp[i as usize].1;
      //println!("{} and {}",x,y);	
      let mut s = inp[i as usize].1;
      let mut t = inp[i as usize].1 + 1;
      //println!("st = {} and {}",s,t);	
      let mini = cmp::min(vec[s as usize].0,vec[t as usize].0);
      let maxi = cmp::max(vec[s as usize].1,vec[t as usize].1);
      vec[s as usize].0 = mini;
      vec[t as usize].0 = mini;
      vec[s as usize].1 = maxi;
      vec[t as usize].1 = maxi;
   }
   for i in 0..n {
      if i > 0 {
        print!(" ");
      }
      print!("{}",vec[i as usize].1-vec[i as usize].0+1);
   }
   println!("");
}


Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  int N;
  int M;
  cin >> N;
  cin >> M;
  int check = 0;
  vector <vector<int>> data(M,vector<int>(2));
  for(int i=0; i<M;i++){
      cin >> data.at(i).at(0);
      cin >> data.at(i).at(1);

  }
  
  
        int first;
        int second;
        int third;
        int count=0;
        int count2=0;
        int count3 =0;
        for(int i=0;i<M;i++){
            if(N != 1&&data.at(i).at(0)==1&&data.at(i).at(1)==0){
               check = 1;
            }
        }
        for(int i=0;i<M;i++){
            if(data.at(i).at(0)==1){
                if (count==0){
                    first = data.at(i).at(1);
                }else{
                    if(data.at(i).at(1)!=first){
                        check = 1;
                    }
                }
                count ++;
            }
            if(data.at(i).at(0)==2){
                if (count2==0){
                    second = data.at(i).at(1);
                }else{
                    if(data.at(i).at(1)!= second){
                        check = 1;
                    }
                }
                count2 ++;
            }
            if(data.at(i).at(0)==3){
                if (count3==0){
                    third = data.at(i).at(1);
                }else{
                    if(data.at(i).at(1) !=third){
                        check = 1;
                    }
                }
                count3 ++;
            }
        }
        
        if(check==1){
          cout << -1 << endl;
        }else{
          if(count==0&&N!=1){
              first =1;
          }
          if(count==0&&N==1){
              first =0;
          }
          if(count2==0){
              second=0;
          }
          if(count3==0){
              third=0;
          }
          if (N==3){
            cout << first << second << third <<endl;
        }else if(N==2){
            cout << first << second  <<endl;
        }else if(N==1){
            cout << first << endl;
        }
      }

    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
    char s[100005];
    cin>>s;
    bool check[26];
    for(int i=0;i<26;i++){
        check[i]=0;
    }
    int N;
    N=strlen(s);
    int num;
    for(int i=0;i<N;i++){
       num=s[i]-'a';
       check[num]=1;
    }
    int ans=0;
    for(int i=0;i<26;i++){
        if(check[i]==0){
            ans=i+'a';
            break;
        }
    }
    if(ans==0) cout<<"None";
    else{
    unsigned char uchar;
    uchar=(char)ans;
    cout<<uchar;}
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

int main()
{
	int n, h, w;
	cin >> n >> h >> w;

	cout << ((n + 1) - h) * ((n + 1) - w) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader fs = new FastReader();
        long a = fs.nextInt();
        long b = fs.nextInt();
        long c = fs.nextInt();
        long d = fs.nextInt();
        long a1 = a * c;
        long a2 = a * d;
        long a3 = b * c;
        long a4 = b * d;
        System.out.println(Math.max(a1, Math.max(a2,Math.max(a3,a4))));



    }


    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 32708
coins = list(map(int, input().split()))
for i in range(len(coins)):
    current_coin = coins[i]
    if i == 0:
        coins[i] = current_coin * 1
    elif i == 1:
        coins[i] = current_coin * 5
    elif i == 2:
        coins[i] = current_coin * 10
    elif i == 3:
        coins[i] = current_coin * 50
    elif i == 4:
        coins[i] = current_coin * 100
    elif i == 5:
        coins[i] = current_coin * 500
 
if sum(coins) >= 1000:
    print('1')
else:
    print('0')


Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  ll lcm = (C * D) / GCD(C, D);
  ll ans1 = (B / C) + (B / D) - (B / lcm);
  ll ans2 = (A / C) + (A / D) - (A / lcm);
  cout << B - A - (ans1 - ans2) << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int a;
int b;

vector<i64> v;

i64 MOD = 1e9 + 7;

i64 nCr[60][60];


int main()
{
    rep(i,0,50)
    {
        rep(j,0,i)
        {
            if(j == 0 || j == i) nCr[i][j] = 1;
            else nCr[i][j] = nCr[i - 1][j - 1] + nCr[i - 1][j];
        }
    }
    cin >> n >> a >> b;
    v.resize(n);
    rep(i,0,n - 1) cin >> v[i];
    sort(v.rbegin(),v.rend());

    i64 MAX = -1;
    vector<int> ans;

    rep(c,a,b)
    {
        i64 sum = 0;
        rep(i,0,c - 1)
        {
            sum += v[i];
        }
        if(MAX == -1)
        {
            ans.push_back(c);
            MAX = sum;
        }
        else if(sum * ans[0] > MAX * c)
        {
            ans.resize(0);
            ans.push_back(c);
            MAX = sum;
        }
        else if(sum * ans[0] == MAX * c)
        {
            ans.push_back(c);
        }
    }
    cout << fixed << setprecision(8);
    cout << 1.0 * MAX / ans[0] << endl;
    i64 result = 0;
    for(int i : ans)
    {
        int inc = 0;
        int cou = 0;
        i64 MI = v[i - 1];
        rep(j,0,n - 1)
        {
            if(MI == v[j])
            {
                if(j < i)
                {
                    inc++;
                }
                cou++;
            }
        }
        result += nCr[cou][inc];
    }
    cout << result << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll n=s.length();
	ll a[n];rep(i,0,n){
		if(s[i]=='L')a[i]=0;
		if(s[i]=='R')a[i]=1;
		if(s[i]=='U')a[i]=2;
		if(s[i]=='D')a[i]=3;
	}
	ll f=1;
	ll cnt[4]={0};
	for(ll i=0;i<n;i+=2)cnt[a[i]]++;
	if(cnt[0]>0)f=0;
	rep(i,0,4)cnt[i]=0;
	for(ll i=1;i<n;i+=2)cnt[a[i]]++;
	if(cnt[1]>0)f=0;
	if(f)cout<<"Yes";
	else cout<<"No";
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

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

  int flag = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        flag = 0;
        break;
      }
    }
  }

  if (flag == 1) {
    printf("APPROVED\n");
  } else {
    printf("DENIED\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 h, w;
  scanf ("%" SCNi32 "%" SCNi32, &h, &w);
  char *s = ALLOC (h * w + 1, char);
  for (i32 i = 0; i < h; ++i) {
    scanf ("%s", s + i * w);
  }
  i32 max = 0;
  for (i32 i = 0; i < h * w; ++i) {
    if (s[i] != 'B') continue;
    for (i32 j = i + 1; j < h * w; ++j) {
      if (s[j] != 'B') continue;
      i32 x = i / w;
      i32 y = i % w;
      i32 p = j / w;
      i32 q = j % w;
      max = MAX (max, ABS (x - p) + ABS (y - q));
    }
  }
  printf ("%" PRIi32 "\n", max);
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 2112
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	x=RD()

	ans=0
	s=0

	for i in x:
		if i=="S":
			s+=1
		else:
			if s==0:
				ans+=1
			else:
				s-=1

	print(ans+s)









if __name__ == "__main__":
	main()


Measured memory_bytes: 73296
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct Combination {
  vector<mint> fact, ifact;
  Combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,k;
  cin >> n >> k;
  Combination c(n);

  rep(i,k){
    int ki = i+1;
    mint ans = c(n-k+1,ki) * c(k-1,ki-1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int AB=sc.nextInt();
		int BC=sc.nextInt();
		int CA=sc.nextInt();

		System.out.print(AB*BC/2);

		sc.close();
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
#define REP(i, x, n) for(int i=x; i<n; i++)

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

        ll a;
        long double b;
        cin >> a >> b;
        cout << a * (ll)(b * 100 + 1e-10) / 100ll << endl;

        return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
int main()
{
	int N;
	int A[9][9];
	int tmp;
	int bits[3] = {0};
	for(int i = 0;i < 3;i++)
		for(int j = 0; j < 3; j++)
			scanf("%d",&A[i][j]);
	scanf("%d", &N);
	for (int i = 0; i < 9; i++){
		scanf("%d", &tmp);
		for (int j = 0; j < 3; j++)
			for(int k = 0; k < 3; k++){
				if(tmp == A[j][k]){
					bits[j] |= (1 << k);
				}
			}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++){
		if(bits[i] == 0x0007){
			ans = 1;
		}
		int temp = 0;
		for(int j = 0; j < 3; j++){
            if((bits[j] & (1 << i)))
				temp++  ;
		}
		if (temp == 3){
			ans = 1;
		}
	}
	if ((bits[0] & (1 << 0)) && 
	(bits[1] & (1 << 1)) && (bits[2] & (1 << 2)))
		ans = 1;
	if ((bits[0] & (1 << 2)) && 
	(bits[1] & (1 << 1)) && (bits[2] & (1 << 0)))
		ans = 1;
	if(ans){printf("Yes");}
	else{printf("No");}
}

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

int main(){
    int N;
    int c=0;
    cin>>N;
    vector<pair<int, int>> throws (N, std::make_pair(0, 0));
    for(int i=0; i<N;i++){
        cin>>throws[i].first;
        cin>>throws[i].second;
    }
    for(int i=0; i<=(N-3);i++){
        if((throws[i].first==throws[i].second) && (throws[i+1].first==throws[i+1].second) && (throws[i+2].first==throws[i+2].second)){
            cout<<"Yes"<<endl;
            c=1;
            break;
        }
    }
    if(c==0) cout<<"No"<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main()
{
    int n;
    int ans = 0;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n%2==1){
        int L = a[(n-1)/2];
        int R = b[(n-1)/2];
        ans = R-L+1;
        cout << ans << endl;
    }else if(n%2==0){
        int L = a[n/2-1]+a[n/2];
        int R = b[n/2-1]+b[n/2];
        ans = R-L+1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4828
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
  int N,K; cin >> N >> K;
  int ans = K;
  rep(i,N-1){
    ans *= K-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var Nx = IO.RSInt;
            var N = Nx[0];
            var x = Nx[1];
            var a = IO.RSInt;

            long ans = 0;
            for (int i = 0; i < N - 1; i++)
            {
                // a[i],a[i+1]を調べる、a[i+1]から減らしていく
                if (a[i] + a[i + 1] > x)
                {
                    var minus = a[i] + a[i + 1] - x;
                    if (a[i + 1] < minus)
                    {
                        a[i + 1] = 0;
                        a[i] -= minus - a[i + 1];
                    }
                    else
                    {
                        a[i + 1] -= minus;
                    }
                    ans += minus;
                }
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 33716