akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
//#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
string str;
string t;
string tmp;
int count;

int main(){
	while(cin >> str){
		map<string,int> mp;
		mp[str] = 0;
		if(str == "0"){
			break;
		}
		queue<string> q;
		q.push(str);

		char a[5] = {'r','g','b'};
		bool q_flag = true;

		while(!q.empty()){
			tmp = q.front();
			q.pop();
			bool flag = true;

			for(int i=0; i+1<tmp.size(); i++){
				if(tmp[i] != tmp[i+1]){
					flag = false;
					for(int j=0; j<3; j++){
						if(a[j] != tmp[i] && a[j] != tmp[i+1]){
							t = tmp;
							t[i+1] = a[j];
							t[i] = a[j];
							if(mp.count(t) == 1){
								continue;
							}
							mp[t] = mp[tmp] + 1;
							q.push(t);
						}
					}
				}
			}
			if(flag == true){
				cout << mp[tmp] << endl;
				q_flag = false;
				break;
			}
		}

		if(q_flag == true){
			cout << "NA" << endl;
		}

	}

}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<50);

vec a(int(2e+5)), ans(int(2e+5));
mat G(int(2e+5), vec(0));
set<ll> d;
void dfs(int v, int p){
    auto ite = d.lower_bound(a[v]);
    int place = (ite == d.end() ? -1 : *ite);
    d.erase(place);
    d.insert(a[v]);
    ans[v] = d.size();
    for(int to : G[v]){
        if(to != p) dfs(to, v);
    }
    d.erase(a[v]);
    if(place != -1) d.insert(place);
}
int main() {
    cin>>N;
    rep(i,N) cin>>a[i];
    rep(i,N - 1){
        int u, v;
        cin>>u>>v;
        --u;
        --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(0, -2);
    rep(i,N){
        cout<<ans[i]<<endl;
    }
    //if(!d.empty())cout<<"dame"<<endl;
}

Measured memory_bytes: 34492
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def query_cumsum2d(s, x1, y1, x2, y2):
    # [x1, x2) × [y1, y2)
    if x2 < x1:
        x1, x2 = x2, x1
    if y2 < y1:
        y1, y2 = y2, y1
    return s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1]

def main():
    N, K = LI()
    G = [[0 for _ in range(2*K)] for __ in range(2*K)]
    cumsum2d = [[0 for _ in range(2*K + 1)] for __ in range(2*K + 1)]
    xyc = []
    for _ in range(N):
        x, y, c =  LS()
        x = int(x)
        y = int(y)
        if c == 'W':
            x += K
        x = x % (2 * K)
        y = y % (2 * K)
        G[x][y] += 1
        xyc.append((x, y, c))
    for x in range(2*K):
        for y in range(2*K):
            cumsum2d[x+1][y+1] = (
                cumsum2d[x+1][y]
                + cumsum2d[x][y+1]
                - cumsum2d[x][y]
                + G[x][y]
            )
    ans = 0
    # import pdb
    # print('cum: ')
    # for row in cumsum2d:
    #     print(row)
    # print()
    # print('g: ')
    # for row in G:
    #     print(row)
    for x in range(K):
        for y in range(K):
            # pdb.set_trace()
            cnt = (
                  query_cumsum2d(cumsum2d, 0, 0, x, y)
                + query_cumsum2d(cumsum2d, x, y, x+K, y+K)
                + query_cumsum2d(cumsum2d, x+K, 0, 2 * K, y)
                + query_cumsum2d(cumsum2d, 0, y+K, x, 2 * K)
                + query_cumsum2d(cumsum2d, 2*K, 2*K, x+K, y+K)
            )

            ans = max(ans, cnt, N - cnt)
    print(ans)



main()



Measured memory_bytes: 125016
from math import gcd
 
