akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
int N,a[300005][2],Ans=2e9;
char s[300005];
int main(){
	scanf("%d%s",&N,s+1);
	for (int i=1;i<=N;++i) a[i][0]=a[i-1][0]+(s[i]=='W'),a[i][1]=a[i-1][1]+(s[i]=='E');
	for (int i=1;i<=N;++i)
		Ans=min(Ans,a[i-1][0]+a[N][1]-a[i][1]);
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
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;
    ll ans = 0;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        ans += abs(a[i]);
    }

    int minus = 0;
    ll m = 1 << 30;
    rep(i, n){
        if(a[i] < 0){
            minus++;
        }
        if(a[i] == 0){
            minus = 0;
            break;
        }
        m = min(m, abs(a[i]));
    }
    if(minus%2 == 0){
        cout << ans << endl;
    }
    else{
        cout << ans - 2*m << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
s = input()
exp = []

def dfs(pos, tot):
    global exp
    if pos == 3:
        return tot == 7

    exp.append("+")
    if dfs(pos + 1, tot + int(s[pos+1])):
        return True
    exp.pop()
    exp.append("-")
    if dfs(pos + 1, tot - int(s[pos+1])):
        return True
    exp.pop()

def main():
    ok = 0
    if dfs(0, int(s[0])):
        for c, i in zip(s, exp):
            print(c, end="")
            print(i, end="")
        print(s[3] + "=7")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
// こっちはなぜかACになる
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

int main()
{
	int N, M;
	char U[256][11], T[256][11];
	bool f, isClosed;

	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%s", U[i]);

	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%s", T[i]);
	}
	for (int i = 0; i < M; i++) {
		f = false;
		for (int j = 0; j < N; j++)
			if (!strcmp(T[i], U[j])) {
				f = true;
				isClosed = !isClosed;
				printf(isClosed ? "Opened by" : "Closed by");
				break;
			}
		if (!f)
			printf("Unknown");
		printf(" %s\n", T[i]);
	}

	return 0;
}



Measured memory_bytes: 2116
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];
ll vis[N];
std::vector<ll> v[N], vv;

void dfs(ll node){
	vis[node] = 1;
	for(auto i : v[node]){
		if(!vis[i]){
			dfs(i);
		}
	}
	vv.push_back(node);
}

