akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) c.begin(),c.end()
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
#define sizestr(i,x)  size_t i=x.length();
using namespace std;



int main(){
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll h;
    if(x>y)h=2*x;
    else h=2*y;
    ll flag;
    ll ju=10000000000000000;
    for(int i=0;i<=h;i+=2){
        int g,k;
        if((x-i/2)<0)g=0;
        else g=x-i/2;
        if((y-i/2)<0)k=0;
        else k=y-i/2;

        flag=a*g+b*k+c*i;
        if(ju>flag)ju=flag;
    }

    cout<<ju<<endl;
}


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

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  
  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x);
      i += i & -i;
    }
  }
  
  ll sum(int l,int r){ //[l, r) 0オリジン
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};


int main(){
  int n,q;
  cin>>n>>q;
  
  BIT bit(n);
  while(q--){
    int com, x, y;
    cin>>com >> x >> y;
    if(com == 0) bit.add(x-1 , y);
    if(com == 1) cout<<bit.sum(x-1,y)<<endl;
  }

  
}



Measured memory_bytes: 3900
#include<stdio.h>
int main(){
  int n,t,a,h[100000],k,cc = 10000000000000,ans;
  scanf("%d",&n);
  scanf("%d %d",&t,&a);
  for(int i = 0;i < n;i++){
    scanf("%d",&h[i]);
    k = t * 1000 - h[i] * 6 - a * 1000;
    if(k < 0){
      k = -k;
    }
    if(k < cc){
      cc = k;
      ans = i;
    }
  }
  printf("%d",ans + 1);
  return 0;
}

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

using namespace std;

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

    string s; cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14, 5);

    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if arr[i] + arr[i+1] >= x:
        tmp = arr[i] + arr[i+1] - x
        if arr[i+1] >= tmp:
            arr[i+1] -= tmp
        else:
            arr[i+1] = 0
        ans += tmp
print(ans)