def main():
    k = int(input())
    ans = 0
 
    for a in range(1, k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                ans += gcd(gcd(a, b), c)
 
    print(ans)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {

  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  while( A > 0 && C > 0 ) {

    C = C - B;
    
    A = A - D;
    
  }

  if ( C <= 0 ) {
    
    puts("Yes");
    
  } else {
    
    puts("No");
    
  }

}



Measured memory_bytes: 3624
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String a = in.next();
      	String b = in.next();
      	int cnt = 0;
      
      if(a.charAt(0)==b.charAt(0)){cnt++;}
       if(a.charAt(1)==b.charAt(1)){cnt++;}
       if(a.charAt(2)==b.charAt(2)){cnt++;}
      
      System.out.print(cnt);
      
      
      
	}
}

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

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if (C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if (A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}

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

//#include <atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;

map<ll, int> prime_fact(ll n) {
  map<ll, int> m;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p) continue;  // 素因数でない
    int num = 0;
    while (!(n % p)) {  // 素因数で何回割れるかを計算する
      num++;
      n /= p;
    }
    m[p] = num;
  }
  if (n > 1) {  // n自身が素因数
    m[n] = 1;
  }

  return m;
}

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

  // 素数の公約数を選べば、それが答え。
  ll g = gcd(a, b);

  // 最大公約数の素因数を数えれば良い
  auto p = prime_fact(g);
  cout << p.size() + 1 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
string s;char x;
 vector<char>v;
    map<char,ll>m;
    ll a,b,c,d,i,j,k,l=0;
  cin>>a;
for(i=1;i<=a;i++)
{
  cin>>s;x=s[0];  
if(x=='C'||x=='R'||x=='A'||x=='M'||x=='H'){
  if(m[x]==0)
  {
        v.push_back(x);
   }
            m[x]++;
  }
}
 for(i=0;i<v.size();i++)
{
for(j=i+1;j<v.size();j++)
   {
for(k=j+1;k<v.size();k++)
{
l+=(m[v[i]]*m[v[j]]*m[v[k]]);
}
}
 }
cout<<l<<endl;
}

Measured memory_bytes: 256
unrest = "UNRESTORABLE"
S = input()
T = input()

def check(a, b):
    res = True
    for i in range(len(a)):
        if a[i] != '?' and a[i] != b[i]:
            res = False
            break
    return res

flag = False
ind = -1
for i in reversed(range(len(S) - len(T) + 1)):
    if check(S[i:i+len(T)], T):
        ind = i
        flag = True
        break


if flag:
    ans = ""
    for i in range(len(S)):
        if i >= ind and i < ind + len(T):
            ans += T[i - ind]
        else:
            if S[i] == '?':
                ans += "a"
            else:
                ans += S[i]
    print(ans)
else:
    print(unrest)


Measured memory_bytes: 38384
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int i;
    i=0;
    while(scanf("%d %d",&a,&b)!=EOF){
    c=a+b;
    for(;;)
    {
        i++;
        if(c<10) break;
        c=c/10;

    }
    printf("%d\n",i);
    i=0;
    }
    return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  if(s == "RRR") {
    cout << 3 << endl;
    return 0;
  }
  if(s == "RRS" || s == "SRR") {
    cout << 2 << endl;
    return 0;
  }
  if(s == "SSS") {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3624
import math

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

r = 0
l = 1e9

test_count = 0

while (l - r > 1) :
    target_log_len = (r + l) // 2
    cut_count = 0

    for log_len in A:
        cut_count += (log_len - 1) // target_log_len

    if cut_count <= K:
        l = target_log_len
    else:
        r = target_log_len

    test_count += 1
    if test_count > 100:
        break

print(int(l))

Measured memory_bytes: 31216
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] cost = new int[10][10];
			for (int[] t : cost)
				Arrays.fill(t, 1 << 24);
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				cost[a][b] = c;
				cost[b][a] = c;
			}
			for (int i = 0; i < 10; i++) {
				slove(i, cost);
			}
			int ans = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < 10; i++) {
				int sum = 0;
				for (int j = 0; j < 10; j++) {
					if (cost[i][j] != 1 << 24)
						sum += cost[i][j];
				}
				if (sum != 0) {
					if (sum < min) {
						min = sum;
						ans = i;
					}
				}
			}
			System.out.println(ans + " " + min);
		}

	}

	private void slove(int x, int[][] cost) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < 10; i++) {
			if (cost[i][x] != 1 << 24) {
				deque.push(i);
			}
		}
		cost[x][x] = 0;
		while (!deque.isEmpty()) {
			int pri = deque.poll();
			for (int i = 0; i < 10; i++) {
				if (pri == i)
					continue;
				int a = cost[x][i];
				int b = cost[pri][i];
				int c = cost[pri][x];
				if (cost[pri][i] != 1 << 24
						&& cost[x][i] > cost[pri][i] + cost[x][pri]) {
					cost[x][i] = cost[pri][i] + cost[x][pri];
					deque.push(i);
				}
			}
		}

	}
}