void solve(){
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i){
		ll a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	for (int i = 1; i <= n; ++i){
		if(!vis[i]){
			dfs(i);
		}
	}
	reverse(vv.begin(), vv.end());
	std::map<ll, ll> mp;
	for (int i = 0; i < vv.size(); ++i){
		for(auto j : v[vv[i]]){
			mp[j] = max(mp[j], mp[vv[i]] + 1);
		}
	}
	ll mx = 0;
	for (int i = 1; i <= n; ++i){
		mx = max(mx, mp[i]);
	}
	cout << mx;
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// Radhe Radhe

Measured memory_bytes: 20920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using T  = tuple<int,int,int>;

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

Measured memory_bytes: 4048
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r, p);
  if(T[u].l != NIL) calcDepth(T[u].l, p + 1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 6448
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			long n = long.Parse(Console.ReadLine());

			var monay = new List<long>();
			monay.Add(1);

			long temp = 6;
			while (temp <= n) {
				monay.Add(temp);
				temp *= 6;
			}

			temp = 9;
			while (temp <= n) {
				monay.Add(temp);
				temp *= 9;
			}

			var dp = new long[n + 1];
			for (int i = 0; i < n + 1; i++) {
				dp[i] = long.MaxValue;
			}

			dp[0] = 1;
			foreach (var m in monay) {
				dp[m] = 1;
			}

			for (int i = 0; i < n; i++) {
				if (dp[i] == long.MaxValue) {
					continue;
				}

				foreach (var m in monay) {
					long next = i + m;
					if (next <= n) {
						dp[next] = Math.Min(dp[next], dp[i] + 1);
					}
				}
			}

			long ans = dp[n];
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 28316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int h[5];
  while(cin>>h[0],h[0]){
    cin>>h[1]>>h[2]>>h[3]>>h[4];
    for(int i=0;i<5;i++){
      bool f1=0,f2=0;
      for(int j=0;j<5;j++){
	if(i==j) continue;
	if(h[i]==1){
	  f1|=h[j]==2;
	  f2|=h[j]==3;
	}
	if(h[i]==2){
	  f1|=h[j]==3;
	  f2|=h[j]==1;
	}
	if(h[i]==3){
	  f1|=h[j]==1;
	  f2|=h[j]==2;
	}
      }
      cout<<(f1|f2?f1+f2*2:3)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define ll long long
using namespace std;

int main() {
    string S; cin >> S;
    int n = S.size() - 1;

    ll ans = 0;
    ll tmp = 0;
    for (int bit=0; bit<(1<<n); bit++) {
        tmp = S.at(0) - '0';
        for (int i=0; i<n; i++) {
            if (bit & 1<<i) {
                ans += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + (S.at(i+1) - '0');
        }
        ans += tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define for(i,s,n) for(int i=s;i<n;i++) 
#define vii vector<int>
signed main()
{
        fast;
	int t = 1,n;
	//cin>>t;
	while (t--)
	{
		cin >> n;
        cout<<(!n)<<endl;
	}
}

Measured memory_bytes: 3616
# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1

def alph_to_num(s):
  return ord(s)-ord('a')

def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 285784
#include<stdio.h>

int main(void){
  int n,i,j,cnt;

  while(scanf("%d",&n),n){
    for(i=1,cnt=0;i<n;i++)
      for(j=i+1;j<n;j++)
	if((j*(j+1)-i*(i-1))/2==n)cnt++;
	
    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int value[100];
int weight[100];
int memo[100][10001];
int max_value(int k, int w) {
  if(k == -1) return 0;

  int &res = memo[k][w];
  if(res != -1) return res;

  if(w >= weight[k]) res = max(res, value[k] + max_value(k, w - weight[k]));
  res = max(res, max_value(k - 1, w));
  // cerr << "k = " << k << ", w = " << w << ", res = " << res << endl;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  memset(memo, -1, sizeof(memo));
  int n, W; cin >> n >> W;
  for(int i = 0; i < n; i++) {
    cin >> value[i] >> weight[i];
  }
  cout << max_value(n - 1, W) << endl;
}

Measured memory_bytes: 5728
#include <iostream>
//#define int long long
#define SIZE 101
#define VALUE 10001
//#define _DEBUG
using namespace std;
int N, W, Vs[SIZE], Ws[SIZE] , T[SIZE][VALUE];
int solve(){
    for(int i=0; i<=N; i++){
        for(int w=0; w<=W; w++){
            if(i==0 || w==0){
                T[i][w] = 0;
            }else if(w<Ws[i-1]){
                T[i][w] = T[i-1][w]; 
            }else{
                T[i][w] = max(T[i-1][w], max(T[i-1][w-Ws[i-1]], T[i][w-Ws[i-1]])+Vs[i-1]);
            }
        }
    }
#ifdef _DEBUG
    for(int i=0; i<=N; i++){
        if(i>0)cout << Vs[i-1] << "," << Ws[i-1] << "\t";
        else cout << "\t";
        for(int w=0; w<=W; w++){
            cout << T[i][w] << " ";
        }cout << endl;
    }
#endif
    return T[N][W];
}
signed main(){
    while(cin >> N >> W){
        for(int i=0; i<N; i++){
            cin >> Vs[i] >> Ws[i];
        }
        cout << solve() << endl;
    }
}


Measured memory_bytes: 7064
#include <iostream>

using namespace std;

int main()
{
    unsigned long long A, B, C, D, numC, numD, numCD;
    cin >> A >> B >> C >> D;

    // Cで割り切れる
    numC = B / C - (A - 1) / C;

    // Dで割り切れる
    numD = B / D - (A - 1) / D;

    // CでもDでも割り切れる
    if(C < D){
        int temp = C;
        C = D;
        D = temp;
    }

    unsigned long long r = C % D;
    unsigned long long prodCD = C*D, prod;
    while(r != 0){
        C = D;
        D = r;
        r = C % D;
    }
    prod = prodCD / D;
    numCD = B / prod - (A - 1) / prod;

    cout << B - A + 1 - numC - numD + numCD << endl;
}

Measured memory_bytes: 256
(let ((s (read-line))
    (n 0))
    (if (not (zerop (rem (length s) 2)))
    (progn
        (setq s (subseq s 0 (- (length s) 1)))
        (setq n (length s))
        (loop for _ below (/ n 2) do
            (if (string= (subseq s 0 (/ (length s) 2)) (subseq s (/ (length s) 2) (length s)))
                (progn
                (format t "~D~%" (length s))
                (return)
                )
                (setq s (subseq s 0 (- (length s) 2)))
            )
        )
    )
    (progn 
        (setq s (subseq s 0 (- (length s) 2)))
        (setq n (length s))
        (loop for _ below (/ n 2) do
            (if (string= (subseq s 0 (/ (length s) 2)) (subseq s (/ (length s) 2) (length s)))
                (progn
                (format t "~D~%" (length s))
                (return)
                )
                (setq s (subseq s 0 (- (length s) 2)))
            )
        )

    )
    )
)

Measured memory_bytes: 24508
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

vector<int> E[100010];
vector<int> res;
int o[100010];
vector<pair<int,int> > bridge;


int dfs(int i,int prev,int &n) {
    if(o[i]) return o[i];

    int M=n;
    o[i] = n++;
    for(vector<int>::iterator it = E[i].begin(); it != E[i].end(); it++) {
        if(prev == *it) continue;
        if(o[i] < o[*it]) continue;

        int res = dfs(*it, i, n);
        M = min(M, res);

        if(o[i] < res) bridge.push_back(pair<int,int>(min(i,*it),max(i,*it)));
    }
    return M;
}

int main(void) {
	int v,e;
	scanf("%d%d",&v,&e);
	for(int i=0; i<e; i++) {
		int s,t;
		scanf("%d%d",&s,&t);
		E[s].push_back(t);
		E[t].push_back(s);
	}

    int n=1;
	dfs(0,-1,n);

    sort(bridge.begin(), bridge.end());

    for(vector<pair<int,int> >::iterator it = bridge.begin(); it != bridge.end(); it++) {
        printf("%d %d\n",it->first,it->second);
    }
    return 0;
}

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

const int MAX = 1e5+10;

int main() {
    int n;
    cin >> n;
    int a[n], maxv = -1, x[MAX] = {};
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        maxv = max(maxv, a[i]);
        x[a[i]]++;
    }
    int ans = -1;
    for (int i = 1; i < MAX-1; i++) {
        ans = max(ans, x[i-1] + x[i] + x[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	char C;
	cin >> C;
	printf("%c\n", C+1);
	return 0;
}



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

int main() {
    ll A, B, C;
    cin >> A >> B >> C;

    bool flag = false;
    FOR(i, 1, B){
        if((A*i)%B == C){
            cout << "YES" << endl;
            flag = true;
            break;
        }
    }

    if (flag == false){
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
    int a[52] = {0};
    char b[4] = {'S','H','C','D'};
    int d, n;
    char c;
    int e, f;
 
    scanf("%d", &n);
    for (f = 0; f < n; f++){
        scanf(" %c %d", &c, &d);
        for (e = 0; b[e] != c; e++){
            d += 13;
        }
        a[d - 1] = 1;
    }
 
    for (f = 0; f < 4; f++){
        for (e = 0; e < 13; e++) {
            if (a[f * 13 + e] == 0) {
                printf("%c %d\n", b[f], e + 1);
            }
        }
    }
 
    return 0;
}



Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int d = a + b + c;
  if(d > 21){
    cout << "bust\n";
  }
  else{
    cout << "win\n";
  }
}


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

int main(void){
   int n,y;
   cin >> n >> y;
   int res_i = -1,res_j=-1,res_k=-1;
   for(int i=0;i<=n;i++){
       for(int j=0;j<=n-i;j++){
           int money = 10000*i+5000*j+1000*(n-i-j);
           if(money == y){
               res_i = i;
               res_j = j;
               res_k = n-i-j;
           }
       }
   }
   cout << res_i << " " << res_j << " " << res_k << endl;
}


Measured memory_bytes: 256
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#include<ctype.h>
typedef long long int ll;
#define  endl "\n"
using namespace std;
#define MAXN 1000005
#define X first
#define Y second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,t;

int main()
{
    fastio;
    cin>>n;
vector< ll > a(n);
for(i=0;i<n;i++) cin>>a[i];
ll ans=0,c,b;
for(ll k=0;k<62;k++){
c=0; b=0;
for(i=0;i<n;i++){
if((a[i]&(1ll<<k))==0) b++;
else c++;
}
ans=ans+((((c * b)%MOD) * ((1ll<<k)%MOD))%MOD);
ans%=MOD;
}
cout<<ans<<endl;
}


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

int main(){
    int a, b, t;
    while(1){
        cin >> a >> b;
        if (a==0 && b==0) break;
        if (a > b) {
            t = a; a = b; b = t;
        }
        cout << a << " " << b << endl;
    }
    return 0;
}

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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val;
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int mod = 1e9 + 7;
const int INF = 1e9;

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

	map<int, int> mp;

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

	int ans = 0;
	each(i, mp) {
		ans = max(i.second, ans);
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int ret = 0;
  for(int i = Z; i <= X; i += Z) {
    if(i + Y + Z > X) break;
    ++ret;
    i += Y;
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main(n):
  if n%2 != 0:
    # odd
    return 0
  else:
    # even
    count_5 = 0
    for i in range(1, 100):
      denominator = (5**i)*2
      if n < denominator:
        break
      count_5 += (n // denominator)
    return count_5

if __name__=='__main__':
  n = int(input())
  print(main(n))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vvi a(n, vi(n));
    rep(i, n) rep(j, n) cin >> a[i][j];
    vector<ll> dp(1 << n);
    vi concerned;
    for(int b = 1; b < 1 << n; b++) {
        concerned.resize(0);
        rep(k, n) {
            if (b >> k & 1) {
                concerned.push_back(k);
            }
        }
        int sz = concerned.size();
        ll tot = 0;
        rep(i, sz) rep(j, i) {
            int x = concerned[i], y = concerned[j];
            tot += a[x][y];
        }
        chmax(dp[b], tot);
        int r0 = 1 << concerned.back();
        concerned.pop_back(); sz--;
        for(int c = 1; c < 1 << sz; c++) {
            int l = 0, r = r0;
            rep(i, sz) {
                int k = concerned[i];
                if (c >> i & 1) l |= 1 << k;
                else r |= 1 << k;
            }
            chmax(dp[b], dp[l] + dp[r]);
        }
    }
    cout << dp.back() << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define w cout 
#define e '\n'

using namespace std;

const int N = 1e6 + 5;
ll dd[3002][3002];

int main(){
	ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
	ll n;
	cin >> n;
	ll arr[n + 1];
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
	}

	for(int L = n ;  L >= 1 ; L --) {
		for(int R = L ; R <= n ; R ++) {
			if(L == R) {
				dd[L][R] = arr[L];
			} else {
				dd[L][R] = max(arr[L] - dd[L + 1][R] , arr[R] - dd[L][R - 1]);
			}
		}
	}

	w << dd[1][n];

}

Measured memory_bytes: 70016
#include<stdio.h>
#define N 10

int CalculateScore(void);

int main(){
  int w, k;

  w = CalculateScore();
  k = CalculateScore();

  printf("%d %d\n", w, k);

  return 0;
}


int CalculateScore(void){
  int i, score, first=0, second=0, third=0;

  for(i=0; i<N; i++){
    scanf("%d", &score);

    if(score > first){
      third = second;
      second = first;
      first = score;
    }else if(score > second){
      third = second;
      second = score;
    }else if(score > third){
      third = score;
    }
  }

  return (first + second + third);
}

Measured memory_bytes: 0
st, gl = map(int, input().split())
ans = 0

if gl == -st:
  ans = 1
elif st >= 0:
  if gl > st:
    ans = gl - st
  elif gl < -st:
    ans = - st - gl + 1
  elif gl > 0:
    ans = st - gl + 2
  else:
    ans = gl + st + 1
elif st < 0:
  if gl > -st:
    ans = gl + st + 1
  elif gl < st:
    ans = st - gl + 2
  elif gl > 0:
    ans = - st - gl + 1
  else:
    ans = gl - st
  
print(ans)


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

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  vector<vector<int>> dp1(N + 1, vector<int>(T));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < T; j++) {
      dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
      int k = j + A[i];
      if (k < T) {
        dp1[i + 1][k] = max(dp1[i + 1][k], dp1[i][j] + B[i]);
      }
    }
  }

  vector<vector<int>> dp2(N + 1, vector<int>(T));
  for (int i = N - 1; i >= 0; i--) {
    for (int j = 0; j < T; j++) {
      dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
      int k = j + A[i];
      if (k < T) {
        dp2[i][k] = max(dp2[i][k], dp2[i + 1][j] + B[i]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a = 0;
    for (int j = 0; j < T; j++) {
      a = max(a, dp1[i][j] + dp2[i + 1][T - 1 - j]);
    }
    a += B[i];
    ans = max(ans, a);
  }
  cout << ans << endl;

  return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:
ll fact[1000005], fact_inv[1000005];

//Prototype Declarations:
int gcd(int, int);

ll power(ll a, ll b) {
    ll res = 1;
    while(b > 0) {
        if(b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

ll comb(ll n, ll r) {
    return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

//================ Main Loop ================
int main() {
    int x, y;
    cin >> x >> y;
    ll ans = 1;
    if(min(x, y) < (ceil((x + y) / 3.0)) || (x + y) % 3 != 0) {
        ans = 0;
    } else {
        int n = (x + y) / 3;

        fact[0] = 1;
        rep(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
        fact_inv[n] = power(fact[n], MOD - 2);
        for(int i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
        ans = comb(n, (min(x, y) - (x + y) / 3));
    }
    cout << ans % MOD << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 14592
//Author: Kudo_kun
//AtCoder_132
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize "-O3"
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(), v.end()
typedef int64_t ll;
typedef long double ld;

const int N = (1e5 + 5);
const long MOD = (1e9 + 9);
const long INF = (1e18 + 18);
int n, c1, c2;
vector<int> g;


int main()
{
	FastIO;
	cin >> n;
	for(int i = 0, u; i < n; i++)
		cin >> u, g.push_back(u);
	sort(all(g));
	int lo = 0, hi = g.size()-1;
	if(n%2 == 0)
	{
		int m = (n/2 - !bool(n % 2)), p = m+1;
		cout << g[p]-g[m] << endl;
	}
	else
		cout << "0\n";
	
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Monster {
    ll x, h;
};

std::istream &operator>>(std::istream &in, Monster &o) {
    cin >> o.x >> o.h;
    return in;
}

string N;
vector<int> n;  //Nの各桁の数字を格納するベクター
int dp[200][2][5];

int main() {
    cin >> N;

    int k;
    cin >> k;

    //ベクターnを構成
    for (auto a : N) {
        n.push_back(a - '0');
    }
    int l = N.size();  //nの長さ

    dp[0][0][0] = 1;  //初期条件。他は0で初期化されている
    for (int i = 0; i < l; i++) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j < 4; j++) {
                for (int x = 0; x <= (smaller ? 9 : n[i]); x++) {
                    dp[i + 1][smaller || x < n[i]][j + (x != 0)] += dp[i][smaller][j];
                }
            }
        }
    }

    cout << dp[l][0][k] + dp[l][1][k] << endl;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a == 5 && b == 5 && c == 7)||(a == 5 && b == 7 && c == 5)||(a == 7 && b == 5 && c == 5)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void){
  int N,K,m,t,l,j;
  double p,sum = 0.0,n;
  cin >> N >> K;
  n = N;
  for(int i = 1;i <= N;i++){
    l = i;
    while(true){
      if(l >= K){
        break;
      }
      l *= 2;
      j++;
    }
    p = 1.0/n;
    for(int i = 0;i < j;i++){
      p *= (double)1/2.0;
    }
    sum += p;
    j = 0;
  }
  printf("%.15lf",sum);

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int mod;
		int i;
		if(A >= C) {
			mod = (A-C)%B;
			i=2;
		}else {
			mod = (((C/A) + 1)*A - C)%B;
			i = ((C/A) + 2);
		}
		int mod_i = -1;
		while(mod != mod_i) {
			mod_i = (A*i - C)%B;
			if(mod_i == 0) {
				System.out.println("YES");
				return;
			}else {
				i++;
			}
		}
		System.out.println("NO");
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
 
int main(){
	int N, k, l, i;
	scanf("%d", &N);
	if(N == 3){
		printf("2 5 63\n");
		return 0;
	}
	if(N <= 15002){
		k = N - 2;
		l = 2;
	}
	else{
		if(N % 2 == 1){
			k = 14999;
			l = N - k;
		}
		else{
			k = 15000;
			l = N - k;
		}
	}
	if(k % 3 == 1){
		for(i = 1; i <= (k / 3) * 3; i++){
			printf("%d ", 2 * i);
		}
		printf("%d ", 2 * (k / 3 + 1) * 3);
	}
	else{
		for(i = 1; i <= k; i++){
			printf("%d ", 2 * i);
		}
	}
	for(i = 1; i <= l; i++){
		printf("%d ", 6 * i - 3);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int r = sc.nextInt();
		int c = sc.nextInt();
		sc.nextLine();

		int[][] mat = new int[r+1][c+1];

		for (int i=0; i < r; i++) {

			String[] data = sc.nextLine().split(" ");

			for (int j=0; j < c; j++) {
				mat[i][j] = Integer.parseInt(data[j]);

				mat[i][c] += mat[i][j];
				mat[r][j] += mat[i][j];
			}
			mat[r][c] += mat[i][c];

		}

		for (int i=0; i<r+1; i++) {

			for (int j=0; j<c; j++) {
				System.out.print(mat[i][j] + " ");
			}
			System.out.print(mat[i][c] + "\n");

		}
	}

}

Measured memory_bytes: 33144
x, y, a, b, c = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i).max(x)
qs = gets.split.map(&:to_i).max(y)
rs = gets.split.map(&:to_i)

puts [*ps, *qs, *rs].max(x + y).inject(:+)


Measured memory_bytes: 31888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

 /*Please dont change namespace, Dcoder 
 and class must not be public*/

 //Compiler version 4.0, .NET Framework 4.5

 namespace Dcoder
 {
 public class Program
 {
 public static void Main(string[] args)
 {
 
 string s = Console.ReadLine();
  if(s[0]==s[1] && s[1]==s[2])
         {
             Console.WriteLine("Yes");
         }
  else if(s[1]==s[2] && s[2]==s[3])
           {
             Console.WriteLine("Yes");
           }
  else
    {
           Console.WriteLine("No");
   
         }
 }
}
}
    

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
main(){
    using namespace std;
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &&i: a)cin >> i;
    vector<int> b(n);
    vector <int> ba(n);
    for (auto &&i: b)cin >> i;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
 
    for(int i = 0; i < n; i++) {
        auto it =  lower_bound(a.begin(), a.end(), b[i]);
        ba[i] = distance(a.begin(), it);
    }
    for(int i = 0; i < n - 1; i++) ba[i + 1] += ba[i];
    int c;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> c;
        auto it = lower_bound(b.begin(), b.end(), c);
        int bi = distance(b.begin(), it);
        if(bi != 0)sum += ba[bi - 1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_VAL_MAX		100005									// 最大値

// 内部変数
static FILE *szpFpI;											// 入力
static int siSum;												// 合計価格
static int si1Buy[D_VAL_MAX];									// 買い方

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 買い方 - セット
int
fSetBuy(
	int piVal					// <I> 単価
)
{
	int i;

	for (i = 0; i <= siSum - piVal; i++) {
		if (si1Buy[i] == D_ON) {
			si1Buy[i + piVal] = D_ON;
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// 合計価格 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siSum);

	// 買い方 - セット
	si1Buy[0] = D_ON;
	fSetBuy(100);
	fSetBuy(101);
	fSetBuy(102);
	fSetBuy(103);
	fSetBuy(104);
	fSetBuy(105);

	return si1Buy[siSum];
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Buy, 0, sizeof(si1Buy));							// 買い方

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 2e5 + 10;
const int P = 998244353;

int n, q, _pow10[MAXN], inv[MAXN];

int getsum(int k) {
    return 1ll * ((_pow10[k] - 1) % P + P) % P * inv[9] % P;
}

struct Segment_Tree {
    #define mid ((l + r) >> 1)
    #define ls k << 1, l, mid
    #define rs k << 1 | 1, mid + 1, r
    struct Node { int val, tag; } t[MAXN << 2];
    void pushup(int k) { t[k].val = (t[k << 1].val + t[k << 1 | 1].val) % P; }
    void pushdown(int k, int l, int r) {
        if (t[k].tag != -1) {
            t[k << 1].tag = t[k].tag, t[k << 1 | 1].tag = t[k].tag;
            t[k << 1].val = 1ll * t[k].tag * getsum(mid - l + 1) % P * _pow10[n - mid] % P;
            t[k << 1 | 1].val = 1ll * t[k].tag * getsum(r - mid) % P * _pow10[n - r] % P;
            t[k].tag = -1;
        }
    }
    void build(int k, int l, int r) {
        t[k].tag = -1;
        if (l == r) return t[k].val = _pow10[n - r], void();
        build(ls), build(rs);
        pushup(k);
    }
    void modify(int k, int l, int r, int ql, int qr, int val) {
        if (ql <= l && r <= qr) {
            t[k].tag = val;
            t[k].val = 1ll * val * getsum(r - l + 1) % P * _pow10[n - r] % P;
            return ;
        }
        pushdown(k, l, r);
        if (ql <= mid) modify(ls, ql, qr, val);
        if (qr > mid) modify(rs, ql, qr, val);
        pushup(k);
    }
} sgt;

int main() {
    _pow10[0] = 1;
    inv[0] = inv[1] = 1;
    rep(i, 2, MAXN - 1) inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
    rep(i, 1, MAXN - 1) _pow10[i] = 1ll * _pow10[i - 1] * 10 % P;
    IO::read(n), IO::read(q);
    sgt.build(1, 1, n);
    rep(i, 1, q) {
        int l, r, val;
        IO::read(l), IO::read(r), IO::read(val);
        sgt.modify(1, 1, n, l, r, val);
        printf("%d\n", sgt.t[1].val);
    }
    return 0;
}

Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;
int dp[15];

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

    fill(dp,dp+15,-INF);
    dp[0]=0;

    int x;
    cin >>x;
    while(x--)
    {
        string s;
        int v;
        cin >>s >>v;
        if(s!="D") continue;
        for(int i=D-1; i>=0; --i) dp[i+1] = max(dp[i+1],dp[i]+v);
    }

    cin >>x;
    while(x--)
    {
        string s;
        int v;
        cin >>s >>v;
        if(s!="DD") continue;
        for(int i=D-1; i>=0; --i)dp[i+2] = max(dp[i+2],dp[i]+v);
    }

    int ans = 0;
    rep(i,D+1) ans = max(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

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

int main() {
    
    int n;
    cin >> n;
    set<string> ar;
    for (int i=0; i<n; i++) {
		string s;
		cin >> s;
		ar.insert(s);
	}
	if (ar.size() == 3) cout << "Three" << endl;
	else cout << "Four" << endl;
	
}


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

using namespace std;
typedef long long ll;

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

int main()
{

    int n;
    cin >> n;

    cout << (n + 1000 - 1) / 1000 * 1000 - n << '\n';
    return 0;
}


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

int main()
{
  ll n, k;
  cin >> n >> k;

  ll waru = n % k;

  cout << min(waru, abs(waru - k));

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	vector<vector<lint>> data(8, vector<lint>(N, 0));

	for (int i = 0; i < N; i++)
	{
		lint a, b, c;
		cin >> a >> b >> c;
		for (int j = 0; j < (1 << 3); j++)
		{
			data[j][i] += (j & (1 << 0)) ? a : -a;
			data[j][i] += (j & (1 << 1)) ? b : -b;
			data[j][i] += (j & (1 << 2)) ? c : -c;
		}
	}

	for (int i = 0; i < 8; i++)
	{
		sort(all(data[i]), greater<lint>());
	}

	lint ans = -INF64;
	for (int i = 0; i < 8; i++)
	{

		lint value = 0;
		for (int j = 0; j < M; j++)
		{
			value += data[i][j];
		}
		ans = max(ans, value);
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 384
s = input()
ans = 'Yes'
for i in range(len(s)):
    if (i + 1) % 2 != 0:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            ans = 'No'
            break
    else:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    char s[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>s[i];
        s[k-1]=tolower(s[k-1]);

    }
    for (int i = 0; i < n; ++i)
    {
     cout<<s[i];
    } 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll al[4];
string str;
int main(void){
    // Your code here!
    cin >> str;
    for (ll i = 0; i < str.length(); i++) {
        if (str[i] == 'N') al[0]++;
        if (str[i] == 'W') al[1]++;
        if (str[i] == 'S') al[2]++;
        if (str[i] == 'E') al[3]++;
    }
    if ((al[0] == 0 && al[2] > 0) || (al[0] > 0 && al[2] == 0) || (al[1] == 0 && al[3] > 0) || (al[1] > 0 && al[3] == 0)) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
int main(void)
{
  char a[11];
  char b[11];
  int i,result;
  i=result=0;
  scanf("%s",&a);
  scanf("%s",&b);
  while(a[i]!='\0')
  {
    if(a[i]!=b[i])
    {
      result=1;
    }
    i++;
  }
  if(result==0)
  {
    printf("Yes");
  }
  else 
  {
    printf("No");
  }
}

Measured memory_bytes: 1724
use std::io::*;
use std::str::FromStr;

use std::collections::HashMap;

fn main() {
	let n: i32 = read();
	let mut h = HashMap::new();
	let mut s: String;
	let mut max: i32 = 0;
	for _ in 0..n {
		s = read();
		let count = h.entry(s).or_insert(0);
		*count += 1;
		if *count > max { max = *count; }
	}
	
	let mut v = Vec::new();
	for (key, val) in h.iter() {
		if *val == max {
			v.push(key);
		}
	}
	v.sort();
	for i in &v {
		println!("{}", i);
	}
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



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

using namespace std;

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

  vector<int> answer(n);

  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    answer[m - 1] = i + 1;
  }

  for (int i : answer) {
    cout << i << endl;
  }

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int flag=0;
    if(s.at(2)==s.at(3)){
        if(s.at(4)==s.at(5)){
            flag=1;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  int x[n];
  double sum = 0;
  for(int i=0; i<n; i++){
    cin >> x[i]; 
    sum += x[i];
  }
  //ll m = 100000000;
  int p = round(sum/n);
  int ans = 0;
  for(int i=0; i<n; i++){
    ans += (x[i]-p)*(x[i]-p);
  }
  cout << ans << endl;
}
  
  
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long H, W;
    vector<vector<char>> M;

    cin >> H >> W;
    M.push_back(vector<char>(W + 1, '.'));
    for (long long i = 0; i < H; i++)
    {
        vector<char> tv{'.'};
        for (long long j = 0; j < W; j++)
        {
            char t;
            cin >> t;
            tv.push_back(t);
        }
        M.push_back(tv);
    }

    vector<vector<long long>> dp(H + 1, vector<long long>(W + 1, INF));
    dp[1][0] = 0;
    dp[0][1] = 0;
    for (long long i = 1; i < H + 1; i++)
    {
        for (long long j = 1; j < W + 1; j++)
        {
            if (M[i - 1][j] == M[i][j])
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            else
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            if (M[i][j - 1] == M[i][j])
                dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            else
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
        }
    }

    cout << (dp[H][W] + 1) / 2 << endl;
}

Measured memory_bytes: 384
const main = input =>{

    const arr = input.split("\n");
    const yohou = arr[0].split("");
    const real = arr[1].split("");
    var result = 0;
    for(var i=0; i<3; i++){
        if(yohou[i] === real[i]){
            result ++;
        }
    }
    
    console.log(result);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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


void make_table(vector<vector<set<int>>> &dp, bool c[55][35], int n, int m) {
    rep(j,m) {
        vector<int> tmp;
        rep(i,n) if (c[i][j]) for (auto &&x: dp[i][j]) tmp.push_back(x);
        rep(i,n) if (c[i][j]) for (auto &&e: tmp) dp[i][j].insert(e);
        rep(i,n) for (auto &&e: dp[i][j]) dp[i][j+1].insert(e);
    }
    return;
}

int solve(vector<vector<set<int>>> &dp, bool c[55][35], int n, int m) {
    rep(j,m) rep(i,n) if (c[i][j]) if (dp[i][j].size() == n) return j+1;
    return -1;
}

int main() {
    int n,x,y;
    int m = 32;
    while (cin >> n, n) {
        bool c[55][35];
        rep(i,n) rep(j,m) c[i][j] = false;
        rep(i,n) {
            cin >> x;
            rep(j,x) {
                cin >> y; c[i][y-1] = true;
            }
        }
        vector<vector<set<int>>> dp(n);
        rep(i,n) dp[i].resize(35);
        rep(i,n) rep(j,m) if (c[i][j]) dp[i][j].insert(i);
        make_table(dp,c,n,m);
        cout << solve(dp,c,n,m) << endl;
    }
}


Measured memory_bytes: 6808
//https://atcoder.jp/contests/abc124/tasks/abc124_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// H_0 < H_1, ..., H_{i-1} < H_i check
vector<bool> view(20);
void HeightCheck(vector<int> &H){
    int tmp = H[0];
    for(int i = 0; i < (int)H.size(); i++){
        if(tmp <= H[i]){
            tmp = H[i];
            view[i] = 1;
        }
    }
}
int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for(auto &x : H){
        cin >> x;
    }
    HeightCheck(H);
    cout << count(ALL(view), 1) << endl;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_;\
__VA_ARGS__;--c_; if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define dump(...) dbg(print(#__VA_ARGS__, __VA_ARGS__))
#define dump_range(...) dbg(cerr<<#__VA_ARGS__<<": ";print_range(__VA_ARGS__))
using namespace std; using ll = long long; 
template< typename t > using V = vector< t >; void print(){cout<<'\n';}
template< typename t, typename... v > void print(const t& a, v&&... b)
{cout << a << ' '; print(b...);}
template< typename t > void print_range(t a, const t& b)
{while (a!=b) cout << (*a++) << ' '; cout << '\n';}
/*}}}*/



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

    int n;
    cin >> n;

    V< int > tb(n);
    for (int& i : tb)
        cin >> i;

    V< int > ilo;
    for (int i = 0; i < n - 1; ++i)
        if (tb[i] == tb[i + 1])
            ilo.push_back(i);

    int pop = -2;
    int res = 0;

    for (int v : ilo)
    {
        if (v - 1 == pop)
            ++res, pop = -2;
        else
        {
            if (pop != -2) ++res;
            pop = v;
        }
    }

    if (pop != -2) ++res;

    print(res);
}

Measured memory_bytes: 256