Measured memory_bytes: 85492
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int main(){
	int m,d,ans=0;scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			if(j%10 >= 2 && j%100/10 >= 2){
				int g1=j%10, g2=j%100/10;
				if(g1*g2 == i)++ ans;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<std::vector<int>> g(4);
	for(int i = 0; i < 3; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	
	for(int a = 0; a < 4; a++) {
		for(int b = 0; b < 4; b++) {
			for(int c = 0; c < 4; c++) {
				for(int d = 0; d < 4; d++) {
					if(a == b or b == c or c == d or d == a or a == c or b == d) continue;
					
					bool f = false;
					for(auto v: g[a]) f |= (v == b);
					if(!f) continue; f = false;
					for(auto v: g[b]) f |= (v == c);
					if(!f) continue; f = false;
					for(auto v: g[c]) f |= (v == d);
					if(!f) continue; f = false;
					printf("YES\n");
					return 0;
				}
			}
		}
	}
	printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
vector<LL>w0,w1,w2,w3;
int main(){
//	freopen("input.txt","r",stdin);
	LL n,W;
	scanf("%lld%lld",&n,&W);
	LL w,v,pw;
	scanf("%lld%lld",&w,&v);
	w0.push_back(v);
	pw=w;
	for(int i=2;i<=n;i++){
		scanf("%lld%lld",&w,&v);
		if(w==pw) w0.push_back(v);
		else if(w==pw+1) w1.push_back(v);
		else if(w==pw+2) w2.push_back(v);
		else if(w==pw+3) w3.push_back(v);
	}
	sort(w0.begin(),w0.end(),greater<LL>());
	sort(w1.begin(),w1.end(),greater<LL>());
	sort(w2.begin(),w2.end(),greater<LL>());
	sort(w3.begin(),w3.end(),greater<LL>());
//	for(int i=0;i<w3.size();i++) cout<<w3[i]<<endl;
	LL ans=-1;
	for(int i=0;i<=w0.size();i++){
		for(int j=0;j<=w1.size();j++){
			for(int k=0;k<=w2.size();k++){
				for(int p=0;p<=w3.size();p++){
					if(pw*i+(pw+1)*j+(pw+2)*k+(pw+3)*p>W) continue;
					LL x=accumulate(w0.begin(),w0.begin()+i,0LL)+accumulate(w1.begin(),w1.begin()+j,0LL)+accumulate(w2.begin(),w2.begin()+k,0LL)+accumulate(w3.begin(),w3.begin()+p,0LL);
					ans=max(ans,x);
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;

vector<vector<ll>> C(61,vector<ll>(61,0));

void mk_c(){
  ll mx=61;
  C[0][0]=1;
  for(int i=1;i<mx;i++){
    C[i][0]=1;
    C[i][i]=1;
    for(int t=1;t<i;t++){
      C[i][t]=C[i-1][t-1]+C[i-1][t];
    }
  }
}




int main(){
  mk_c();
  ll n,m;
  while(cin>>n>>m && n){
  ll I=0;
  while(1){
    const ll &c=C[n][I];
    if(c>=m){break;}
    m-=c;
    I++;
  }
  string ans(n,'0');
  ll l=0;
  while(I>0){
    ll c=0;
    if(n-l-1>=0 && I>=0){c=C[n-l-1][I];}
    if(c<m){
      ans[l]='1';
      I--;
      m-=c;
    }
    l++;
  }
  cout<<ans<<endl;

  }

  return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 105, INF = 10000;
const int WHITE = 0, GRAY = 1, BLACK = 2;

int n;
int M[MAX_N][MAX_N], color[MAX_N], d[MAX_N], p[MAX_N];

void init(){
    rep(i,MAX_N){
        rep(j,MAX_N) M[i][j] = -1;
        color[i] = WHITE;
        d[i] = INF;
    }
}

void prim(int u){
    d[u] = 0;
    p[u] = -1;

    while(true){
        int mincost = INF;
        rep(i,n){
            if(color[i] != BLACK && mincost > d[i]){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INF) break;
        color[u] = BLACK;
        rep(v,n){
            if(color[v] != BLACK && M[u][v] != -1){
                if(M[u][v] < d[v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
}

int main()
{
    cin >> n;
    init();
    rep(i,n){
        rep(j,n){
            int aij; cin >> aij;
            if(aij != -1) M[i][j] = aij;
        }
    }
    prim(0);
    int sum = 0;
    rep(i,n) sum += d[i];
    cout << sum << endl;
}


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

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


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1000000
int n;

pair<int, int> T[MAX];

main(){
    int id, m, s;
    while( cin >> n && n ){
	for ( int i = 0; i < n; i++ ){
	    cin >> id;
	    int sum = 0;
	    for ( int j = 0; j < 4; j++ ){
		cin >> m >> s;
		sum += m*60 + s;
	    }
	    T[i] = make_pair(sum, id);
	}
	sort( T, T + n );

	cout << T[0].second << endl;
	cout << T[1].second << endl;
	cout << T[n-2].second << endl;
    }
}

Measured memory_bytes: 0
N = int(input())
A = [int(x) for x in input().split()]
sum = 1
big = False
if 0 in A:
    print(0)
else:
    for a in A:
        sum *= a
        if sum > 10**18:
            big = True
            break
    if big:
        print(-1)
    else:
        print(sum)

Measured memory_bytes: 88112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y;
  cin>>x>>y;
  if(x>y)swap(x,y);
  bool flag=1;
  if(y-x<2)flag=0;
  cout<<((!flag)?"Brown":"Alice")<<endl;

  return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  V x(n), y(n), m(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> m[i];
  char a[100][100];
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) a[i][j] = '.';
  for (int k = 0; k < n; k++) {
    if (m[k] == 1) {
      for (int i = 0; i < h; i++) for (int j = 0; j < x[k]; j++) a[i][j] = '#';
    }
    else if (m[k] == 2) {
      for (int i = 0; i < h; i++) for (int j = x[k]; j < w; j++) a[i][j] = '#';
    }
    else if (m[k] == 3) {
      for (int i = 0; i < y[k]; i++) for (int j = 0; j < w; j++) a[i][j] = '#';
    }
    else if (m[k] == 4) {
      for (int i = y[k]; i < h; i++) for (int j = 0; j < w; j++) a[i][j] = '#';
    }
  }
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '.') cnt++;
    }
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

static const ll max_v = 1e15;



void Main(){
    ll H, N, a, b;
    cin >> H >> N;
    vector<ll> as(N);
    vector<ll> bs(N);
    ll max_a = H;
    rep(i, N){
        sll(as[i]);
        sll(bs[i]);
        max_a = max(max_a, as[i]);
    }


    vector<ll> dp(2*max_a+10, max_v);
    dp[0] = 0;
    rep(i, 2*max_a+1){
        rep(j, N){
            if(i>=as[j]){
                dp[i] = min(dp[i-as[j]]+bs[j], dp[i]);
            }
        }
    }

    ll ans = max_v;
    for(ll i=H;i<=2*max_a;i++){
        ans = min(dp[i], ans);
    }

    cout << ans <<endl;


}

int main(){
    Main();
}

Measured memory_bytes: 3308
#include<iostream>
using namespace std;
int main()
{
    string s ;cin>>s;
   if (s=="SUN")cout<<"7";
   else if(s=="MON")cout<<"6";
   else if(s=="TUE")cout<<"5";
   else if(s=="WED")cout<<"4";
   else if(s=="THU")cout<<"3";
   else if(s=="FRI")cout<<"2";
   else if(s=="SAT")cout<<"1";
return 0 ;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    vector<int> cnt[5];

    REP(i, 3) {
        int a, b;
        cin >> a >> b;
        cnt[a].push_back(b);
        cnt[b].push_back(a);
    }
    REP(i, 5) {
        if(cnt[i].size() >= 3) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var x = parseInt(input[0][1], 10);
	var vec_a = input[1].map(e => parseInt(e, 10));
	var sum  = function(arr) {
		var sum = 0;
		arr.forEach(function(elm) {
			sum += elm;
		});
		return sum;
	};
	var vec_b = [];
	var tmp = 0;
	for (var i = 0; i < N; i++){
		if (vec_a[i] >= (x - tmp)) vec_b.push(x - tmp);
		else vec_b.push(vec_a[i]);
		tmp = vec_b[i];
	}
	console.log(sum(vec_a) - sum(vec_b));
}


Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 45272
import math

def merge(A, left, mid, right, cnt):
    n1 = mid - left
    n2 = right - mid
    L = [0]*(n1+1)
    R = [0]*(n2+1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = math.inf
    R[n2] = math.inf
    i = 0
    j = 0
    for k in range(left,right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else: 
            A[k] = R[j]
            j += 1
            
    return A, cnt

def mergeSort(A, left, right, cnt):
    if left+1 < right:
        mid = (left + right)//2
        A, cnt = mergeSort(A, left, mid, cnt)
        A, cnt = mergeSort(A, mid, right, cnt)
        A, cnt = merge(A, left, mid, right, cnt)
    return A, cnt
        
n = int(input())
S = list(map(int,input().split()))

S_out, cnt_out = mergeSort(S,0,len(S),0)

S_str = list(map(str,S))
print(" ".join(S_str))
print(str(cnt_out))


Measured memory_bytes: 75380
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<map>

using namespace std;

#define maxn 5005
#define ll long long

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if (b > a + w) cout << b - (a + w) << '\n';
	else if (a > b + w) cout << a - (b + w) << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>  
#include<cstring>  
#include<cstdlib>  
#include<cmath>  
#include<iostream>  
#include<algorithm>  
#include<vector>  
using namespace std;
string a,b,c;
int main(){
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] A = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int max = A.Max();
            int min = A.Min();
            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 13396
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (s, t) = (0 until 2).map { sc.next() }
    var (a, b) = (0 until 2).map { sc.nextInt() }
    val u = sc.next()
    if (u == s) {
        a -= 1
    } else {
        b -= 1
    }
    println("$a $b")
}

Measured memory_bytes: 31132
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n,a[100007];
int main() {
  //  freopen("a.inp", "r", stdin);
    scanf("%d", &n);
    For(i,1,n) scanf("%d", &a[i]);
    sort(a+1,a+n+1,greater<int>());
    a[n+1] = 0;
    int k;
    int t;
    For(i,1,n+1) {
        if (a[i]<i) {
            t = i-2;
            k = a[t+1] - t -1 ;
            break;
        }
    }
    int k1 = 0;
//    cout<<t<<endl;
    For(i,t+2,n) k1+= (a[i] == t+1);
    if (a[1]==1) k1 = !(n%2);
//    cout<<k<<" "<<k1<<endl;
    if (k%2==0 && k1%2==0) cout<<"Second";
        else cout<<"First";
}


Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String set = s.substring(0, s.length() - 1);
        for (int i = set.length(); i > 0; i--) {
            if (set.length() % 2 != 0) {
                set = set.substring(0, set.length() - 1);
                continue;
            } else {
                String first = set.substring(0, set.length() / 2);
                String end = set.substring(set.length() / 2, set.length());
                if (first.equals(end)) {
                    System.out.println(set.length());
                    return;
                }
                set = set.substring(0, set.length() - 1);
            }
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
#define int long long
int mark[N], nxt[N], x[N], a[N], n, m, ans[N];
long long k;
vector<int> tps;
void dfs(int v) {
	mark[v] = 1, tps.push_back(v);
	if (!mark[nxt[v]])
		dfs(nxt[v]);
}
int32_t main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		x[i] = a[i + 1] - a[i];
	iota(nxt, nxt + n + 1, 0);
	cin >> m >> k;
	for (int i = 0; i < m; i++) {
		int y;
		cin >> y;
		y--;
		swap(nxt[y], nxt[y - 1]);
	}
	for (int i = 0; i < n; i++) {
		if (!mark[i]) {
			dfs(i);
			long long fw = k % ((long long) tps.size());
			for (int i = 0; i < tps.size(); i++)
				ans[tps[i]] = x[tps[(i + fw) % tps.size()]];
			tps.clear();
		}
	}
	int lst = a[0];
	cout << a[0] << "\n";
	for (int i = 0; i < n - 1; i++) {
		lst = lst + ans[i];
		cout << lst << "\n";
	}

	return 0;	
}


Measured memory_bytes: 14324
import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	int array[] = new int[n + 1];
	for(int i = 1;i <= n;i++){
		array[i] = Integer.parseInt(br.readLine());
	}
	long ans = array[1] - 1;
	array[1] = 1;
	int curr = 2;
	for(int i = 2;i <= n;i++){
		if(array[i] < curr)continue;
		if(array[i] > curr){
			ans += array[i]/curr;
				if(array[i] % curr == 0)--ans;
		}
		if(array[i] == curr)++curr;
	}
	System.out.print(ans);
}
}

Measured memory_bytes: 18256
#include<iostream>
using namespace std;
int main(){
	while(1){
		int a,b,ans=0;
		cin>>a>>b;
		if(a==0)break;
		a--;
		int c[12]={31,29,31,30,31,30,31,31,30,31,30,31};
		for(int i=0;i<a;i++){
			ans+=c[i];
		}
		ans+=b;
		if(ans%7==1){
			cout<<"Thursday"<<endl;
		}
		if(ans%7==2){
			cout<<"Friday"<<endl;
		}
		if(ans%7==3){
			cout<<"Saturday"<<endl;
		}
		if(ans%7==4){
			cout<<"Sunday"<<endl;
		}
		if(ans%7==5){
			cout<<"Monday"<<endl;
		}
		if(ans%7==6){
			cout<<"Tuesday"<<endl;
		}
		if(ans%7==0){
			cout<<"Wednesday"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 2996
// https://abc097.contest.atcoder.jp/submissions/2503233

/* 参考
http://vivi.dyndns.org/tech/cpp/set.html
*/

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  string s;
  int k;
  set<string> st;
  
  cin >> s;
  cin >> k;

  int len = s.length();
  for(int i = 0; i < len; i++){
    for(int k = 0; (i+k) <= len; k++){
      if(k > 5) break;
      string work = s.substr(i, k);
      st.insert(work);
    }
  }
  auto itr = st.begin();
  for(int i = 0; i < k; ++i)
    ++itr;
  cout << *itr << endl;

/*  // debug
  for(auto itr = st.begin(); itr != st.end(); ++itr) {
    std::cout << *itr << "\n";      // イテレータの指す先のデータを表示
  }*/
  return 0;
}


Measured memory_bytes: 1664
n = gets.to_i
a = gets.split.map(&:to_i)
ans = [true, false].map do |sign|
  sum = 0
  count = 0
  a.each do |i|
    sign = !sign
    sum += i
    if sum == 0
      count += 1
      sum = sign ? -1 : 1
      next
    end
    if sign
      if sum > 0
        count += sum + 1
        sum = -1
      end
    else
      if sum < 0
        count += -sum + 1
        sum = 1
      end
    end
  end
  count
end
p ans.min


Measured memory_bytes: 8580
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
//#define PB push_back
#define CLEAR(c,d) memset((c),(d),sizeof(c))
#define TO_STRING(VariableName) # VariableName
//#define DB(c) cout<<TO_STRING(c)<<"="<<(c)<<endl

#define EXIST(e,s) ((s).find(e)!=(s).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;
// }}}

int perm_parity(vector<int> v){
	vector<int> w = v;
	sort(ALL(w));
	map<int,int> rev_v;
	REP(i,v.size())rev_v[v[i]] = i;
	int parity = 1;
	REP(i,v.size()){
		if(v[i]==w[i])continue;
		else{
			int j = rev_v[w[i]];
			swap(v[i],v[j]);
			rev_v[v[i]] = i;
			rev_v[v[j]] = j;
			parity *= -1;
		}
	}
	return parity;
}

int a[3][100010];

vector<int> v,sign,even,odd;
int odd_prod = 1, even_prod = 1;

int main(){
	int N;
	scanf("%d",&N);
	REP(i,3)REP(j,N)scanf("%d",&a[i][j]),a[i][j]--;
	bool valid = true;
	REP(i,N){
		int m = a[1][i];
		if(not ((a[0][i]==m-1 and a[2][i]==m+1) or (a[0][i]==m+1 and a[2][i]==m-1))){
			valid = false;
		}
		v.push_back(m/3);
		sign.push_back(a[0][i]==m-1?1:-1);
	}
	if(not valid){
		printf("No\n");
		return 0;
	}
	REP(i,N){
		if(i%2==0)even.push_back(v[i]),even_prod*=sign[i];
		else odd.push_back(v[i]),odd_prod*=sign[i];
	}
	int even_parity = perm_parity(even), odd_parity = perm_parity(odd);
	sort(ALL(even));sort(ALL(odd));

	REP(i,N){
		if(i%2==0){
			if(even[i/2]!=i)valid = false;
		}else{
			if(odd[i/2]!=i)valid = false;
		}
	}
	if(even_parity != odd_prod or odd_parity != even_prod) valid = false;
	if(valid)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 5492
p = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]

num = int(input())

for i in range(num):
    b,f,r,v = [ int(x) for x in input().split()]
    p[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ",end="")
            print(p[i][j][k],end="")
        print()
    if i < 3:
        print("####################")



Measured memory_bytes: 5636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[202],cnt=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n-1;i+=2) cnt+=min(a[i],a[i+1]);
	printf("%d",cnt);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
        a[i] -= i+1;
    }
    
    sort(ALL_OF(a));
    ll b = a[n/2];
    ll ans = 0;
    REP(i, n) ans += abs(a[i] - b);
    cout << ans << endl;
    
}

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

int main() {
	cin.tie(NULL);
	cout.tie(NULL);

     int t;
     cin>>t;
     
     //unordered_map<string,int>m;
     
     vector<int>res(4,0);
     for(int i=0;i<t;i++)
     {
     	string s;
     	cin>>s;
     	if(s=="AC")res[0]++;
     	else if(s=="WA")res[1]++;
     	else if(s=="TLE")res[2]++;
     	else if(s=="RE")res[3]++;
   
     	
     }
     
       cout<<"AC x "<<res[0]<<endl;
       cout<<"WA x "<<res[1]<<endl;
       cout<<"TLE x "<<res[2]<<endl;
       cout<<"RE x "<<res[3]<<endl;
       

	return 0;
}

Measured memory_bytes: 3628
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using ll = long long;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
const double PI = acos(-1.0);
template<class Int> Int __gcd(Int a, Int b) { return (b == 0 ? abs(a) : __gcd(b, a % b)); }
int dx[] = { 0,0,-1,1 };
int dy[] = { -1,1,0,0 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
vector<int>v;
map<pair<int, ll>, bool>mp;
bool solve(int idx, ll m) {
	if (idx == sz(v))
		return m == 0;
	//cout << idx << endl;
	if (mp.count({ idx,m }))
		return mp[{idx, m}];
	int ret = solve(idx + 1, m);
	ret |= solve(idx + 1, m + v[idx]);
	ret |= solve(idx + 1, m -= v[idx]);
	return mp[{idx, m}] = ret;
}
int main() {
	//cout << setprecision(4) << fixed;
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//file();
	//freopen("pocnitoare.in", "r", stdin);
	//freopen("pocnitoare.out", "w", stdout);
	//
	int x, y;
	cin >> x >> y;
	ll sum = 0;
	if (x == 1 && y == 1)
		sum = 400000;
	x--, y--;
	if (x > 2)
		x = 3;
	if (y > 2)
		y = 3;
	int arr[] = { 300000 ,200000 ,100000,0 };
	sum += arr[x] + arr[y];
	cout << sum << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 11.05.2020 14:20:05       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << '\n';
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  string s;
  cin >> s;
  int sz=s.size();
  int ans=0,cnt=0;
  rep(i,sz){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      cnt++;
    } else {
      ans = max(ans,cnt);
      cnt=0;
    }
  }
  ans = max(ans,cnt);

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);
	
	string s; cin >> s;
	auto sa = atcoder::suffix_array(s);

	auto lcp = atcoder::lcp_array(s, sa);
	int64_t c = 0;
	for (auto& elem : lcp) {
		c += elem;
	}
	int64_t n = s.size();
	cout << (n * (n + 1)) / 2 - c << endl;

	return 0;
}

Measured memory_bytes: 15680
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const int SZE = 1e6+1;

double adj[1009][1009];
PII p[1009];
int r[1009];
double dist[1009];
priority_queue<pair<double,int>,vector<pair<double,int> >,greater<pair<double,int> > >pq;

int main(){
	RII(p[0].F,p[0].S);
	RII(p[1].F,p[1].S);
	DRI(n);
	REP(i,n){
		RIII(p[i+2].F,p[i+2].S,r[i+2]);
	}
	n+=2;
	REP(i,n){
		REP(j,n){
			adj[i][j]=max((double)0,(double)hypot(p[i].F-p[j].F,p[i].S-p[j].S)-r[i]-r[j]);
			//printf("%lf ",adj[i][j]);
		}//puts("");
	}
	REP(i,n)dist[i]=-2;
	dist[0]=0;
	pq.push(MP(dist[0],0));
	while(!pq.empty()){
		pair<double,int> cur=pq.top();pq.pop();
		if(cur.S==1)break;
		int x=cur.S;
		REP(i,n){
			if(i==x)continue;
			if(dist[i]>-1&&dist[x]+adj[x][i]>=dist[i])continue;
			dist[i]=dist[x]+adj[x][i];
			pq.push(MP(dist[i],i));
		}
	}
	printf("%.10lf",dist[1]);
}


Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int N, M, Q, mx = 0;
vector<tuple<int, int, int, int>> J;

void judge(vector<int>& V) {
	int a, b, c, d, cnt = 0;
	for (int i = 0;i < Q;i++) {
		tie(a, b, c, d) = J[i];
		a--;
		b--;
		if (V[b] - V[a] == c) {
			cnt += d;
		}
	}
	mx = max(cnt, mx);
}

void dfs(vector<int>& V, int X) {
	if (X == N) {
		judge(V);
		return;
	}
	if (X == 0) {
		for (int i = 1;i <= M;i++) {
			V[X] = i;
			dfs(V, X + 1);
		}
	}
	else {
		for (int i = V[X - 1];i <= M;i++) {
			V[X] = i;
			dfs(V, X + 1);
		}
	}
}

int main() {
	int a, b, c, d;
	cin >> N >> M >> Q;

	for (int i = 0;i < Q;i++) {
		cin >> a >> b >> c >> d;
		J.push_back(make_tuple(a, b, c, d));
	}
	vector<int> V(N);
	dfs(V, 0);
	cout << mx << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, f = 0, t = 0, o = 0;
  cin >> N;
  vector<ll> a(N);

  rep(i, N){
    cin >> a[i];
    if(a[i]%4==0) f++;
    else if(a[i]%2 == 0) t++;
    else o++;
  }

  
  if(t>0) t=1;

  if(f >= o + t - 1){
    print("Yes");
  } else {
    print("No");
  }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ll x,k,d; cin>>x>>k>>d;
    x = abs(x);
    ll m = x/d, md = x%d;
    if(m > k) cout<<md+(m-k)*d<<endl
    else{
    	m -= k;
    	if(m&1) cout<<d-md<<endl
    	else cout<<md<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
#define mod 1000000007
ll ans;
int n;
int main() {
	n = read();
	if (n < 3) {
		cout << 0 << endl;
		return 0;
	}
	vector<ll>dp(n + 1, 0);
	dp[3] = 1;
	for (int i = 4; i <= n; ++i) {
		for (int j = i-3; j >= 3; --j)
			dp[i] += dp[j];
		dp[i] ++;
		dp[i] %= mod;
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;

int main()
{
    string s,s1;
    cin >> s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i] == 'B')
        {
            if(!s1.empty())
                s1.pop_back();
        }
        else
            s1 += s[i];
    }

    cout << s1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

int main(){
	string S;cin>>S;
  int L = 0;
  int ok_0 = 0; //0101...
  int ok_1 = 0; //1010...

  for(char x: S){
    int c = x-'0';
    if(L%2==c)ok_0++;
    if(L%2!=c)ok_1++;
    L++;
  }

  int err = L - max(ok_0, ok_1);

  cout<<err<<endl;
}

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

int main() {
  int A, P;
  cin >> A >> P;

  cout << (3 * A + P) / 2 << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>

int solve(int a, int b, int c) {
	int n = 0;
	for (int x = a; x <= b; ++x) {
		if (c % x == 0)
			++n;
	}
	return n;
}

int main(void) {
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << solve(a, b, c) << std::endl;
	return 0;
}

Measured memory_bytes: 3108
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}


// go だと固定長配列とか辛いので無理だった
type Queue struct {
	arr [] int
	back int
}
func NewQueue() Queue {
	return Queue{make([]int, 0, 10000), 0}
}

func (this *Queue)Enque(i int) {
	this.arr = append(this.arr, i)
}

func (this *Queue)Front() int {
	return this.arr[0]
}

func (this *Queue) Dequeue() {
	if 0 < len(this.arr) {
		this.arr = this.arr[1:]
	}
}

func (this *Queue) Empty() bool {
	return 0 == len(this.arr)
}



func main() {
	var n int
	var q int

	fmt.Scanf("%d %d", &n, &q)
	Queues := make([]Queue, n)
	for i := 0; i < n; i++ {
		Queues[i] = NewQueue()
	}
	lines, _ := ReadLongLines(q)
	for _, line := range lines {
		args := strings.Split(line, " ")
		cmd := args[0]
		switch cmd {
		case "0":
			t, _ := strconv.Atoi(args[1])
			x, _ := strconv.Atoi(args[2])
			// fmt.Printf("enque %d < %d\n", t, x)
			Queues[t].Enque(x)
		case "1":
			t, _ := strconv.Atoi(args[1])
			// fmt.Printf("front %d\n", t)
			if !Queues[t].Empty() {
				fmt.Println(Queues[t].Front())
			}
		case "2":
			t, _ := strconv.Atoi(args[1])
			// fmt.Printf("dequeue %d\n", t)
			Queues[t].Dequeue()
		}
	}
}


Measured memory_bytes: 95280
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

// O(√n) 
bool primeNumber(int n){  
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true; 
  cin >> n;
  VL a(n),b(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  for(int i=0; i<n; i++){
    ans = 0;
    for(int k=0; k<=i;k++){
      ans += a[k];
    }
    for(int j = i; j<n; j++){
      ans += b[j];
    }
    chmax(Max,ans);
  }
  pri(Max);
  return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long N;
    cin>>N;

    long long i, j;
    for (long long k = 1; k <= sqrt(N); ++k)
        if (N % k == 0)
            i = k;
    j = N / i;

    long long moves = (i-1) + (j-1);
    cout<<moves<<"\n";



    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int c[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  c[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(c[v]==WHITE){
      dfs_visit(v);
    }
  }
  c[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) c[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(c[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();
  
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    ll mid = ll(n/4) * 2;
    ll zan = m;
    REP(i, mid/2){
        cout << mid-i << " " << i+1 << endl;
        zan--;
        if (zan == 0){
            break;
        }
    }
    if (n%2 == 0){
        n--;
    }
    REP(i, zan){
        cout << n-i << " " << mid+1+i << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<"Yes"<<endl;
    cout<<2<<endl;
    cout<<1<<" "<<1<<endl;
    cout<<1<<" "<<1<<endl;
    return 0;
  }
  bool f=false;
  int i;
  for(i=1;i*(i+1)<=n*2;i++){
    if(i*(i+1)==n*2){
      f=true;
      break;
    }
  }
  if(!f){
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;
  cout<<i+1<<endl;

  vector<vector<int> > ans(i+1,vector<int>(i));

  int np=1;
  for(int j=0;j<i;j++){
    for(int k=0;k<i-j;k++)ans[j][j+k]=np+k;
    for(int k=0;k<i-j;k++)ans[j+k+1][j]=np+k;
    np+=i-j;
  }

  for(int j=0;j<i+1;j++){
    cout<<i<<" ";
    for(int k=0;k<i;k++){
      cout<<ans[j][k];
      if(k!=i-1)cout<<" ";
    }
    cout<<endl;
  }

}


Measured memory_bytes: 2944
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
#define dbg(x)  cerr << #x << " = " << x << endl;
const int M=100005;
const int mod=1000000007;
const double pi = acos(-1.0);
using namespace std;
int32_t main(){

    #ifndef ONLINE_JUDGE 
        freopen("in.txt", "r", stdin); 
        freopen("out.txt", "w", stdout); 
    #endif 

    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int r=0,w=0;
        for(int i=0;i<n;i++){
            if(s[i]=='R'){
                r++;
            }
            else{
                w++;
            }
        }
        int ans=min(r,w),count=0;
        for(int i=0;i<r;i++){
            if(s[i]=='W'){
                count++;
            }
        }
        ans=min(ans,count);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
long long ans = 0, s = 0, ans2 = 0, s2 = 0;

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		long long temp;
		cin >> temp;
		s += temp;
		s2 += temp;
		if(i % 2 == 1)
		{
			if(s <= 0)
			{
				ans += abs(s) + 1;
				s = 1;
			}
		}
		else
		{
			if(s >= 0)
			{
				ans += abs(s) + 1;
				s = -1;
			}
		}
		if(i % 2 == 0)
		{
			if(s2 <= 0)
			{
				ans2 += abs(s2) + 1;
				s2 = 1;
			}
		}
		else
		{
			if(s2 >= 0)
			{
				ans2 += abs(s2) + 1;
				s2 = -1;
			}
		}
	}
	cout << min(ans, ans2);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
string s1,s2,s3;
cin>>s1;
cin>>s2;
cin>>s3;
char ch1=s1[0];
ch1=ch1-32;
char ch2=s2[0];
ch2=ch2-32;
char ch3=s3[0];
ch3=ch3-32;
cout<<ch1<<ch2<<ch3;
return 0;
}


Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, k = map(int, input().split())

    heights = list(map(int, input().split()))

    count = 0

    for h in heights:
        if h >= k:
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12556