Measured memory_bytes: 19896
# include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n, m,i,j; 
  long long int mod=1e9+7;
  cin>>n>>m; 
  char ar[n][m];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin>>ar[i][j];
    }
  }
  long long int dp[n][m];
   memset(dp,0,sizeof(dp));
  for(i=1;i<m;i++){
    if(ar[0][i]=='.'){
      dp[0][i]=1;
    }
    else{
      break; 
    }
  }
  for(i=1;i<n;i++){
    if(ar[i][0]=='.'){
      dp[i][0]=1;
    }
    else{
      break; 
    }
  }
  for(i=1;i<n;i++){
    for(j=1;j<m;j++){
      if(ar[i][j]=='.')
      dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod; 
    }
  }
 /* for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cout<<dp[i][j]<<" ";
    }
    cout<<"\n";
  }*/
  cout<<dp[n-1][m-1];
  return 0;
}

Measured memory_bytes: 12376
H,W,K = map(int,input().split(" "))
dp = [ [0]*W for _ in range(H+1) ]
dp[0][0] = 1
mod = 10**9+7

for i in range(1,H+1):
    for j in range(W):
        l,m,r = 0,0,0
        for k in range(1<<(W-1)):
            flg = True
            for bit in range(W-2):
                if (k >> bit) & (k >> (bit+1)) & 1:
                    flg =  False
                    break
            if flg:
                if j < (W-1) and (k >> (W - j - 2)) & 1:
                    r += 1
                if (j == (W-1) or ((k >> (W - j - 2)) & 1 == 0)) and (j == 0 or ((k >> (W - j - 1)) & 1 == 0)):
                    m += 1
                if j > 0 and (k >> (W - j - 1)) & 1:
                    l += 1

        if j > 0:
            dp[i][j] += l * dp[i-1][j-1]
        dp[i][j] += m * dp[i-1][j]
        if j < (W-1):
            dp[i][j] += r*dp[i-1][j+1]
        dp[i][j] %= mod
print(dp[-1][K-1]%mod)

Measured memory_bytes: 44016
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	cin >>n>>m;
	int ac=0,wa=0;
	pair<int,string>state;
	VPi data(n,mp(0,0));
	rep(i,m){
		cin>>state.F>>state.S;
		state.F--;
		if(data[state.F].F==0){
			if(state.S=="AC"){
				data[state.F].F++;
			}else{
				data[state.F].S++;
			}
		}
	}
	rep(i,n){
		ac+=data[i].F;
		if(data[i].F==1){
		wa+=data[i].S;
		}
	}
	printf("%d %d\n",ac,wa);
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] inputs = Console.ReadLine().Split(' ');

            int currentval = int.Parse(inputs[0]);
            int kurikosi = 0;
            bool trigger = false;

            if(n == 1)
            {
                Console.WriteLine("Yes");
                return;
            }

            for (int i = 0; i < n - 1; i++)
            {
                int nextval = int.Parse(inputs[i + 1]);
                int diff = nextval - currentval;

                if(currentval < nextval)
                {
                    currentval = nextval;
                    trigger = false;
                }
                else if (currentval == nextval)
                {
                    trigger = true;
                }
                else{
                    if (diff < -1)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                    
                    else
                    {
                        trigger = true;
                    }
                    
                }



            }
            Console.WriteLine("Yes");

        }
    }
}


