akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C;
            if (A == 1)
            {
                if (B == 2)
                    C = 3;
                else
                    C = 2;
            }
            else if (A == 2)
            {
                if (B == 1)
                    C = 3;
                else
                    C = 1;
            }
            else
            {
                if (B == 1)
                    C = 2;
                else
                    C = 1;
            }
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
	long x;
	int h, m, s;
	
	h=0; m=0; s=0;
	
	scanf("%ld", &x);

	
	if(x>0){
		s = x%60;
	}
	if(x>=60){
		m = x % 3600-s;
		//printf("m %d\n", m);
		m = m/60;
	}
	if(x>=3600){
		h = x / 3600;
	}
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, r, p, c;
	int i,j;
	while (cin >> n >> r) {
		if (n == 0 && r == 0)break;
		int sta[50]; int copsta[50];
		for (i = 0; i < n; i++) {
			sta[i] = n-i;
		}
		for (i = 0; i < r; i++) {
			for (j = 0; j < n; j++) {
				copsta[j] = sta[j];
			}
			cin >> p >> c;
			for (j = 0; j < p + c - 1; j++) {
				if (j < c) {
					sta[j] = copsta[j + p-1];
				}
				else sta[j] = copsta[j - c];
			}
		}
		cout << sta[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
k,n = map(int,input().split())
a_ = list(map(int,input().split()))

#N個の区間の中で最大距離の区間以外の和を取ると良い
disList = []
for i in range(n):
    if i == n-1:
        dis = k - a_[i] + a_[0]
        disList.append(dis)
    else:
        dis = a_[i+1] - a_[i]
        disList.append(dis)
max = max(disList)
print(k - max)


Measured memory_bytes: 26420
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;  ll T;
  cin >> N >> T;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  vector<ll> B(N);
  ll M = A[N-1];
  for(int i=N-1; i>=0; i--) {
    if(M - A[i] > 0) {
      B[i] = M - A[i];
    } else {
      M = A[i];
    }
  }
  sort(B.begin(), B.end());
  int tmp;
  for(int i=N-1; i>=0; i--)
    if(B[i] != B[N-1]) {
      tmp = i;
      break;
    }
  cout << N - tmp - 1 << endl;
  return 0;
}


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

int main(void) 
{
   int a, b;
   cin >> a >> b;
   cout << a*b <<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll P, Q, R;
    cin >> P >> Q >> R;

    cout << min(P+Q, min(Q+R, R+P)) << endl;
}

Measured memory_bytes: 256
function Main(input) {
    const args = input.split(' ');
	const tree = parseInt(args[0], 10);
    const bin = parseInt(args[1], 10);
    
    var unit = bin * 2 + 1;
    var watcher = Math.ceil(tree/unit)
    console.log(watcher);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
int main()
{
    int a,b,c,temp,p;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b && a>=c)
    {
        if(b>=c)
            ;
        else
        {
            temp=b;
            b=c;
            c=temp;
        }
    }
    else if(b>=a && b>=c)
    {
        temp=b;
        b=a;
        a=temp;
        if(b>=c)
            ;
        else
        {
            temp=b;
            b=c;
            c=temp;
        }
    }
    else if(c>=a && c>=b)
    {
        temp=c;
        c=a;
        a=temp;
        if(b>=c)
            ;
        else
        {
            temp=b;
            b=c;
            c=temp;
        }
    }
    p=(a*10)+b+c;
    printf("%d",p);

}

Measured memory_bytes: 128
from collections import deque

n,m = map(int, input().split())
c = [[] for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0

for i in range(m):
    a,b = map(int, input().split())
    c[a-1].append(b-1)
    c[b-1].append(a-1)

# 部屋 1 をキューに入れる
que = deque([])
que.append(0)

while que:
    # キューの先頭を取り出す
    p = que.popleft()
    # 今いる部屋と繋がっている部屋を順番に探索
    for i in c[p]:
        # すでに訪れたことがあるかの判定
        if d[i] != -1:
            continue
            # 移動できるならキューに入れ、その部屋の道しるべを p で確定する
        que.append(i)
        d[i] = p

print("Yes")
for i in d[1:]:
    print(i+1)


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) cin >> D[i];

    bool flag = true;
    REP(i, N) {
        if (D[i]%2 == 0) {
            if (D[i]%3 == 0 || D[i]%5 == 0) {
                continue;
            } else {
                flag = false;
                break;
            }
        }
    }
    if (flag) print("APPROVED");
    else print("DENIED");
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#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 ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}



int main() {
  int K;
  cin >> K;
  
  queue<long>a;
  a.push(1);
  a.push(2);
  a.push(3);
  a.push(4);
  a.push(5);
  a.push(6);
  a.push(7);
  a.push(8);
  a.push(9);
  while(K){
  long x=a.front();a.pop();
  K--;
  if(K==0){
    cout<<x<<endl;
  }
  if(x%10!=0){
    a.push(10*x+x%10-1);
  }
  a.push(10*x+x%10);
  if(x%10!=9){
    a.push(10*x+x%10+1);
  }
  }
}





Measured memory_bytes: 1792
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()
a=[]
sum=0
for i in range(m-1):
    a.append(abs(x[i+1]-x[i]))
a.sort()
plus=len(a)-n+1
for i in range(plus):
    sum+=a[i]
print(sum)

Measured memory_bytes: 13832
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std;


int main(){
    ll l,r;
    cin>>l>>r;
    ll ans=20190;
    if(r-l>=2019) ans=0;
    else{
        for(ll i=l;i<=r;i++){
            for(ll j=l;j<=r;j++){
                if(i==j) break;
                // cout<<i*j<<endl;
                else ans=min(ans,(i*j)%2019);
                // cout<<ans<<endl;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var Q = int.Parse(Console.ReadLine());
            var dict = new Dictionary<long, long>();
            var answer = 0L;
            for (var i = 0; i < A.Length; i++)
            {
                if (dict.ContainsKey(A[i])) dict[A[i]]++;
                else dict[A[i]] = 1L;
                answer += A[i];
            }

            for (var i = 0; i < Q; i++)
            {
                var BC = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
                var B = BC[0];
                var C = BC[1];
                if (!dict.ContainsKey(B)) dict[B] = 0L;
                if (!dict.ContainsKey(C)) dict[C] = 0L;
                dict[C] += dict[B];
                answer += (C - B) * dict[B];
                dict[B] = 0L;
                Console.WriteLine(answer);
            }
        }
    }
}


Measured memory_bytes: 49916
bit=require("bit")
n,m,x=io.read("*n","*n","*n","*l")
c={}
a={}
for i=1,n do
    c[i]=io.read("*n")
    a[i]={}
    for j=1,m do
        a[i][j]=io.read("*n")
    end
end

total=-1
for i=0,bit.lshift(1,n)-1 do
    icopy=i
    price=0
    xable={}
    for j=1,m do
        xable[j]=0
    end
    for j=1,n do
        if icopy%2==1 then
            for k=1,m do
                xable[k]=xable[k]+a[j][k]
            end
            price=price+c[j]
        end
        icopy=bit.rshift(icopy,1)
    end
    xbove=true
    for j=1,m do
        if xable[j]<x then
            xbove=false
        end
    end
    if xbove then
        if total==-1 then
            total=price
        else
            total=math.min(total,price)
        end
    end
end
print(total)


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

int main() {
  int x, y, z, tmp;
  cin >> x >> y >> z;
  tmp = y;
  y = x;
  x = tmp;
  tmp = z;
  z = x;
  x = tmp;
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<map>
#define mod  998244353
#define int long long int
int32_t main()
{
     int k,t;
     cin>>k>>t;
     multimap<int,int> mp;
     int j,prev=0;
     for(j=1;j<=t;j++)
     {
		 int x;
		 cin>>x;
		 mp.insert({x,j});
	 }
	 int answer=0;
	 while(mp.size()!=0)
	 {
		 auto it=mp.end();
		 it--;
		 if(it->second==prev)
		 {
			 if(mp.size()==1)
			 {
				 answer+=(it->first);
				 break;
			 }
			 it--;
			 int val=it->first-1;
			 int type=it->second;
			 mp.erase(it);
			 prev=type;
			 if(val!=0)
			    mp.insert({val,type});
		 }
		 else
		 {
			 int val=it->first-1;
			 int type=it->second;
			 prev=type;
			 mp.erase(it);
			 if(val!=0)
			   mp.insert({val,type});
		 }
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char s[201],p[101],q[101];
    scanf("%s %s",s,p);
    strcpy(q,s);
    strcat(s,q);
    if(strstr(s,p) == NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
    
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T min_index(const vector<T>& v) {
    return distance(v.begin(), min_element(v.begin(), v.end()));
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

template<class T> T max_index(const vector<T>& v) {
    return distance(v.begin(), max_element(v.begin(), v.end()));
}

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

    next<int>(); next<int>();
    int ans = 0;
    int x, y;

    times(next<int>(), j) {
        int X = next<int>(), Y = next<int>();
        unless(j) {
            x = X;
            y = Y;
        }
        x -= X; y -= Y;
        #ifdef debug
            cout << "(" << x << "," << y << ")\t"
                 << ans << " += " << x * y << " > 0 ? " << max(abs(x), abs(y)) << " : " << abs(x) + abs(y) ln;
        #endif
        ans += x * y >= 0 ? max(abs(x), abs(y)) : abs(x) + abs(y);
        x = X;
        y = Y;
    }

    cout << ans ln;

    return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>

int main(){
	int n , m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//int r,d,x;
	while(cin >> n >> m){
		int l = 1,r = n;
		f(m){
			int add1,add2;
			cin >> add1 >> add2;
			l=max(l,add1);
			r=min(r,add2);
		}
		int ans=r-l+1;
		cout << max(ans,0) << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(int data[],int size);

int main()
{
    int n=0;
    int x,y,z;
    int i;
    int f[60010]={0};

    scanf("%d",&n);

    for(x=1;x<=100;x++)
    {
        for(y=1;y<=100;y++)
        {
            for(z=1;z<=100;z++)
            {
                f[(x*x+y*y+z*z+x*y+y*z+z*x)]++;
            }
        }
    }

    for(i=1;i<=n;i++)
    {
        printf("%d\n",f[i]);
    }

}


Measured memory_bytes: 1956
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

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

    int ans = 0;
    int r = n-1;
    for (int l=0; l<r; l++) {
        if (s[l] == 'R') continue;
        while(l<r && s[r]=='W') r--;
        if (s[l] == 'W' && s[r] == 'R') {
            s[l] = 'R';
            s[r] = 'W';
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3484
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

string N;
ll f(ll d, bool u3, bool u5, bool u7, bool uN) {
    if (d == N.size()) {
        return u3 && u5 && u7;
    }

    if (uN) {
        return f(d + 1, true, u5, u7, uN)
            + f(d + 1, u3, true, u7, uN)
            + f(d + 1, u3, u5, true, uN);
    } else {
        if (N[d] >= '7') {
            return f(d + 1, true, u5, u7, N[d] > '3')
                + f(d + 1, u3, true, u7, N[d] > '5')
                + f(d + 1, u3, u5, true, N[d] > '7');
        } else if (N[d] >= '5') {
            return f(d + 1, true, u5, u7, N[d] > '3')
                + f(d + 1, u3, true, u7, N[d] > '5');
        } else if (N[d] >= '3') {
            return f(d + 1, true, u5, u7, N[d] > '3');
        } else {
            return 0;
        }
    }
}

int main() {
    cin >> N;

    ll ans = 0;
    for (ll i = 0; i < (ll)N.size() - 2; i++) {
        ans += f(i, false, false, false, i != 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = breads >>= print . solve 

-- | 
-- >>> solve [3,2]
-- 9
-- >>> solve [5, 3]
-- 1
-- >>> solve [31415,9265]
-- 27
-- >>> solve [35897,932]
-- 114191
solve :: [Int] -> Int 
solve [n, k]
    | odd k = zn ^ 3
    | otherwise = zn ^ 3 + hn ^ 3
    where
        zn = foldl' ff1 0 [1..n]
        hn = foldl' ff2 0 [1..n]

        ff1 acc x 
            | x `mod` k == 0 = acc + 1
            | otherwise = acc
        ff2 acc x 
            | x `mod` k == hk = acc + 1
            | otherwise = acc
        
        hk = k `div` 2

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 508
n, m, x = map(int, input().split())

books = list()
for _ in range(n):
    books.append(list(map(int, input().split())))


target = list()
result = -1

for i in range(2**n):
    score = [0] * m
    tmp = 0
    for j in range(n):
        bit = i >> (n-j-1) & 1
        if bit:
            score = [a + b for a, b in zip(score, books[j][1:])]
            tmp += books[j][0]

    if all([a >= x for a in score]):
        if result == -1:
            result = tmp
        else:
            result = min(result, tmp)

print(result)


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,M; cin >> N >> M;
    vector<ll> H(N),X(N,1);
    for(int i = 0; i < N; ++i) cin >> H[i];
    for(int i = 0; i < M; ++i) {
        int a,b; cin >> a >> b;
        a--,b--;
        if(H[a]<H[b]){
            X[a]=0;
        }
        if(H[a]>H[b]){
            X[b]=0;
        }
        if(H[a]==H[b]){
            X[a]=X[b]=0;
        }
    }
    cout << accumulate(ALL(X),0) << endl;

    return 0;
}


Measured memory_bytes: 4792
a, b = map(int, input().split())
s = input()
flag = True
for i, ss in enumerate(s):
  if i == a:
    if ss != '-':
      flag = False
  else:
    if ord(ss) not in range(ord('0'), ord('9')+1):
      flag = False

if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 998244353;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int cnt[100005];
int d[100005];
int modpow(int x, int n, int md) {
	if (!n)return 1;
	int res = modpow(x*x%md, n / 2, md);
	if (n & 1)res = res*x%md;
	return res;
}
signed main() {
	int n; cin >> n;
	int mx = 0;
	rep(i, n) {
		cin >> d[i];
		cnt[d[i]]++;
		mx = max(mx, d[i]);
	}
	int ans = 1;
	if (d[0] || cnt[0] != 1)ans *= 0;
	for (int i = 0; i < mx; i++) {
		ans *= modpow(cnt[i], cnt[i + 1], mod);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		double EPS=1e-10;
		for(;;)
		{
			int e=in.nextInt();
			if(e==0)
				return;
			int ans=Integer.MAX_VALUE;
			for(int z=0;z*z*z<=e;z++)
			{
				int y=(int) (Math.sqrt(e-z*z*z));
				int x=e-z*z*z-y*y;
				ans=Math.min(ans, x+y+z);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 24956
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;

    void solve() {
    	string a, b, c, s;
    	cin >> a >> b >> c;
    	putchar(toupper(a[0]));
    	putchar(toupper(b[0]));
    	putchar(toupper(c[0]));
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] A = new long[N];
        long[] B = new long[N];
        long[] C = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextLong();
        }

        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);

        // Bを固定して尺取り法
        int aIndex = 0;
        int cIndex = 0;
        long cnt = 0;
        for (int i = 0; i < N; i++) {

            // bより小さいところまで
            while (aIndex < N && A[aIndex] < B[i]) {
                aIndex++;
            }

            while (cIndex < N && C[cIndex] <= B[i]) {
                cIndex++;
            }

            cnt += (long) aIndex * (N - cIndex);
        }

        out.println(cnt);
    }
}

Measured memory_bytes: 99132
#include <cstdio>

int main(int argc, char const *argv[]) {
    int n, q, target;
    int findCount = 0; // ???????????£?????°????????°
    int inputSequence[100000];

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

    scanf("%d", &q);
    for(int i=0 ; i<q ; i++){
        scanf("%d", &target);
        int begin = 0, end = n-1;
        do{
            int current = (begin+end)/2;
            if(inputSequence[current] == target){
                findCount++;
                break;
            }
            // ?????????????????§????????????????????????
            else if(inputSequence[current] < target){
                begin = current + 1;
            }
            // ????????????????°?????????????????????????
            else if(inputSequence[current] > target){
                end = current - 1;
            }
        } while(begin <= end); // ????????¨????°??????\???????????£????????????
    }

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

Measured memory_bytes: 2972
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

// Self settings
// clang-format off
#define MAX_N 100000
#define mod 1000000007
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

typedef long long ll;
int N, M;
bool A[MAX_N];
int dp[MAX_N + 1];

int main(void)
{
  cin >> N >> M;
  REP(i, N) A[i] = true;
  REP(i, M)
  {
    int a;
    cin >> a;
    A[a] = false;
  }
  dp[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    // 壊れているならその階にはたどり着けないので0通りにする
    if (!A[i]) {
      dp[i] = 0;
      continue;
    }

    // 一個前か二個前からたどり着くための
    // 方法は何通りあるか確認する
    ll sum = 0;
    for (int j = 1; j <= 2; j++) {
      int idx = i + j;
      if (idx > N) continue;
      sum = (sum + dp[idx]) % mod;
    }
    dp[i] = sum;
  }

  // REP(i, N + 1) cout << dp[i] << SLN(i, N + 1);
  cout << dp[0] << endl;
  return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

int main() {
  int N,a,cnt=0;
  cin >> N;
  vector<int> A(1e5+1,0);
  rep(i,N) {
    cin >> a;
    if (A[a]) cnt++;
    A[a]++;
  }
  cout << N-cnt-cnt%2 << endl;
} 

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
long int operation(int n,long cnt,vector<long>sum,vector<long> a) {
	for (int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + a[i];
		if (sum[i - 1] > 0) {
			if (sum[i] >= 0) {
				cnt += sum[i] + 1;
				sum[i] = -1;
			}
		}
		else if (sum[i - 1] < 0) {
			if (sum[i] <= 0) {
				cnt += abs(sum[i]) + 1;
				sum[i] = 1;
			}
		}
	}
	return cnt;
}
int main() {
	int n;
	cin >> n;
	vector<long>sum(n),a(n),sum2(n);
	rep(i, n) {
		cin >> a[i];
	}
	long count = 0;
	long count2 = 0;
	sum[0] = a[0];
	if (sum[0]>0) {
		sum2[0] = -1;
		count2 += sum[0] + 1;
	}
	else if (sum[0] < 0) {
		sum2[0] = 1;
		count2 += abs(sum[0])+1;
	}
	else {
		sum[0] = 1;
		count++;
		sum2[0] = -1;
		count2++;
	}
	cout<<min(operation(n, count, sum, a) 
		,operation(n, count2, sum2, a))<< endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int n, k, ans;
char s[305];
int dp[305][305][305];
int dfs(int l, int r, int x) {
    if(l >= r) {
        return r - l + 1;
    }
    if(dp[l][r][x] != -1) {
        return dp[l][r][x];
    }
    int ret = max(dfs(l + 1, r, x), dfs(l, r - 1, x));
    if(s[l] == s[r]) {
        ret = max(ret, dfs(l + 1, r - 1, x) + 2);
    } else if(x) {
        ret = max(ret, dfs(l + 1, r - 1, x - 1) + 2);
    }
    return dp[l][r][x] = ret;
}
int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%s%d", s + 1, &k);
    n = strlen(s + 1);
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) {
            ans = max(ans, dfs(i, j, k));
        }
    } 
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 111104
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct Combination {
    static ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(1e6);

int main() {
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0) {
        write(0);
        return 0;
    }

    int Z = X + Y;
    X -= Z / 3;
    Y -= Z / 3;

    if (X < 0 || Y < 0) {
        write(0);
        return 0;
    }

    write(C(X + Y, X));
}

Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] depth_width = str.split(" ", 0);
		int depth = Integer.parseInt(depth_width[0]);
		int width = Integer.parseInt(depth_width[1]);;

		int perimeter = depth * 2 + width * 2;
		int area = depth * width;

		System.out.println(area + " " + perimeter);
	}
}

Measured memory_bytes: 23964
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[-1] == 0:
    print(0)
    exit()

ans = A[0]
lim = 10**18
for a in A[1:]:
    ans *= a
    if ans > lim:
        print('-1')
        exit()
print(ans)

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  auto cnt=make_v<signed char>(h,w);
  fill_v(cnt,0);

  Int dy[]={-1,-1,-1,0,1,1,1,0};
  Int dx[]={-1,0,1,1,1,0,-1,-1};
  for(Int i=1;i<h-1;i++)
    for(Int j=1;j<w-1;j++)
      for(Int k=0;k<8;k++)
	cnt[i][j]+=s[i+dy[k]][j+dx[k]]=='.';

  auto used=make_v<signed char>(h,w);
  fill_v(used,0);
  using P = pair<Int, Int>;
  queue<P> cur,nxt;

  
  for(Int i=1;i<h-1;i++){
    for(Int j=1;j<w-1;j++){
      if(s[i][j]=='.') continue;
      if(cnt[i][j]>=s[i][j]-'0'){
	s[i][j]='.';
	used[i][j]=1;
	cur.emplace(i,j);
      }
    }
  }
  
  auto dec=[&](Int y,Int x){
    for(Int k=0;k<8;k++)
      cnt[y+dy[k]][x+dx[k]]++;
  };

  Int ans=0;
  while(!cur.empty()){
    while(!cur.empty()){
      Int y,x;
      tie(y,x)=cur.front();cur.pop();
      //cout<<y<<" "<<x<<endl;

      dec(y,x);
      
      for(Int k=0;k<8;k++){
	Int ny=y+dy[k],nx=x+dx[k];
	if(s[ny][nx]=='.'||used[ny][nx]) continue;
	if(cnt[ny][nx]>=s[ny][nx]-'0'){
	  s[ny][nx]='.';
	  used[ny][nx]=1;
	  nxt.emplace(ny,nx);
	}
      }
    }
    
    ans++;
    swap(cur,nxt);
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 6096
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static long MOD = 1000000007;
	static char[] A, B, C;

	public static void main(String[] args) {
		while (sc.hasNext()) {
			A = sc.next().toCharArray();
			if (!sc.hasNext()) break;
			B = sc.next().toCharArray();
			C = sc.next().toCharArray();
			System.out.println(solve());
		}
	}

	static long solve() {
		long[][] dp = new long[2][A.length + 1];
		dp[0][A.length] = 1;
		for (int i = A.length - 1; i >= 0; --i) {
			for (int j = 0; j < 10; ++j) {
				if (A[i] != '?' && A[i] - '0' != j) continue;
				for (int k = 0; k < 10; ++k) {
					if (B[i] != '?' && B[i] - '0' != k) continue;
					if (i == 0 && (j == 0 || k == 0)) continue;
					for (int carry = 0; carry <= 1; ++carry) {
						int sum = j + k + carry;
						if (C[i] != '?' && sum % 10 != C[i] - '0') continue;
						dp[sum / 10][i] += dp[carry][i + 1];
						dp[sum / 10][i] %= MOD;
					}
				}
			}
		}
		return dp[0][0];
	}
}

Measured memory_bytes: 22984
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s,w;
    cin>>s>>w;
    if(s<=w)cout<<"unsafe\n";
    else cout<<"safe\n";
    return 0;   
}

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

int compare(string s, string t){
    int result = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) result++;
    }
    return result;
}

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int ans = 2000;
    for(int i = 0; i <= n-m; i++){
        string u = s.substr(i,m);
        if(compare(t,u) < ans) ans = compare(t,u);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  int N, X, L[100];
  cin >> N >> X;
  rep(i, N)cin >> L[i];

  int diff = 0, norm = 1;
  rep(i, N){
    diff += L[i];
    if(diff > X)break;
    //diff += L[i];
    norm++;
  }
  cout << norm << endl;
}


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

int main() {
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0]){
		cout<< "YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

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

int main(){ //できたじゃねーかよーーー。個数を持つのね。なるほど。
int n,q;
cin >> n;
vector<int> num(100010);
ll sum=0;
rep(i,n){
    int a;
    cin >> a;
    num[a]++;
    sum +=a;
}
vector<ll> s(100010);
cin >> q;
rep(i,q){
    int b,c;
    cin >> b >> c;
    num[c] += num[b];
    s[i]= sum + (c-b)*num[b];
    num[b]=0;
    sum = s[i];
}

rep(i,q) cout << s[i] << endl;

}

Measured memory_bytes: 4264
#include<bits/stdc++.h>
using namespace std;
#define int long long

struct QuickFind{
  vector<int> r,p;
  vector<vector<int> > v;
  QuickFind(){}
  QuickFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    v.resize(size);
    for(int i=0;i<size;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};
signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<int> b(a);
  sort(b.begin(),b.end());
  map<int,int> p,q;
  for(int i=0;i<n;i++){
    p[a[i]]=i;
    q[b[i]]=i;
  }
  QuickFind qf(n);
  for(int i=0;i<n;i++) 
    qf.unite(i,p[b[i]]);
  //for(int i=0;i<n;i++) cout<<i<<" "<<p[b[i]]<<endl;
  int ans=0;
  for(int i=0;i<n;i++){
    int k=qf.v[i].size();
    if(qf.p[i]!=i||k==1) continue;
    int m=a[qf.v[i][0]];
    int tmp=0;
    for(int j=0;j<k;j++){
      //cout<<" "<<a[qf.v[i][j]];
      tmp+=a[qf.v[i][j]];
      m=min(m,a[qf.v[i][j]]);
    }
    //cout<<endl;
    ans+=min(tmp+m*(k-2),tmp+m+b[0]*(k+1));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3392
#include<stdio.h>
typedef struct Dice{int t,s,e,w,n,b;}dice;
 
void koro(dice *d,char *h){
    dice dbuf;
    dbuf.t=d->t;dbuf.s=d->s;dbuf.e=d->e;dbuf.w=d->w;dbuf.n=d->n;dbuf.b=d->b;
    switch(*h){
        case 'S':
            d->t=dbuf.n;
            d->s=dbuf.t;
            d->e=dbuf.e;
            d->w=dbuf.w;
            d->n=dbuf.b;
            d->b=dbuf.s;
            break;
        case 'E':
            d->t=dbuf.w;
            d->s=dbuf.s;
            d->e=dbuf.t;
            d->w=dbuf.b;
            d->n=dbuf.n;
            d->b=dbuf.e;
            break;
        case 'W':
            d->t=dbuf.e;
            d->s=dbuf.s;
            d->e=dbuf.b;
            d->w=dbuf.t;
            d->n=dbuf.n;
            d->b=dbuf.w;
            break;
        case 'N':
            d->t=dbuf.s;
            d->s=dbuf.b;
            d->e=dbuf.e;
            d->w=dbuf.w;
            d->n=dbuf.t;
            d->b=dbuf.n;
            break;
    }
}
 
int main(void){
    dice di;
    int i,q,dice[7],target_top,target_front;
    for(i=0;i<6;i++)scanf("%d",&dice[i]);
    di.t=dice[0];di.s=dice[1];di.e=dice[2];di.w=dice[3];di.n=dice[4];di.b=dice[5];
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d",&target_top,&target_front);
		if	   (di.s==target_top) koro(&di,"N");
		else if(di.e==target_top) koro(&di,"W");
		else if(di.w==target_top) koro(&di,"E");
		else if(di.n==target_top) koro(&di,"S");
		else if(di.b==target_top){koro(&di,"S");koro(&di,"S");}

		if     (di.e==target_front){koro(&di,"W");koro(&di,"S");koro(&di,"E");}
		else if(di.w==target_front){koro(&di,"E");koro(&di,"S");koro(&di,"W");}
		else if(di.n==target_front){koro(&di,"S");koro(&di,"S");koro(&di,"E");koro(&di,"E");}
		
		printf("%d\n",di.e);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string A, B, C;

	cin >> A;
	cin >> B;
	cin >> C;

	if (A[A.size() - 1] == B[0]) {
		if (B[B.size() - 1] == C[0]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		cout << "NO" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1005],N;
double dp[305][305][305];
double dfs(int x,int y,int z)
{
	if (x==0&&y==0&&z==0) return 0;
	if (dp[x][y][z]>=0) return dp[x][y][z];
	int Sum=x+y+z;
	double ans=1.0*N/Sum;
	if (x) ans+=1.0*dfs(x-1,y,z)*x/Sum;
	if (y) ans+=1.0*dfs(x+1,y-1,z)*y/Sum;
	if (z) ans+=1.0*dfs(x,y+1,z-1)*z/Sum;
	dp[x][y][z]=ans;
	return dp[x][y][z];
}
int main()
{
	scanf("%d",&N);
	memset(dp,-1,sizeof(dp));
	for (int i=1;i<=N;i++)
	  {
	  	int ss;
	  	scanf("%d",&ss);
	  	a[ss]++;
	  }
	printf("%.10lf",dfs(a[1],a[2],a[3]));
}

Measured memory_bytes: 221952
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
  int n;
  cin>>n;
  int a[200000];
  for(int i=1; i<=2*n-1; i++){
    cin>>a[i];
  }
  int x1=1, x2=2*n-1;
  while(x1!=x2){
    int x=(x1+x2+1)/2;
    bool b[200000];
    for(int i=1; i<=2*n-1; i++){
      b[i]=(a[i]>=x);
    }
    if(b[n] && (b[n-1] || b[n+1])){
      x1=x;
      continue;
    }
    if(!b[n] && (!b[n-1] || !b[n+1])){
      x2=x-1;
      continue;
    }
    int l=-1, r;
    for(int i=1; i<=2*n-2; i++){
      if(l<0 && b[i] && !b[i+1]){
        l=i;
      }
      if(l>0 && b[i]==b[i+1]){
        if(b[i]) r=i;
        else r=i-1;
        if(r>=n) break;
        l=-1;
      }
    }
    if(l==1 && r==2*n-1){
      x1=x;
      continue;
    }
    bool ok;
    int m=(l+r)/2;
    if(m==n){
      ok=(b[r+1] || b[l-1]);
    }else if(m<n){
      ok=b[r+1];
    }else{
      ok=b[l-1];
    }
    if(ok) x1=x;
    else x2=x-1;
  }
  cout<<x1<<endl;
	return 0;
}

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

int main(){
  int n;

  while(cin >> n && n){
    int res = 0,k=0,tmp = 1;
    while(n){
      res += ((n%10)+10)%10 * tmp;
      if(n%10<0)n-=10;
     
      tmp *= 10;
      n /= -10;
      k++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int w,h;

int dfs(int i, int j, int c[][51]) {
    if(c[i][j] == 1) {
        c[i][j] = 0;
        rep(di,i-1,i+2) {
            rep(dj,j-1,j+2) {
                if(di != i || dj != j) {
                    if(di<0 || di>=h || dj<0 || dj>=w) continue;
                    if(c[di][dj] == 1) dfs(di,dj,c);
                }
            }
        }
        return 1;
    }
    return 0;
}

int main() {
    int c[51][51];

    while(cin >> w >> h) {
        if(w == 0 && h == 0) break;

        rep(i,0,h) {
            rep(j,0,w) {
                cin >> c[i][j];
            }
        }

        int ret = 0;
        rep(i,0,h) {
            rep(j,0,w) {
                ret += dfs(i,j,c);
            }
        }

        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1388
S=list(input())

s=[]

for i in range(len(S)):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        s.append(1)
    else:
        s.append(0)
        
ans=0
cnt=0
for i in range(len(S)):
    if s[i]==1:
        cnt+=1
        if ans<cnt:
            ans=cnt
    else:
        cnt=0
print(ans)


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

using ll = long long;
int main()
{
    ll k,a,b;
    cin >> k >> a >> b;
    if(k < a+1 || b<=a){
        cout << k+1 << endl;
        return 0;
    }
    ll ans = b;
    ll kd = k - (a+1);
    
    ans += (kd/2)*(b-a);
    ans += kd%2;
    cout << max(ans, k+1) << endl;
    return 0;
}

Measured memory_bytes: 256
main = do
  [h, w] <- map read . words <$> getLine
  putStrLn . show $ solve h w

solve:: Int -> Int -> Int
solve h w = minimum $ map calcD $ (calc h w) ++ (calc w h)

calcD:: [Int] -> Int
calcD a = (maximum a) - (minimum a)

calc:: Int -> Int -> [[Int]]
calc h w = concat [[s1:(cut (h - hh) w), s1:(slice (h - hh) w)] | hh <- [1..(h - 1)], s1 <- [w * hh]]

slice:: Int -> Int -> [Int]
slice h w = [h1 * w, (h - h1) * w] where
  h1 = div h 2

cut:: Int -> Int -> [Int]
cut h w = [h * w1, h * (w - w1)] where
  w1 = div w 2

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int n,x=0,m=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
			x++;
		else
			x--;
		m=max(x,m);
	}
	cout<<m;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

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

void solve(){
  int x, y; cin >> x >> y;
  vector<int> v = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  if(v[x - 1] == v[y - 1]) cout << "Yes\n";
  else cout << "No\n";
  return;
}

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


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

using namespace std;

typedef long long int int64;

int main() {
	int64 n, m;
	cin >> n >> m;
	if(n == 1 || m == 1) {
		cout << "1\n";
		return 0;
	}
	cout << ((n*m)/2 + (n*m)%2) << "\n";
	return 0;
}

Measured memory_bytes: 256