akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

        
    public static void main(String[] args) {    	                 
            Scanner  sc = new Scanner(System.in);        
            
            int N = sc.nextInt();
            
            int K = sc.nextInt();
            int L = sc.nextInt();
            
            UnionFind road    = new UnionFind(N);
            UnionFind railway = new UnionFind(N);
            
            for(int i = 0;i < K;i++){
                road.union(sc.nextInt()-1 ,sc.nextInt() - 1);
            }            
            
            for(int i = 0;i < L;i++){
                railway.union(sc.nextInt() - 1,sc.nextInt() - 1);                
            }

            Map<Long,Integer> count = new HashMap<>();
            
            for(int i = 0;i < N;i++){
                  long key = (long) road.find(i)*N + railway.find(i);
                  if(count.containsKey(key))
                      count.put(key,count.get(key) + 1);  
                  else
                      count.put(key,1);
            }
            
            StringBuilder sb = new StringBuilder();
            for(int i = 0;i < N;i++){
                 long key = (long) road.find(i)*N + railway.find(i);
                 sb.append(count.get(key)).append(" ");                                                  
            }            
                          
            System.out.println(sb);
    }
    
    static class UnionFind{
        int parent[];
        int rank[];
        
        UnionFind(int n){
            parent = new int[n];
            rank   = new int[n];            
            for(int i = 0;i < n;i++){
                parent[i] = i;
                  rank[i] = 0;
            }            
        }
        
        public int find(int x){
           if(parent[x] == x)
              return x;
           else
              return parent[x] = find(parent[x]);
        }                
        
        boolean same(int x,int y){
            return find(x) == find(y);
        }                                        

        public void union(int x,int y){
            x = find(x);
            y = find(y);
            
            if(x != y){
                if(rank[x] > rank[y]){
                     parent[y] = x;                    
                }else{                                        
                     parent[x] = y;
                    if(rank[x] == rank[y]){
                        rank[y]++;                        
                    }                    
                }                                                              
            }
            
            return;
        }        
        
        public int count(){
            int count = 0;
            for(int i = 0;i < parent.length;i++){                
                if(i == parent[i]){
                    count++;
                }
            }                       
            return count;
        }          
        
    }     
    
}

Measured memory_bytes: 116868
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--;
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