Measured memory_bytes: 28384
#include<bits/stdc++.h>
#define N 200020
#define LOGN 20
using namespace std;
int n,first[N],nxt[N*LOGN*15],tot=0;
long long Ans,a[N],inf=1e18,d;
int fa[N],cnt=0;
long long Read()
{
	long long x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') 
	{
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9') 
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
struct Edge
{
	int u,v;
	long long w;
}edge[N*LOGN*15];
bool cmp(const Edge a,const Edge b)
{
	if (a.w<b.w) return true;
	else return false;
}
void Add(int u,int v)
{
	long long w=abs(u-v)*d+a[u]+a[v];
	tot++;
	nxt[tot]=first[u];
	first[u]=tot;
	edge[tot]=(Edge){u,v,w};
	return;
}
int Build(int l,int r,int flag)
{
	if (l==r) return l;
	int mid=(l+r)>>1;
	int minl=Build(l,mid,-1),minr=Build(mid+1,r,1);
	for (int i=l;i<=mid;i++) Add(i,minr);
	for (int i=mid+1;i<=r;i++) Add(i,minl);
	long long minlr=inf;
	int point=0;
	for (int i=l;i<=r;i++) 
	    if (i*d*flag+a[i]<minlr) point=i,minlr=i*d*flag+a[i];
	return point;
}
int Get(int x)
{
	if (x==fa[x]) return x;
	else return fa[x]=Get(fa[x]);
}
void Join(int x,int y)
{
	fa[x]=y;
	return;
}
long long Krus()
{
	long long ret=0;
	for (int i=1;i<=n;i++) fa[i]=i;
	sort(edge+1,edge+tot+1,cmp);
	for (int i=1;i<=tot;i++)
	{
		int u=edge[i].u,v=edge[i].v;
		int f1=Get(u),f2=Get(v);
		if (f1!=f2)
		{
			cnt++;
			ret+=edge[i].w;
			Join(f1,f2);
		}
	}
	return ret;
}
int main()
{
	//freopen("testdata.in","r",stdin);
	memset(first,-1,sizeof(first));
	n=Read(),d=Read();
	for (int i=1;i<=n;i++) a[i]=Read();
	Build(1,n,0);
	Ans=Krus();
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 74752
{-# LANGUAGE MultiWayIf #-}

solve :: String -> Int -> Int
solve [] _     = 0
solve (x:xs) n = if
  | x == 'S'  -> solve xs (n+1)
  | n > 0     -> solve xs (n-1)
  | otherwise -> 1 + solve xs 0

main :: IO ()
main = do
  s <- getLine
  print $ 2 * solve s 0


Measured memory_bytes: 9596
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int H, W, K; std::cin >> H >> W >> K;
  auto dist = [&](int h, int w)->int {
    int d = std::min(std::min(h, w), std::min(H-1-h, W-1-w));
    return (d+K-1)/K;
  };
  std::vector<std::string> rooms(H);
  int sH, sW;
  for(int h = 0; h < H; ++h) {
    std::cin >> rooms[h];
    for(int w = 0; w < W; ++w) if(rooms[h][w] == 'S') {
      sH = h;
      sW = w;
    }
  }
  int dh[4] = {0, -1, 0, 1};
  int dw[4] = {-1, 0, 1, 0};
  auto mhp = mk2d<int>(H, W, -100);
  std::queue<std::tuple<int,int,int>> q;
  q.emplace(sH, sW, K);
  int ans = H+W;
  while(!q.empty()) {
    int h, w, hp;
    std::tie(h, w, hp) = q.front(); q.pop();
    if(hp <= mhp[h][w]) continue;
    int cur = dist(h, w);
    ans = std::min(ans, cur);
    if(ans == 0) break;
    mhp[h][w] = hp;
    if(hp == 0) continue;
    for(int i = 0; i < 4; ++i) {
      int nh = h+dh[i], nw = w+dw[i];
      if(rooms[nh][nw]!='.') continue;
      q.emplace(nh, nw, hp-1);
    }
  }
  fin(ans+1);
  return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#define N 80
#define ll long long
int p;
inline void add(int&x,int y){if((x+=y)>=p)x-=p;}
inline int min(int x,int y){return x<y?x:y;}
int f[2][N][N][N],i,j,k,l;
inline int _a(int n,int m)
{
    for(f[0][0][0][n+3>>1]=i=1;i<=n;i++)for(j=0;j<=i>>1;j++)
    {
        for(k=0;k<j;k++)for(l=i>>1;l<=n+2>>1;f[i&1^1][j][k][l++]=0)
        if(i&1)add(f[1][i+1>>1][k][l],f[0][j][k][l]),add(f[1][j][k][k<i-m>>1?min((j<<1|1)+m>>1,l):l],f[0][j][k][l]);
        else
        {
            add(f[0][j][i>>1][n+3>>1],f[1][j][k][l]);
            if(i>>1<l)add(f[0][j][k][l],f[1][j][k][l]);
        }
        for(k=j;k<i+1>>1;k++)for(l=i>>1;l<=n+3>>1;f[i&1^1][j][k][l++]=0)
        if(i&1)
        {
            add(f[1][i+1>>1][k][n+2>>1],f[0][j][k][l]);
            if(i+1>>1<l)add(f[1][j][k][l],f[0][j][k][l]);
        }
        else add(f[0][j][i>>1][l],f[1][j][k][l]),add(f[0][j][k][j<i-m+1>>1?min(l,(k+1<<1)+m+1>>1):l],f[1][j][k][l]);
    }
    for(i=k=0;i<=n+1>>1;i++)for(j=0;j<i;j++)add(k,f[n&1][i][j][n+2>>1]);
    for(i=0;i<=n+1>>1;i++)for(j=i;j<=n>>1;j++)add(k,f[n&1][i][j][n+3>>1]);
    return k;
}
int g[N];
inline int _b(int n,int m)
{
    for(*g=i=1;i<=m;i++)g[i]=0;
    for(i=0;i<=n;i++)
    {
        for(j=m+1;j--;)g[j+1]=g[j];
        for(*g=j=0;j++<=m;)add(*g,g[j]);
    }
    return *g;
}
int m,n;
int main()
{
    scanf("%d%d%d",&n,&m,&p),printf("%d\n",m&1?_a(n,m):(ll)_b(n>>1,m>>1)*_b(n+1>>1,m>>1)%p);
    return 0;
}

Measured memory_bytes: 3968
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));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input = br.readLine().split("");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int c = Integer.parseInt(input[2]);
        int d = Integer.parseInt(input[3]);
        String[] op = new String[3];
        
        if(a + b + c + d == 7){
            op[0] = "+";
            op[1] = "+";
            op[2] = "+";
        }
        
        if(a + b + c - d == 7){
            op[0] = "+";
            op[1] = "+";
            op[2] = "-";
        }
        
        if(a + b - c + d == 7){
            op[0] = "+";
            op[1] = "-";
            op[2] = "+";
        }
        
        if(a + b - c - d == 7){
            op[0] = "+";
            op[1] = "-";
            op[2] = "-";
        }
        
        if(a - b + c + d == 7){
            op[0] = "-";
            op[1] = "+";
            op[2] = "+";
        }
        
        if(a - b + c - d == 7){
            op[0] = "-";
            op[1] = "+";
            op[2] = "-";
        }
        
        if(a - b - c + d == 7){
            op[0] = "-";
            op[1] = "-";
            op[2] = "+";
        }
        
        if(a - b - c - d == 7){
            op[0] = "-";
            op[1] = "-";
            op[2] = "-";
        }
        
        
        out.println(a + op[0] + b + op[1] + c + op[2] + d + "=7");
        out.close();
        
    }
}

Measured memory_bytes: 39392
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

if count >= 3: print('Yes')
else: print('No')

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    cin >>N>>K;
    vector<long long>vec(N);
    for(int i=0;i<N;i++){
        cin >>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    long long MIN=10000000000;
    for(int i=0;i<N-K+1;i++){
        long long a=vec.at(i)-vec.at(i+K-1);
        MIN=min(a,MIN);
    }
    cout <<MIN<<endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define FST first
#define SND second

#define MAX_N   (2000)                  // 10^3
#define MAX_Q   (200000)                  // 10^5
// #define MAX_N   (1000000000)              // 10^9
// #define MAX_N   (1000000000000000000)     // 10^18
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

ll A, B;

ll calc() {
  ll r = 1L << 61;
  while (r > 0) {
    ll da = A & r;
    ll db = B & r;
    if (da != db) break;
    r >>= 1;
  }
  if (r == 0) return 1;

  if (A > B) swap(A, B);
  ll mask = (r << 1) - 1;
  A &= mask; B &= mask;

  ll k = r >> 1;
  while (k > 0) {
    ll db = B & k;
    if (db != 0) break;
    k >>= 1;
  }
  r <<= 1; k <<= 1;
  if (k == 0) k = 1;

  ll l1 = A, r1 = (r >> 1) + k;
  ll l2 = A + (r >> 1), r2 = r;
  if (l2 <= r1) {
    return max(r1, r2) - min(l1, l2);
  } else {
    return (r1 - l1) + (r2 - l2);
  }
}

void solve() {
  ll ans = calc();

  cout << ans << endl;
}

int main() {
  cin >> A >> B;

  solve();

  return 0;
}


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

using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < s.size(); j++){
            char ss = s[j];
            if (ss == char('Z')) s[j] = char('A');
            else s[j]++;
            
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int n,m;
	cin>>n>>m;
	bool b[n+1]={};
	ll s[n+2]={};
	rep(i,m){
		int a;
		cin>>a;
		b[a]=true;
	}
	s[0]=1;
	rep(i,n){
		if(!b[i]){
		s[i]%=1000000007;
		s[i+1]+=s[i];
		s[i+2]=s[i];
		}
	}
	cout<<s[n]%1000000007<<endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if (n % 2 == 1)
    {
        ll num = n / 2;
        ll left, right;
        left = a[num];
        right = b[b.size() -1 - num];
        cout << right - left + 1 << endl;
    }else{
        ll num = n / 2;
        ll left1,left2, right1,right2;
        left1 = a[num - 1];
        left2 = a[num];
        right1 = b[b.size() - 1 - num + 1];
        right2 = b[b.size() - 1 - num];
        ll left, right;
        cout << right1 + right2 - left1 - left2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6364
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0, L =0;
    cin(N);cin(L);

    //vll X(N);
    //REP(i,N) cin(X.at(i));
    vector<string> S(N);
    REP(i,N){
    cin(S.at(i));
      
    } 

    //本文
    vector<string> ans(N);
    REP(j,N*N){
    REP(i,N-1){
      if(S[i+1] < S[i]){
        string tem;
        tem = S[i+1];
        S[i+1] = S[i];
        S[i] = tem;
      }
    }
    }

    //出力
    //cout <<  << endl;
    REP(i,N) cout << S.at(i);
  return 0;
}

Measured memory_bytes: 3676
#D - Floor Function
A,B,N = map(int, input().split())

if B>N:
    a = (A*N)//B
    b = N//B
    print(a-A*b)
    exit()
else:
    N = B-1
    a = (A*N)//B
    b = N//B
    print(a-A*b)

Measured memory_bytes: 9184
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        s: Bytes,
    }

    let b = s[2] == s[3] && s[4] == s[5];
    println!("{}", if b { "Yes" } else { "No" });
}