inline int inv(int x) {
  return pw(x, mod - 2);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> r(k + 1, 0);
  for (int i = k; i >= 1; i--) {
    r[i] = pw(k / i, n);
    for (int j = i + i; j <= k; j += i) {
      add(r[i], -r[j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    add(ans, mul(i, r[i]));
  }
  cout << ans << '\n';
  return 0;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N), C(N);
    for ( int i = 0; i < N; i++ ) cin >> P[i], P[i]--;
    for ( int i = 0; i < N; i++ ) cin >> C[i];

    vector<int> gp(N,-1);
    int g = 0;
    vector<ll> gp_len, gp_sum;
    for ( int i = 0; i < N; i++ ) {
        if ( gp[i] >= 0 ) continue;
        int cur = i;
        while ( gp[cur] < 0 ) {
            gp[cur] = g;
            if ( gp_len.size() <= g ) gp_len.push_back(0LL);
            if ( gp_sum.size() <= g ) gp_sum.push_back(0LL);
            gp_len[g]++;
            gp_sum[g] += C[cur];
            cur = P[cur];
        }
        g++;
    }
    ll ans = -1e10;
    for ( int i = 0; i < N; i++ ) {
        int g = gp[i];
        int cur = i;
        ll k = K;
        ll s = 0;
        for ( int j = 0; j < min(gp_len[g],K); j++ ) {
            cur = P[cur];
            s += C[cur];
            k--;
            ll x = s + k/gp_len[g]*max(gp_sum[g],0LL);
            ans = max(ans, x);
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <string.h>
int main(void)
{
    int n,i,ans,tmp;
    char cmd[6];
    int dice[6];
    while(1)
    {
        ans = 1;
        for(i=0;i<6;i++)
        {
            dice[i] = i+1;
        }
        scanf("%d",&n);
        if(n == 0)return 0;
        for(i=0;i<n;i++)
        {
            scanf("%s",cmd);
            if(strcmp(cmd,"North") == 0)
            {
                tmp = dice[0];
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = dice[4];
                dice[4] = tmp;
                ans += dice[0];
            }
            else if(strcmp(cmd,"East") == 0)
            {
                tmp = dice[3];
                dice[3] = dice[5];
                dice[5] = dice[2];
                dice[2] = dice[0];
                dice[0] = tmp;
                ans += dice[0];
            }
            else if(strcmp(cmd,"West") == 0)
            {
                tmp = dice[0];
                dice[0] = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[3];
                dice[3] = tmp;
                ans += dice[0];
            }
            else if(strcmp(cmd,"South") == 0)
            {
                tmp = dice[0];
                dice[0] = dice[4];
                dice[4] = dice[5];
                dice[5] = dice[1];
                dice[1] = tmp;
                ans += dice[0];
            }
            else if(strcmp(cmd,"Right") == 0)
            {
                tmp = dice[1];
                dice[1] = dice[2];
                dice[2] = dice[4];
                dice[4] = dice[3];
                dice[3] = tmp;
                ans += dice[0];
            }
            else if(strcmp(cmd,"Left") == 0)
            {
                tmp = dice[1];
                dice[1] = dice[3];
                dice[3] = dice[4];
                dice[4] = dice[2];
                dice[2] = tmp;
                ans += dice[0];
            }
            else
            {
                printf("ERROR\n");
                return 0;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 604
#include <cstdio>
using namespace std;

int main(){
	int n, m, c = 0, s = 0, t = 0;
	while(scanf("%d,%d", &n, &m) == 2){
		t += m;
		s += n * m;
		++c;
	}
	printf("%d\n%.f\n", s, (double)t / c + 1e-9);
}

Measured memory_bytes: 1060
W,H,w,h,x,y = map(int, input().split())
if x+w//2 <= W//2 and y+h//2 <= H//2:
    print(y/x)
    quit()
else:
    if x+w//2 > W//2:
        x = (x-w//2+W//2)/2
    if y+h//2 > H//2:
        y = (y-h//2+H//2)/2
    print(y/x)
    quit()


Measured memory_bytes: 5612
#include<iostream>
#include<math.h>
using namespace std;
#define intt long long
intt func(intt i,intt temp)
{
    intt sum =0,r=0;
    while(temp>0)
    {
        r += temp%i;
        temp = temp/i;
    }
    return r;
}
int main()
{
    intt n,s;
    cin>>n>>s;
    intt ans;
    if(n==s)
    {
        cout<<n+1<<endl;
        return 0;
    }
    if(n<s)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    intt k = sqrt(n);
    for(int i=2; i<=k; i++)
    {
        intt temp = n;
        if(func(i,temp)==s)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    for(intt p=k; p>0; p--)
    {
        intt q = s-p;
        intt b = (n-q)/p;
        if(q>=0 && (n-q)%p==0 && p<b && q<b)
        {
            cout<<b<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll d[200005],x[200005],y[200005],mod=998244353;
int main(){
    ll n,k;cin>>n>>k;
    for(ll i=1;i<=k;i++){
        cin>>x[i]>>y[i];
    }
    d[1]=1;d[0]=0;
    for(ll i=2;i<=n;i++){
        for(ll j=1;j<=k;j++){
            if(i<x[j]) continue;
            ll l=i-x[j],r=max((ll)0,i-y[j]-1);
            d[i]+=d[l]-d[r];d[i]=(d[i]%mod+mod)%mod;
        }
        d[i]+=d[i-1];d[i]%=mod;
    }
    cout<<((d[n]-d[n-1])%mod+mod)%mod<<endl;
}

Measured memory_bytes: 5208
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int K=3005;
int x[K][K];
int n,k;
int getsize(int x1,int y1,int x2,int y2){
    return x[x2][y2]-x[x2][y1]-x[x1][y2]+x[x1][y1];
}
int main()
{
    scanf("%d%d",&n,&k);
    int a,b;
    char c;
    for(int i=1;i<=n;i++){
		scanf("%d%d %c",&a,&b,&c);
		a%=2*k,b%=2*k;
        if(c=='W')
			b+=k;
        x[a%(2*k)+1][b%(2*k)+1]++;
    }
    for(int i=1;i<=2*k;i++)
		for(int j=1;j<=2*k;j++)
			x[i][j]=x[i][j]+(x[i-1][j]+x[i][j-1]-x[i-1][j-1]);
	int ans=0,sum;
    for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++){
			sum=getsize(0,0,i,j);
			sum+=getsize(i,j,k+i,k+j);
			sum+=getsize(k+i,k+j,2*k,2*k);
			sum+=getsize(k+i,0,2*k,j);
			sum+=getsize(0,k+j,i,2*k);
			sum=max(n-sum,sum);
            ans=max(ans,sum);
		}
	printf("%d\n",ans);
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split().Select(int.Parse).ToList();
            var c = Console.ReadLine().Split().Select(int.Parse).ToList();

            var ans = 0;

            for(int i=0;i<n;i++)
            {
                if((v[i] - c[i])> 0)
                {
                    ans += v[i] - c[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }

int k=0;
void dfs(int a[],int cnt,int sum,string s){
    if(cnt==4){
        if(sum==7&&k==0) cout<<s+"=7"<<endl,k++;
        return ;
    }

    dfs(a,cnt+1,sum+a[cnt],s+"+"+to_string(a[cnt]));
    dfs(a,cnt+1,sum-a[cnt],s+"-"+to_string(a[cnt]));
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int a[4];
    rep(i,4) a[i]=s[i]-'0';
    dfs(a,1,a[0],to_string(a[0]));
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  int a;
  cin>>a;
  vector<int>v1(a);
  for(int i=0;i<a;i++){
    cin>>v1.at(i);
  }
  sort(v1.begin(),v1.end());
  ll count=1;
  ll goukei=0;
  ll d=v1.at(0);
  if(a==1){
    if(d==1){
      cout<<0<<endl;
    }
    else{
      cout<<1<<endl;
    }
  }
  
  else{
  for(int j=1;j<a;j++){
    ll e=v1.at(j);
    if(e==d){
      count++;
      if(j==a-1){  
        if(count>=d){
        goukei+=(count-d);
      }
      else{
        goukei+=count;
      }
      }       
    }
    else{
      if(count>=d){
        goukei+=(count-d);
        d=e;
        count=1;
      }
      else{
        goukei+=count;
        d=e;
        count=1;
      }
      if(j==a-1){
        if(e>1){
          goukei++;
        }
      }
    }
  }
  cout<<goukei<<endl;
  }
}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll n=s.size()-1;
	if(s[n]=='s'){
		cout << s<<"es";
	}
	else{
		cout << s<<"s";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3624
# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def sum_of_digits(n):
    s = 0
    while n > 0:
        s += n % 10
        n = n // 10
    return s


N, A, B = invr()

S = 0
for i in range(1, N+1):
    s = sum_of_digits(i)
    if s >= A and s <= B:
        S += i
print(S)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    b = sorted(a)
    return b[-1] - b[0]


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3060
R = range(8)
A = [4,1,4,1,2,1,2,1]
A += A
B = "41412121"
B = map(int, [B[i:]+B[:i] for i in R])

import sys
for s in sys.stdin:
  x = map(int, s[:-1].split())
  m = sum(x)
  for i in R:
    s = sum([max(0, x[j] - A[i+j]) for j in R])
    if s<m: m,p = s,B[i]
    elif m==s and B[i]<p: p=B[i]
  a= " ".join(list(str(p)))
  print a

Measured memory_bytes: 4244
#include <iostream>

using namespace std;

int main()
{
	char buf[11];
	while ( cin >> buf ) {
		for (int i=0; i<10; i++) buf[i] -= '0';
		for (int i=9; i>0; i--) {
			for (int j=0; j<=i; j++) buf[j] = (buf[j] + buf[j+1]) % 10;
		}
		cout << static_cast<int>(buf[0]) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3108
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
std::deque<int32_t> arr;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		int a;
		in >> a;
		if (i & 1) {
			arr.push_front(a);
		}
		else {
			arr.push_back(a);
		}
	}
	if (N & 1) {
		auto iter = arr.rbegin();
		out << *iter; ++iter;
		for (; iter != arr.rend(); ++iter) {
			out << ' ' << *iter;
		}
	}
	else {
		auto iter = arr.begin();
		out << *iter; ++iter;
		for (; iter != arr.end(); ++iter) {
			out << ' ' << *iter;
		}
	}
	out << endl;
	return 0;
}
#endif


Measured memory_bytes: 3072
from collections import Counter

N = int(input())
As = list(map(int, input().split()))

lst = [0]*N

for i in range(N):
  if As[i] % 4 == 0:
    lst[i] = 4
  elif As[i] % 2 == 0:
    lst[i] = 2
  else:
    lst[i] = 1
    
dic = Counter(lst)
  
if dic[1] <= dic[4]:
  print('Yes')
elif dic[1] - dic[4] == 1 and dic[2] == 0:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 87780
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ s, c ] <- readInts
	let
		r1 = min s $ c `div` 2
		c' = c - 2 * r1
		r2 = c' `div` 4
	print $ r1 + r2

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> f;
    f.push_back(".......................................................");
    rep(i, H)
    {
        string input;
        cin >> input;
        f.push_back("." + input + ".");
    }
    f.push_back(".......................................................");
    vector<string> answer;
    for (int i = 1; i <= H; ++i)
    {

        for (int j = 1; j < f[i].size() - 1; j++)
        {
            int ans = 0;

            if (f[i][j] == '#')
            {
                cout << "#";
            }
            else
            {
                for (int k = 0; k < 3; ++k)
                {
                    for (int l = 0; l < 3; ++l)
                    {

                        if (f[i + k - 1][j + l - 1] == '#')
                        {
                            ans++;
                        }
                    }
                }
                cout << ans;
            }
        }
        cout << endl;
        //answer.push_back(temp);
    }
}


Measured memory_bytes: 256
def geti; gets.to_i end
def getis; gets.split.map &:to_i end
def getin n;  n.times.map{geti}  end
def getisn n; n.times.map{getis} end
YES = "YES"; NO = "NO"; Yes = "Yes"; No = "No";

a,b=getis
p (a+b+1)/2

__END__
n,a,b=getis
puts (1..n).select{|s| c=s.to_s.chars.map(&:to_i).reduce(:+); a<=c&&c<=b }.reduce(:+)

a,b,c,d=getis
puts %w(Balanced Left Right)[a+b<=>c+d]

puts (gets.sub(?\s,'').to_i**0.5)%1==0? "Yes" : "No"

a,b=getis
puts a*b%2==0? "Even" : "Odd"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#define int ll
#define MOD ll(1e9+7)
vector<vector<ll>> memo(22, vector<ll>(2e6+1e5, -1));

int binpow(int a, int b){
	int res = 1;
	while(b){
		if(b % 2)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

ll dp(vector<vector<int>> &v, int mmask, int i){
	if(i == v.size())
		return 1;
	if(memo[i][mmask] != -1)
		return memo[i][mmask];
	memo[i][mmask] = 0;
	for(int e : v[i]){
		if(mmask & binpow(2, e)){
			memo[i][mmask] = (memo[i][mmask] + dp(v, mmask & (binpow(2, 21)-1-binpow(2, e)), i+1)) % MOD;
		}
	}
	return memo[i][mmask];
}

signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n; 
	cin>>n;
	vector<vector<int>> v(n);
	for(int i = 0; i <n; i++){
		for(int j = 0; j < n; j++){
			int a;
			cin>>a;
			if(a)
				v[i].push_back(j);
		}
	}
	cout<<dp(v, binpow(2, 21)-1, 0);
	
}


Measured memory_bytes: 377600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int N,M,ans=0;
  cin>>N>>M;
  unordered_map<int,vector<int>> mp;//価値と日数
  priority_queue<int> q;
  for(int i=0;i<N;i++){
    int a,b;//aは何日かかるか、bは価値
    cin>>a>>b;
    mp[a].push_back(b);
    if(a==1){q.push(b);}
  }
  for(int i=1;i<=M;i++){//i日前
    if(!q.empty()){
      ans+=q.top();
      q.pop();
    }
    if(i<M){
      for(int j=0;j<(int)mp[i+1].size();j++){
        q.push(mp[i+1].at(j));
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(){

  int h, a[300];

  cin >> h;
  for(int i = 1;i <= h;i++) cin >> a[i];

  for(int i = 1;i <= h;i++){
    cout << "node " << i << ": ";
    cout << "key = " << a[i] << ", ";
    if(i / 2 != 0) cout << "parent key = " << a[i / 2] << ", ";
    if(2 * i <=h) cout << "left key = " << a[2 * i] << ", ";
    if(2 * i + 1 <= h) cout << "right key = " << a[2 * i + 1] << ", ";
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3032
#include <string>
#include <cstdio>
using namespace std;

int main(){
    char s[10];
    scanf("%s",s);
    if(s[1]==s[0]&&s[2]==s[0]) printf("Yes\n");
    else if(s[1]==s[2]&&s[1]==s[3]) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i,j,k,n,s1=100000000,s2=0;
	string st;
	cin>>st;
	for(i=0;i<st.length();i++)
	if(st[i]=='C'){
		s1=i;
		break;
	}
	for(i=st.length()-1;i>=0;i--)
	if(st[i]=='F'){
		s2=i;
		break;
	}
	if(s1<s2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
using namespace std;

char str1[1010], str2[1010];
int f[1010][1010];
int main(){
	int q = 0;
	cin >> q;
	while (q--) {
		scanf("%s%s", str1 + 1, str2 + 1);
		int m = strlen(str1+1);
		int n = strlen(str2+1);
		f[0][0] = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				if (str1[i] == str2[j]) 
					f[i][j] = f[i-1][j-1]+1;
				else f[i][j] = 0;
				f[i][j] = max(f[i][j],f[i-1][j]);
				f[i][j] = max(f[i][j],f[i][j-1]);

			}
		}
		printf("%d\n", f[m][n]);
		
	
	}
	return 0;
    
}


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

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

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;

    long long int ans = 0;

    ans += (n / (a+b)) * a;
    ans += min(a, n % (a+b));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int h, w, q;
  cin >> h >> w >> q;
  vector<string> mp(h);
  for (int i = 0; i < h; i++)
    cin >> mp[i];
  int lrdp[h + 1][w + 1];
  int uddp[h + 1][w + 1];
  int bdp[h + 1][w + 1];
  for (int i = 0; i <= h; i++)
    for (int j = 0; j <= w; j++)
      lrdp[i][j] = uddp[i][j] = bdp[i][j] = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      bdp[i + 1][j + 1] =
          bdp[i][j + 1] + bdp[i + 1][j] - bdp[i][j] + (mp[i][j] == '1' ? 1 : 0);
    }
  for (int i = 1; i < h; i++)
    for (int j = 0; j < w; j++) {
      uddp[i + 1][j + 1] =
          uddp[i][j + 1] + uddp[i + 1][j] - uddp[i][j] +
          (mp[i][j] == mp[i - 1][j] && mp[i][j] == '1' ? 1 : 0);
    }
  for (int i = 0; i < h; i++)
    for (int j = 1; j < w; j++) {
      lrdp[i + 1][j + 1] =
          lrdp[i][j + 1] + lrdp[i + 1][j] - lrdp[i][j] +
          (mp[i][j] == mp[i][j - 1] && mp[i][j] == '1' ? 1 : 0);
    }
  for (int i = 0; i < q; i++) {
    int x, y, x2, y2;
    cin >> y >> x >> y2 >> x2;
    int vsum =
        bdp[y2][x2] + bdp[y - 1][x - 1] - bdp[y2][x - 1] - bdp[y - 1][x2];
    int udsum = uddp[y2][x2] + uddp[y][x - 1] - uddp[y2][x - 1] - uddp[y][x2];
    int lrsum = lrdp[y2][x2] + lrdp[y - 1][x] - lrdp[y2][x] - lrdp[y - 1][x2];
    cout << vsum - udsum - lrsum << endl;
  }
  return 0;
}


Measured memory_bytes: 53948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
   
    
  int main(){
      lint N;
      cin >>N; lint A[N];
      rep(i,N)cin >> A[i];
      lint ans=INF;
       repp(j,1,101){
            lint sum=0;
    rep(i,N){
       
        sum+=(j-A[i])*(j-A[i]);
        }
    ans=min(ans,sum);
    }
    cout<<ans;
    }
     
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b;
  cin >> a >> b;
  int ans = max(a+b,max(a*b,a-b));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

struct B{
	int b;
	int c;
};

int main() {
	
	int N;
	cin>>N;
	vector<vector<B>> F(N+1);
	fx(N-1){
		int a,b,c;
		cin>>a>>b>>c;
      
		B A,AA;
		A.b=b;
		A.c=c;
      AA.b=a;
      AA.c=c;
		pb(F.at(a),A)
          pb(F.at(b),AA)
	}
	int Q,K;
	cin>>Q>>K;
	ll dp[N+1];
  bool flag[N+1];
	fx(N+1){
		dp[x]=INT_MAX;
      flag[x]=false;
	}
	dp[K]=0;
	queue<int> J;
	J.push(K);
	while(J.size()>0){
		int k=J.front();
		J.pop();
      flag[k]=true;
		fy(F.at(k).size()){
                    if(!flag[F.at(k).at(y).b]){
			dp[F.at(k).at(y).b]=dp[k]+F.at(k).at(y).c;

			J.push(F.at(k).at(y).b);
                    }
		}
	}
	
	fz(Q){
		int x,y;
		cin>>x>>y;
		ce(dp[x]+dp[y])
	}
}

Measured memory_bytes: 8820
def main():
  s = input()
  if len(s) == 2 and s[0] == s[1]:
    print(1, 2)
    return
  for i in range(len(s)-2):
    if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:
      print(i+1, i+3)
      return
  print(-1, -1)
  return

if __name__ == '__main__':
  main()


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  ll n;cin>>n;
  ll a,b;cin>>a>>b;
  ll mi=(a+b-n>=0?a+b-n:0);
  out(min(a,b)<<" "<<mi);

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s  << endl;
 
}

Measured memory_bytes: 3592
from collections import deque

H, W = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
c1 += 1
c2 += 1
d1 += 1
d2 += 1
S = ["#"*(W+4)]*2 + ["##"+input()+"##" for _ in range(H)] + ["#"*(W+4)]*2

ans = [[10000000]*(W+4) for _ in range(H+4)]
ans[c1][c2] = 0
q = deque([[c1, c2]])

x = [[-1, 0], [0, -1], [0, 1], [1, 0]]

while q:
    h, w = q.popleft()
    
    for a, b in x:
        nh = h+a
        nw = w+b
        if S[nh][nw] == ".":
            if ans[nh][nw] > ans[h][w]:
                ans[nh][nw] = ans[h][w]
                q.appendleft([nh, nw])
    
    for a in range(-2, 3):
        for b in range(-2, 3):
            nh = h+a
            nw = w+b
            if S[nh][nw] == ".":
                if ans[nh][nw] > ans[h][w]+1:
                    ans[nh][nw] = ans[h][w]+1
                    q.append([nh, nw])

if ans[d1][d2] == 10000000:
    print(-1)
else:
    print(ans[d1][d2])

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

int main() {
	// 毎日N人が到着
	// バス1台の定員がc人
	// 乗客は到着時刻からkだけ待ってくれる
	ll n,c,k;cin >> n >> c >> k;
	vector<ll> t(n);
	rep(i,n) cin >> t.at(i);
	sort(t.begin(),t.end());

	ll ans = 0;
	//現在時刻
  ll now = t.at(0);
	// 待たせている時間
	ll time = 0;
	// 乗客数
	ll cnt = 0;
  rep(i,n){
		if( i == 0 ){
			time = 0;
			now = t.at(i);
			cnt = 1;
		}else{
			time += t.at(i) - now;
			now = t.at(i);
			++cnt;
			if( time > k ){
				++ans;
				time = 0;
				cnt = 1;
			}else if( cnt > c ){
				++ans;
				time = 0;
				cnt = 1;
			}
		}
	}
	cout << ans+1 << endl;

	return 0;
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var vals = Console.ReadLine().Split(' ').ToArray();
        var str = string.Empty;
        for (int i = 0; i < n; i++)
        {
            str += vals[0].Substring(i, 1) + vals[1].Substring(i, 1);
        }
        Console.WriteLine(str);
    }
}


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

using namespace std;

int main(){
  int n;bool flag = false;
  cin >> n;
  for(int i = 1;i < 10;i++){
    for(int j = 1;j < 10;j++){
      if(n == i*j)flag = true;
    }
  }
  if(flag)cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
typedef long long lint;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define all(x) (x).begin(),(x).end()

#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
struct BIT2D{
    vector<vector<lint>> bit;
    lint n,m;
    BIT2D(lint n,lint m):n(n),m(m){
        bit.resize(n+1,vector<lint>(m+1,0));
    }
    //1-indexed ([1,x],[1,y])-sum
    lint get(lint x,lint y){
        lint res=0;
        for(lint i=x;i>0;i-=i&-i)for(lint j=y;j>0;j-=j&-j)res+=bit[i][j];
        return res;
    }
    lint get(lint x1,lint y1,lint x2,lint y2){
        return get(x2,y2)-get(x1-1,y2)-get(x2,y1-1)+get(x1-1,y1-1);
    }
    //1-indexed
    void add(lint x,lint y,lint val){
        if(x>n||y>m)return;
        for(lint i=x;i<=n;i+=i&-i)for(lint j=y;j<=n;j+=j&-j)bit[i][j]+=val;
    }
};

int main(){
    BIT2D bit=BIT2D(1010,1010);
    lint n;
    cin>>n;
    rep(i,n){
        lint a,b,c,d;
        cin>>a>>b>>c>>d;
        bit.add(a+1,b+1,1);
        bit.add(a+1,d+1,-1);
        bit.add(c+1,b+1,-1);
        bit.add(c+1,d+1,1);
    }
    lint M=0;
    repi(i,1,1001)repi(j,1,1001){
        M=max(M,bit.get(i,j));
    }
    cout<<M<<endl;
}


Measured memory_bytes: 10688
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
	int i, j, k, l;
	int a[3], b[3];

	cin >> a[0] >> b[0] >> a[1] >> b[1] >> a[2] >> b[2];

	int temp = 0;

	for (i = 1; i < 5; i++)
	{
		j = 0;

		if (a[0] == i || b[0] == i)
		{
			j++;
		}
	
		if (a[1] == i || b[1] == i)
		{
			j++;
		}

		if (a[2] == i || b[2] == i)
		{
			j++;
		}

		if (j == 0)
		{
			printf("NO");
			return 0;
		}
		else
			if (j == 1)
			{
				continue;
			}
			else
			{
				temp++;
			}
	}

	if (temp == 2)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}

	return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include <limits.h>  

#define WHITE 0
#define BLACK 1
#define MAX 100
#define NIL -1

int d[MAX];
int w[MAX][MAX];
int color[MAX];

int main(){

  int n,i,j,mincost,u,v,cost=0;

scanf("%d", &n);

 for(i = 0 ; i < n ; i++)
   for(j = 0 ; j < n ; j++)
     scanf("%d",&w[i][j]);

for(i = 0 ; i < n ; i++){
  d[i] = INT_MAX;
  color[i] = WHITE;
 }

 d[0] = 0;

 while(1){
   mincost = INT_MAX;

   for(i = 0 ; i < n ; i++){
     if(d[i] < mincost && color[i] == WHITE){
       mincost = d[i];
       u = i;
     }
   }

   if(mincost == INT_MAX) break;
   cost += mincost;
   color[u] = BLACK;
    
   for(v = 0 ; v < n ; v++){
     if(w[u][v] == NIL) continue;
     if(d[v] > w[u][v]) d[v] = w[u][v];
     
   }
 }

 printf("%d\n",cost);

 return 0;

}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<String> box = new ArrayList<>();
        int amount = sc.nextInt();
        String each = null;
        for (int i = 0; i < amount; i++) {
            box.add(sc.next());
        }
        List<String> list = new ArrayList<String>(new LinkedHashSet<>(box));
        System.out.println(list.size());
    }
}

Measured memory_bytes: 78684
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, L;

int main(){
  cin >> N >> L;
  
  int m = INFi;
  int s = 0;
  REP(i, N) {
    s += L + i;
    if(abs(m) > abs(L + i)) {
      m = L + i;
    }
  }

  cout << s - m << endl;


  return 0;
}


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

using namespace std;

int main()
{
	string o;
	string e;
	string p;
	int i;
	cin>>o;
	cin>>e;

	if(o.size()>e.size())
	{
		for(i=0;i<e.size();i++)
		{
			p+=o[i];
			p+=e[i];
		}
		p+=o[i];
	}else{
		for(i=0;i<e.size();i++)
		{
			p+=o[i];
			p+=e[i];
		}
	}
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;

int main(){
    string S;
    cin >> S;
    int ans[100010] = {0};
    bool lcount = false;
    bool rcount = true;
    int r = 0;
    int l = 0;
    int nowR = 0;
    for(int i = 0;i < S.length();i++){
        if(rcount == true && S[i] == 'R')r++;
        else if(rcount == true && S[i] == 'L'){lcount = true;rcount = false;l++;nowR = i-1;}
        else if(lcount == true && S[i] == 'R'){
            if(r % 2 == 1){
                ans[nowR]+=r/2+1;
                ans[nowR+1]+=r/2;
            }
            else{
                ans[nowR]+=r/2;
                ans[nowR+1]+=r/2;
            }
            if(l % 2 == 1){
                ans[nowR]+=l/2;
                ans[nowR+1]+=l/2+1;
            }
            else{
                ans[nowR]+=l/2;
                ans[nowR+1]+=l/2;
            }
            r = 0;
            l = 0;
            rcount = true;lcount = false;r++;
        }
        else l++;
    }
    
    if(r % 2 == 1){
        ans[nowR]+=r/2+1;
        ans[nowR+1]+=r/2;
    }
    else{
        ans[nowR]+=r/2;
        ans[nowR+1]+=r/2;
    }
    if(l % 2 == 1){
        ans[nowR]+=l/2;
        ans[nowR+1]+=l/2+1;
    }
    else{
        ans[nowR]+=l/2;
        ans[nowR+1]+=l/2;
    }

    for(int i = 0;i < S.length();i++){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> happi(n, vector<int>(3, 0));
	for (auto& day : happi)
		cin >> day[0] >> day[1] >> day[2];

	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0] = happi[0];
	/*cout << endl;*/
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3] + happi[i][j], dp[i - 1][(j + 2) % 3] + happi[i][j]);
		}

		/*copy(dp[i].begin(), dp[i].end(), ostream_iterator<int>(cout, " "));
		cout << endl;*/
	}
	
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;


ll N, X;
ll ans = 0;
ll A[51];
ll P[51];


ll a(int level) {
	if (A[level] != -1) return A[level];
	else return A[level] = 2 * a(level - 1) + 3;
}

ll p(int level) {
	if (P[level] != -1) return P[level];
	else return P[level] = 2 * p(level - 1) + 1;
}

ll dfs(ll remain, ll level) {
	//if (level == 0) return (remain <= 0) ? 0 : 1;
	if (remain == 1) return (level == 0) ? 1 : 0;
	else if (remain <= 1 + a(level - 1)) return dfs(remain - 1, level - 1);
	else if (remain == 2 + a(level - 1)) return p(level - 1) + 1;
	else if (remain <= 2 + 2 * a(level - 1)) return p(level - 1) + 1 + dfs(remain - 2 - a(level - 1), level - 1);
	else return p(level);
}

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

	for (int i = 0; i < 51; i++) A[i] = P[i] = -1;
	A[0] = 1;
	P[0] = 1;

	cout << dfs(X, N) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,N,M;
  cin >> N >> M;
  vector<int>DP(N+1,0),issafe(N+1,1);
  rep(i,0,M){
    cin >> A;
    issafe[A]=0;
  }
  DP[0]=1;
  if(issafe[1])DP[1]=1;
  rep(i,2,N+1){
    if(issafe[i-2])DP[i]+=DP[i-2];
    if(issafe[i-1])DP[i]+=DP[i-1];
    DP[i]%=mod;
  }
  Out(DP[N]);
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int

using namespace std;


int main() {
    char S[101010];
    scanf("%s", S);
    bool app[26];
    for (int i = 0; i < 26; ++i) {
        app[i] = false;
    }
    for (int i = 0; S[i] != '\0'; ++i) {

        app[S[i] - 'a'] = true; // aを0番目としたときのアルファベットが何番目かを表す
        // cout << S[i] - 'a' <<endl;
    }
    for (int i = 0; i < 26; ++i) {
        if (!app[i]) {
            // (char) (i + 'a') -> i番目のアルファベットを表す
            printf("%c\n", (char) (i + 'a'));
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int n; cin >> n;
	vector<pair<int, int> > xl(n);
	for (auto& e : xl) cin >> e.first >> e.second;
	sort(xl.begin(), xl.end());
	int s = -2e9;
	int ans = n;
	for (int i = 0; i < n; ++i) {
		if (s > xl[i].first - xl[i].second) {
			if (s > xl[i].first + xl[i].second) s = xl[i].first + xl[i].second;
			--ans;
		} else s = xl[i].first + xl[i].second;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
class dice:
    def __init__(s, i):
        s.d1,s.d2,s.d3,s.d4,s.d5,s.d6 = map(int, i)
    
    def W(s):
        tmp = s.d1
        s.d1 = s.d3
        s.d3 = s.d6
        s.d6 = s.d4
        s.d4 = tmp
        
    def E(s):
        tmp = s.d1
        s.d1 = s.d4
        s.d4 = s.d6
        s.d6 = s.d3
        s.d3 = tmp
        
    def N(s):
        tmp = s.d1
        s.d1 = s.d2
        s.d2 = s.d6
        s.d6 = s.d5
        s.d5 = tmp
        
    def S(s):
        tmp = s.d1
        s.d1 = s.d5
        s.d5 = s.d6
        s.d6 = s.d2
        s.d2 = tmp
        
dice1 = dice(input().split())
lst = list(input())
for s in lst:
    eval("dice1." + s)()
print(dice1.d1)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;
inline void add(long long &a, long long b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += md;
}

inline long long mul(long long a, long long b) {
  return (long long) ((long long) a * b % md);
}

inline long long inv(long long a) {
  a %= md;
  if (a < 0) a += md;
  long long b = md, u = 0, v = 1;
  while (a) {
    long long t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> n >> k;
    for(i = k; i <= n+1; i++){
        x = mul(i,i-1);
        l = inv((ll)2);
        x = mul(x,l);
        y = mul(n,i);
        sub(y,x);
        sub(y,x);
        add(y,1);
        add(sum,y);
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

typedef long long ll;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N, M;
	cin >> N >> M;

	double ans = 0;
	double _pow = 1.0 / pow(2, M);
	ll time = 1900 * M;
	for(int i = 1; i <= 100000; i++)
	{
		ans += time * _pow;
		_pow *= 1.0 - (1.0 / pow(2, M));
		time += 1900 * M + (N - M) * 100;
	}

	ans += (N - M) * 100;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
str = $stdin.gets.chomp

ans = "Yes"

for i in 0..str.size - 1
    if i % 2 == 1
        if str[i] != "L" and str[i] != "U" and str[i] != "D"
            ans = "No"
            break
        end
    else
        if str[i] != "R" and str[i] != "U" and str[i] != "D"
            ans = "No"
            break
        end
    end
end

puts ans

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

int main(){
  int n,sumb=0,a[101],b[101];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    sumb+=b[i];
  }
  int sumA=0;
  int mx=0;
  for(int i=0;i<n;i++){
   int sum=(sumA+a[i]+sumb);
    sumA+=a[i];
    sumb-=b[i];
    mx=max(mx,sum);
  }
  cout<<mx<<endl;
}
    

Measured memory_bytes: 256