Measured memory_bytes: 2136
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner si=new Scanner(System.in);
		String str;
		
		str=si.next();
		
		char ch[]=str.toCharArray();
		
		int n=str.length(),count=1;
		
		for(int i=0;i<n-1;i++)
		    if(ch[i]=='R' && ch[i+1]=='R')
		        count++;
		    else if(ch[0]=='R' && ch[2]=='R' && count==1||ch[1]=='R' && ch[2]=='S' && count==1|| ch[0]=='R'&& count==1 || ch[2]=='R'&& count==1)
		        count=1;
		    else if(ch[i]!='R' && count==1)
		        count=0;
		
		System.out.println(count);
		si.close();
	}
}


Measured memory_bytes: 26948
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n; cin>>n;
    int p[200001]={};
    FOR(i,0,n){
        int q; cin>>q;
        p[q-1]=i;
    }
    int k=0;
    int km=0;
    int c=-1;
    FOR(i,0,n){
        if(p[i]>c){
            k++;
            km=max(k,km);
        }else{
            k=1;
        }
        c=p[i];
    }
    co(n-km);
}


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

int main() {
  int K,X;
  cin >> K >> X;
  for(int i = X - K + 1 ; i <= X + K -1; i++){
    cout << i << " " ;
  }

  cout << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

// (a ^ b) % mod
ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}

int main() {

	string s;
	cin >> s;

	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
using namespace std;




int main()
{
	
	long long int n, k, ans = 0;
	cin >> n >> k;
	ans += pow(n / k, 3);
	if (k % 2 == 0) {
		ans += pow((n + (k / 2)) / k, 3);
	}
	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 512
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        A[j][k] = "x"
      else:
        pass
if A[0] == ["x","x","x"]:
  print("Yes")
elif A[1] == ["x","x","x"]:
  print("Yes")
elif A[2] == ["x","x","x"]:
  print("Yes")
elif A[0][0] == "x" and A[1][0] == "x" and A[2][0] == "x":
  print("Yes")
elif A[0][1] == "x" and A[1][1] == "x" and A[2][1] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][2] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<=(n); i++)//第一引数の変数をカウンタ変数としてn回回す
//repはカウンタ変数が1ずつ増える場合にしか使えない
int INF = 10101010;
using veci = vector<int>;
using vecd = vector<double>;
int main(){//それぞれの枚数について固定してよいので全探索する
  int a, b, c, x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  int count=0;
  rep(i, a){
    rep(j, b){
      rep(h, c){
        if ((500*i) + (100*j) + (50*h) == x){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		ArrayList<Double> x = new ArrayList<Double>();
		ArrayList<Double> y = new ArrayList<Double>();
		double xm = 0;
		double ym = 0;
		while(sc.hasNext()) {
			String[] tmp = sc.next().split(",");
			if(tmp[0].equals("A")) break;
			double xt = (Double.parseDouble(tmp[0]));
			double yt = (Double.parseDouble(tmp[1]));
			xm = Math.min(xt, xm);
			ym = Math.min(yt, ym);
			x.add(xt);
			y.add(yt);
		}
		x.add(x.get(0));
		y.add(y.get(0));
		double S = 0;
		for(int i = 0; i < x.size()-1; i++) {
			S += (x.get(i) - x.get(i+1))*(y.get(i) + y.get(i+1));
		}
		S /=2;
		out.println(Math.abs(S));
		out.flush();

	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

Measured memory_bytes: 15072
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	L, R, d := nextInt(), nextInt(), nextInt()

	fmt.Fprintf(out, "%d\n", R/d-(L-1)/d)
}


Measured memory_bytes: 1812
h, w = map(int, input().split())
a = [[j for j in input()] for i in range(h)]

cnt = [0 for i in range(26)]
for i in range(h):
    for j in range(w):
        cnt[ord(a[i][j]) - ord("a")] += 1

ans1 = 0
ans2 = 0
ans4 = 0
if h % 2 == 1 and w % 2 == 1:
    ans1 = 1
    ans2 = (h - 1) // 2 + (w - 1) // 2
    ans4 = (h * w - ans1 - ans2 * 2) // 4
elif h % 2 == 1:
    ans2 = w // 2
    ans4 = (h * w - ans2 * 2) // 4
elif w % 2 == 1:
    ans2 = h // 2
    ans4 = (h * w - ans2 * 2) // 4
else:
    ans4 = h * w // 4

cnt1 = 0
cnt2 = 0
cnt4 = 0
for i in cnt:
    if i >= 4:
        cnt4 += i // 4
        i %= 4
    if i >= 2:
        cnt2 += i // 2
        i %= 2
    cnt1 += i

# print("ans1 =", ans1)
# print("ans2 =", ans2)
# print("ans4 =", ans4)
# print("cnt1 =", cnt1)
# print("cnt2 =", cnt2)
# print("cnt4 =", cnt4)

if ans4 > cnt4:
    print("No")
else:
    cnt2 += (cnt4 - ans4) * 2
    if ans2 > cnt2:
        print("No")
    else:
        cnt1 += (cnt2 - ans2) * 2
        if ans1 != cnt1:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 66080
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 1000001;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	int c1=0,c2=0;
	rep(i,0,n)
	{
		if(s[i]=='S')
		{c1++;
		}
		else
		{
			if(c1>0)
			{c2++;
			c1--;
			}

		}
	}

	cout<<n-2*c2;

}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

  

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main() {
	aryan_pandeya();
	FIO;


	int n ;
	cin>>n;

	cout<<1-n;

}


Measured memory_bytes: 3628
N,A,B=gets.split.map &:to_i
V=gets.split.map(&:to_i).sort.reverse

cnt = Hash.new(0)
V.each do |v|
  cnt[v] += 1
end

val = 0
cnt2 = Hash.new(0)
V[0...(A-1)].each do |v|
  val += v
  cnt2[v] += 1
end

ave=Rational(0,1)
res=0
A.upto(B) do |i|
  val += V[i-1]
  cnt2[V[i-1]] += 1
  a = Rational(val, i)
  next    if a < ave
  res = 0 if a > ave
  ave = a
  res += V[0...i].uniq.map{|v| (0...cnt[v]).to_a.combination(cnt2[v]).size}.inject(:*)
end
puts format("%.10f", ave.to_f), res.to_i


Measured memory_bytes: 2172
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to;
    long long cost;
    Edge(){};
    Edge(int to0, long long  cost0){to = to0; cost = cost0;}
};

void shortestPath(const vector<vector<Edge> >& edges, int start, vector<long long >& dist)
{
    dist.assign(edges.size(), LLONG_MAX);
    dist[start] = 0;
    priority_queue<pair<long long ,int>, vector<pair<long long ,int> >, greater<pair<long long ,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<long long , int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

const long long X = 100000;

int main()
{
    int n, transferTime;
    string start, goal;
    cin >> n >> transferTime >> start >> goal;

    vector<int> a(n);
    vector<vector<string> > s(n);
    vector<vector<int> > t(n);
    map<string, int> index;

    for(int i=0; i<n; ++i){
        cin >> a[i];
        s[i].resize(a[i]);
        for(int j=0; j<a[i]; ++j){
            cin >> s[i][j];
            index[s[i][j]];
        }

        t[i].resize(a[i]-1);
        for(int j=0; j<a[i]-1; ++j)
            cin >> t[i][j];
    }

    int m = 0;
    for(map<string, int>::iterator it=index.begin(); it!=index.end(); ++it){
        it->second = m;
        ++ m;
    }

    vector<vector<Edge> > edges(m + accumulate(a.begin(), a.end(), 0));
    int p = m;
    for(int i=0; i<n; ++i){
        for(int j=0; j<a[i]; ++j){
            edges[p+j].push_back(Edge(index[s[i][j]], transferTime * X + 1));
            edges[index[s[i][j]]].push_back(Edge(p+j, 0));
        }
        for(int j=0; j<a[i]-1; ++j){
            edges[p+j].push_back(Edge(p+j+1, t[i][j] * X));
            edges[p+j+1].push_back(Edge(p+j, t[i][j] * X));
        }
        p += a[i];
    }

    vector<long long> dist;
    shortestPath(edges, index[start], dist);
    long long ret = dist[index[goal]];
    
    if(ret == LLONG_MAX){
        cout << -1 << endl;
    }else{
        ret -= (transferTime * X + 1);
        cout << (ret / X) << ' ' << (ret % X) << endl;
    }

    return 0;
}

Measured memory_bytes: 29356
#include <iostream>
using namespace std;
long long a[100005];
int main(){
    int N;
    cin >> N ;
    long long result = 0;
    while(N--){
        int b;
        cin >> b;
        a[b]++;
        result += b;
    }

    cin >> N;
    while(N--){
        int p,q;
        cin >> p >> q;
        if(a[p]){
            a[q]+=a[p];
            result += a[p]*(q-p);
            a[p]=0;
        }
        cout << result << endl ;
    }
    return 0;
}

Measured memory_bytes: 3920
package main

import (
	"fmt"
	"math"
)

func main() {
	var H int
	fmt.Scan(&H)
	if H == 1 {
		fmt.Println(1)
	}

	if H != 1 {
		cnt := 1
		for {
			H = H / 2
			cnt++
			if H <= 1 {
				break
			}
		}

		fmt.Println(int(math.Pow(float64(2), float64(cnt))) - 1)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int a[10], k;
    REP(i,5){
        cin >> a[i];
    }
    cin >> k;
    int tmp;
    FOR(i,1,5){
        if(abs(a[0]-a[i])>k){
            cout << ":(" << endl;
            return 0;
        }
    }
    FOR(i,2,5){
        if(abs(a[1]-a[i])>k){
            cout << ":(" << endl;
            return 0;
        }
    }
    FOR(i,3,5){
        if(abs(a[2]-a[i])>k){
            cout << ":(" << endl;
            return 0;
        }
    }
    FOR(i,4,5){
        if(abs(a[3]-a[i])>k){
            cout << ":(" << endl;
            return 0;
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256