akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>
#include<math.h>
#include<random>

#define lli long long int
#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}

struct SegmentTree {
private:
	int n;
	vector<long long int> node;
	int TANNI;

	long long int Func(long long int a, long long int b) {
		return min(a,b);
	}

public:
	//元配列ｖをセグメント木で表現する。
	SegmentTree(vector<long long int> v, long long int tanni) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪→これをｎとおく。
		//セグメント木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1;
		while (n < sz)n *= 2;

		TANNI = tanni;
		node.resize(2 * n - 1, TANNI);

		//最下段に値を入れた後に、下の段から順番に値を入れる。
		//値を入れるには、自分の子の２値を参照すればよい。
		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = Func(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(long long int x, long long int val) {
		//最下段のノードにアクセスする。
		x += (n - 1);

		//最下段のノードを更新したら、あとは親に上って更新していく。
		node[x] = val;

		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = Func(node[2 * x + 1], node[2 * x + 2]);
		}
	}

	long long int getVal(int x) {
		x += (n - 1);
		return node[x];
	}

	long long int getAns(int a, int b, int k = 0, int l = 0, int r = -1) {
		//最初に呼び出された時の区間は[0,n)
		if (r < 0)r = n;

		//要求区間と対象区間が交わらない→単位元を返す。
		if (r <= a || b <= l) return TANNI;

		//要求区間が対象区間を完全に被覆する→対象区間を答えの計算に使う。
		if (a <= l && r <= b) return node[k];

		//要求区間が対象区間の一部を被覆→子をよびだす。
		//左の子をvl、右の子をvrとしている。
		//新しい対象区間は現在の対象区間を半分に割ったもの。
		int vl = getAns(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getAns(a, b, 2 * k + 2, (l + r) / 2, r);
		return Func(vl, vr);


	}



};




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

	lli ans = 0;


	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				ans += gcd(a, gcd(b, c));



			}



		}

	}

	cout << ans << endl;


	return 0;

}



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public List<List<int>> D;
        public void Run()
        {
            // Input
            N = Input.ReadInt();

            D = new List<List<int>>();
            for (int i = 0; i < N; i++)
            {
                D.Add(new List<int>());
            }

            for (int i = 1; i < N; i++)
            {
                var w = Input.ReadInt() - 1;
                int l = i;
                D[w].Add(l);
            }

            int ret = Depth(0);
            Console.WriteLine(ret);
        }

        public int Depth(int i)
        {
            int c = D[i].Count;
            if (c == 0) return 0;
            if (c == 1) return Depth1(i);
             
            int[] depths = new int[c];
            for (int j = 0; j < c; j++)
            {
                depths[j] = Depth(D[i][j]);
            }

            Array.Sort(depths);

            for (int d = 0; d < c; d++)
            {
                depths[d] += (c - d);
            }

            int ret = 0;
            for (int d = 0; d < c; d++)
            {
                ret = Math.Max(ret, depths[d]);
            }

            return ret;
        }

        public int Depth1(int i)
        {
            return Depth(D[i][0]) + 1;
        }
    }


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

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

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

  vector<int64_t> x(n + 1), y(n + 1);
  for (int i = 1; i <= n; i++) {
    if (i + a[i] < n) x[i + a[i]]++;
    if (i - a[i] > 1) y[i - a[i]]++;
  }

  int64_t ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += x[i] * y[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 102, INF = 1000000009;

int n, m;
char a[N][N];

int dp[N][N];

void solv()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        scanf(" %s", (a[i] + 1));
    for (int i = n; i >= 1; --i)
    {
        for (int j = m; j >= 1; --j)
        {
            if (a[i][j] == '#')
            {
                if (i == n && j == m)
                {
                    dp[i][j] = 1;
                }
                else if (i == n)
                {
                    if (a[i][j + 1] == '#')
                        dp[i][j] = dp[i][j + 1];
                    else
                        dp[i][j] = dp[i][j + 1] + 1;
                }
                else if (j == m)
                {
                    if (a[i + 1][j] == '#')
                        dp[i][j] = dp[i + 1][j];
                    else
                        dp[i][j] = dp[i + 1][j] + 1;
                }
                else
                {
                    dp[i][j] = INF;
                    if (a[i + 1][j] == '#')
                        dp[i][j] = min(dp[i][j], dp[i + 1][j]);
                    else
                        dp[i][j] = min(dp[i][j], dp[i + 1][j] + 1);
                    if (a[i][j + 1] == '#')
                        dp[i][j] = min(dp[i][j], dp[i][j + 1]);
                    else
                        dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1);
                }
            }
            else
            {
                if (i == n && j == m)
                {
                    dp[i][j] = 0;
                }
                else if (i == n)
                {
                    dp[i][j] = dp[i][j + 1];
                }
                else if (j == m)
                {
                    dp[i][j] = dp[i + 1][j];
                }
                else
                {
                    dp[i][j] = INF;
                    dp[i][j] = min(dp[i][j], dp[i + 1][j]);
                    dp[i][j] = min(dp[i][j], dp[i][j + 1]);
                }
            }
        }
    }
    printf("%d\n", dp[1][1]);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 256
from sys import maxsize

n = int(input())
a = list(map(int, input().split()))

res = maxsize
for i in (0, 1):
    cumsum = cnt = 0
    for k in range(n):
        if k % 2 == i:
            if cumsum + a[k] <= 0:
                cnt += abs(1 - (cumsum + a[k]))
                cumsum = 1
            else:
                cumsum += a[k]
        else:
            if cumsum + a[k] >= 0:
                cnt += abs(-1 - (cumsum + a[k]))
                cumsum = -1
            else:
                cumsum += a[k]
    if cnt < res:
        res = cnt

print(res)


Measured memory_bytes: 14468
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;

const int B1=123456789;
const int B2=999999937;
const int P=1000000007;

void gen_hash(const vector<string> &m,int H,int W,int R,int C,vector<vector<long long> >&hash){
	vector<vector<long long> > hash1(H);
	hash.resize(H);

	for(int h=0;h<H;h++){
		hash1[h].resize(W);
		hash[h].resize(W);

		long long c=0;
		long long Brev=1;
		for(int w=0;w<W;w++){
			c=(c*B1+m[h][w])%P;
			if(w<C)Brev=Brev*B1%P;else c=((c-m[h][w-C]*Brev)%P+P)%P;
			hash1[h][w]=c;
		}
	}
	for(int w=0;w<W;w++){
		long long c=0;
		long long Brev=1;
		for(int h=0;h<H;h++){
			c=(c*B2+hash1[h][w])%P;
			if(h<R)Brev=Brev*B2%P;else c=((c-hash1[h-R][w]*Brev)%P+P)%P;
			hash[h][w]=c;
		}
	}
}

int main(){
	int H,W,R,C;
	cin>>H>>R;W=H,C=R;
	vector<string>field(H);
	for(int i=0;i<H;i++)cin>>field[i];
	vector<string>pattern(R);
	for(int i=0;i<H;i++)cin>>pattern[i];
	vector<vector<long long> >hash_field,hash_pattern;
	gen_hash(field,H,W,R,C,hash_field);
	gen_hash(pattern,R,C,R,C,hash_pattern);
	for(int h=R-1;h<H;h++)for(int w=C-1;w<W;w++){
		if(hash_field[h][w]==hash_pattern[R-1][C-1]){puts("Yes");return 0;}
	}
	puts("No");
}

Measured memory_bytes: 256
n_building = 4
n_floor = 3
n_room = 10
count = Array.new(n_building){Array.new(n_floor){Array.new(n_room, 0)}}

n = gets.chomp.to_i
n.times{
    b, f, r, v = gets.chomp.split.map(&:to_i)
    count[b - 1][f - 1][r - 1] += v
}

n_building.times{|b|
    n_floor.times{|f|
        n_room.times{|r|
            print " #{count[b][f][r]}"
        }
        puts
    }
    puts "#" * 20 unless b == n_building - 1
}

Measured memory_bytes: 8716
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e5 + 10;
int a[MAXN],b[MAXN],c[MAXN];

void solve(){
    int n; cin>>n;
    FOR(i,1,n) cin>>a[i];
    FOR(i,1,n) cin>>b[i];
    
    int ans = 0;  
    FOR(bit,0,28){
        int T = (1LL<<bit);
        FOR(i,1,n) c[i] = b[i]%(2*T);
        sort(c+1,c+n+1);
        int cnt = 0;

        FOR(i,1,n){ 
            int val = a[i]%(2*T);
            int temp1 = lower_bound(c+1,c+n+1,2*T - val) - lower_bound(c+1,c+n+1,T - val);
            int temp2 = lower_bound(c+1,c+n+1,4*T - val) - lower_bound(c+1,c+n+1,3*T - val);
            cnt = cnt + temp1 + temp2;
        }
        ans = (ans + (cnt%2)*T);
    }

    cout<<ans<<endl;
}

signed main(){

   FastRead;    

    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

using namespace std;

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int flag=0;
    if(a[0]==a[1] && a[1]!=a[2])flag=1;
    if(a[1]==a[2] && a[1]!= a[0])flag=1;
    if(flag==1)cout<<"Yes";
    else cout<<"No";
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
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 LCS(string a ,string b)
{
	vector <vector <int>> dp(a.length()+1,vector<int>(b.length()+1,0));
	REP(i,a.length()+1)
	REP(j,b.length()+1)
	{
		if(i==0||j==0)
		{
			dp[i][j] = 0;
		}
		else if(a[i-1]==b[j-1])
				dp[i][j] = 1+dp[i-1][j-1];
		else 
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	}

	int index  =  dp[a.length()][b.length()];
	// cout<<index;
	char ans[index+1];
	ans[index] = '\0';
	int i = a.length();
	int j = b.length();
	while(i>0&&j>0)
	{
		if(a[i-1]==b[j-1])
		{
			ans[index-1] = a[i-1];
			i--;
			j--;
			index--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	cout<<ans;
}
int main()
{string a ,b;
	cin>>a>>b;

    LCS(a,b);
    return 0;
}

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;

  int t = INF;
  int res{};
  for (int i = 0; i < N; ++i) {
    int s; cin >> s;
    if (s % 10 != 0) {
      chmin(t, s);
    }
    res += s;
  }
  auto ans = res % 10 == 0 
    ? t == INF ? 0 : res - t
    : res;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main(){
	int H, W;
  	cin >> H >> W;
  	vector<vector<char>> field(H, vector<char>(W));
  	for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
        	char c;
          	cin >> c;
          	field[i][j] = c;
        }
    }
  	vector<vector<int>> directions = {{1, 0}, {-1, 0}, {0, 1}, {0,-1}};
  	int cost_max = 0;
  	for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
			vector<vector<int>> visited(H, vector<int>(W));
        	pair<int, int> s(i, j);
          	if(field[i][j] == '#') continue;
          	queue<pair<int, pair<int, int>>> que;
          	pair<int, pair<int, int>> p_(0, s);
          	que.push(p_);
          	while(que.size() > 0){
            	pair<int, pair<int, int>> q = que.front();
              	que.pop();
              	int cost = q.first;
              	pair<int, int> pos = q.second;
              	int x = pos.first;
              	int y = pos.second;
              	visited[x][y] = 1;
              	for(int k = 0; k < directions.size(); k++){
                  	vector<int> direction = directions[k];
              		int dx = direction[0];
                  	int dy = direction[1];
                  	int nx = x + dx;
                  	int ny = y + dy;
                  	int ncost = cost + 1;
                  	if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                  	if(field[nx][ny] == '#') continue;
            		if(field[nx][ny] == '.' && visited[nx][ny] == 0){
                    	pair<int, int> np(nx, ny);
                      	pair<int, pair<int, int>> p(ncost, np);
                      	if(cost_max < ncost) cost_max = ncost;
                      	visited[nx][ny] = 1;
                      	que.push(p);
                    } 
                }
            }
        }
    }
  	cout << cost_max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

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

    ll ans;

    if(m <= 2 * n)
    	ans = m / 2;
    else
    {
    	m = m - 2 * n;
    	ans = n + (m / 4);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <string.h>

using namespace std;
int main(int argc, char *argv[])
{
  string w;
  cin >> w;
  char moji[27];
  
  for (int i = 0; i < sizeof(moji); i++) {
    moji[i] = 0;
  }
  moji[26] = '\0';

  for(int i = 0;i<w.length();i++){
    char x = w[i];
    moji[(int)x-97]++;
  }
  int i;
  for (i = 0; i < sizeof(moji); i++) {
    if (moji[i]%2 == 1) {
      cout << "No";
      break;
    }
  }
  
  if(i == sizeof(moji)){
    cout << "Yes";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int attack=0;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    attack+=a;
  }
  if(attack>=n) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

    


Measured memory_bytes: 256
DP[17];main(a,b,n){for(;scanf("%d%d%d",&a,&b,&n)*a;printf("%d\n",DP[b])){int m[17][17]={0},x,y;for(;n--;m[x][y]=1)scanf("%d%d",&x,&y);for(x=0;x++<a;)for(y=0;y++<b;)DP[y]=m[x][y]?0:x*y-1?DP[y]*(x>1)+DP[y-1]*(y>1):1;}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static int gcd(int a, int b) {
        if(a < b) gcd(b, a);
        if(b == 0) return a;
        return gcd(b,a%b);
    }

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer K = Integer.parseInt(scanner.next());
        Integer total = 0;

        for (int i = 1; i <= K; i++) {
            for (int j = 1; j <= K; j++) {
                for (int k = 1; k <= K; k++) {
                    total += gcd(i, gcd(j,k));
                }
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 52736
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#else
#define DBG(expr)
#endif
#define UNREACHABLE() do { \
        cerr << "[Oops] UNREACHABLE: at line " << __LINE__ << endl; \
        __builtin_unreachable(); \
        exit(123); \
    } while (0)
#define ECHO(expr) cout << (expr) << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll x,a;
    cin >> x >> a;
    ECHO(x < a ? 0 : 10)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
def search_from(i,j):
    #print(i,j)
    if i>0:
        if visited[i-1][j] == 0:
            if map[i][j] != map [i-1][j]:
                to_visit.append((i-1,j))
                #print("append", i-1,j, "from",i,j)

    if i<h-1:
        if visited[i+1][j] == 0:
            if map[i][j] != map [i+1][j]:
                to_visit.append((i+1,j))
                #print("append", i+1,j,"from",i,j)
                
    if j>0:
        if visited[i][j-1] == 0:
            if map[i][j] != map [i][j-1]:
                to_visit.append((i,j-1))
                #print("append", i,j-1,"from",i,j)

    if j<w-1:
        if visited[i][j+1] == 0:
            if map[i][j] != map [i][j+1]:
                to_visit.append((i,j+1))
                #print("append", i,j+1,"from",i,j)

h, w = map(int, input().split())
map = []
for i in range(h):
    map.append(input())

#print(map)

visited = [[0 for i in range(w)] for j in range(h)]

#print(visited)

to_visit = []

ans = 0
for i in range(h):
    for j in range(w):
        if visited[i][j] == 1:
            continue
        #not visited
        black = 0
        white = 0
        
        to_visit.append((i,j))
        while len(to_visit)>0:
            next = to_visit.pop()
            if visited[next[0]][next[1]] ==0:
                visited[next[0]][next[1]] = 1
                search_from(next[0],next[1])
                if map[next[0]][next[1]] =='#':
                    black += 1
                if map[next[0]][next[1]] =='.':
                    white += 1
        ans += black * white
        #print("b",black, "w",white)
        
print(ans)     



     

    


Measured memory_bytes: 19532
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n;
	cin >> n;
	vector<ll> v(n), mx(n);
	for(int i = 0; i < n;i++)
	{
		cin >> v[i];
		mx[i] = v[i];
		if(i)
			mx[i] = max(mx[i], mx[i-1]);
	}
	ll ans = 0;
	for(int i = 0; i < n;i++)
	{
		ans += mx[i]-v[i];
	}
	cout << ans << '\n';
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 6360
#include<cstdio>
#include<algorithm>

long long min(long long a,long long b){ return a>b?b:a; }

long long max(long long a,long long b){ return a>b?a:b; }

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long c = a*b-1;
    long long L = 1, R = min(2000000000,c);
    long long res = -1;
    while(L<=R){
        long long M = (L+R)/2;
        long long mid = (M+1)/2;
        long long value = mid*(M+1-mid);
        //printf("M = %lld, value = %lld\n",M,value);
        if(value>c){
            R = M-1;
        }
        else{
            res = M;
            L = M+1;
        }
    }
    if(a!=b) res--;
    printf("%lld\n",max(0,res));
    }
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(vv) vv.begin(), vv.end()
 
using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=1e9 + 7;
 
#define int ll

int n, mdd, l, phi, r, dp[maxn], dp2[maxn];
vector <int> edge[maxn];

int binpow(int a, int n)
{
	int res = 1;
	while(n)
	{
		if(n&1)
		{
			n--;
			res*=a;
			res%=mdd;
		}
		n/=2;
		a*=a;
		a%=mdd;
	}
	return res;
}

void dfs(int v, int pred = 0)
{
	dp[v] = 1;
	dp[v] %= mdd;
	FOR(0, i, edge[v].size())
	{
		int to = edge[v][i];
		if(to == pred) continue;
		dfs(to, v);
		dp[v] *= (dp[to] + 1) % mdd;
		dp[v] %= mdd;
	}
}

void dfs2(int v, int pred = 0)
{
	if(v == 1) dp2[v] = 1;
	dp2[v] %= mdd;
	vector <int> pref, suff;
	pref.reserve(edge[v].size() + 3);
	suff.reserve(edge[v].size() + 3);
	pref[0] = 1;
	suff[edge[v].size() + 1] = 1;
	FOR(0, i, edge[v].size())
	{
		int to = edge[v][i];
		if(to == pred) pref[i + 1] = pref[i];
		else
		pref[i + 1] = pref[i] * ((dp[to] + 1) % mdd) % mdd;
	}
	for(int i = (int)edge[v].size() - 1; i >= 0; --i)
	{
		int to = edge[v][i];
		if(to == pred) suff[i + 1] = suff[i + 2];
		else
		suff[i + 1] = suff[i + 2] * ((dp[to] + 1) % mdd) % mdd;
	}
	FOR(0, i, edge[v].size())
	{
		int to = edge[v][i];
		if(to == pred) continue;
		dp2[to] = 1 + (pref[i] * suff[i + 2] % mdd * (dp2[v]) % mdd) % mdd;
		dp2[to] %= mdd;
		dfs2(to, v);
	}
}

main()
{
	IOS
	cin >> n >> mdd;
	int mm = mdd;
	phi = mdd;
	forn(2, i, mm)
	{
		if(i * i > mm) break;
		if(mm % i == 0)
		{
			phi = phi - phi / i;
		}
		while(mm % i == 0)
		{
			mm /= i;
		}
	}
	if(mdd == 1)
	{
		phi = 1;
	}
	if(mm > 1)
	{
		phi = phi - phi / mm;
	}
	forn(1, i, n - 1)
	{
		cin >> l >> r;
		edge[l].pb(r);
		edge[r].pb(l);
	}
	dfs(1);
	dfs2(1);
	forn(1, i, n)
	{
		cout << dp[i] * dp2[i] % mdd << " ";
	}
}

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

struct data{
	char a;
	char b;
}; 

int BubbleSort(struct data *a,int n){
	int count=0;
	int flag=1;
	while(flag){
		flag=0;
		for(int i=n-1;i>0;i--){
			if(a[i].b<a[i-1].b){
				struct data temp=a[i];
				a[i]=a[i-1];
				a[i-1]=temp;
				flag=1;
				count++;
			}
		}
	}
}

int SelectionSort(struct data *a,int n){
	int count=0;
	for(int i=0;i<n-1;i++){
		int minj=i;
		for(int j=i+1;j<n;j++){
			if(a[minj].b>a[j].b){
				minj=j;
			}
		}
		if(minj!=i){
			struct data temp = a[minj];
			a[minj]=a[i];
			a[i]=temp;
			count++;
		}
	}
}


int main() {
	
	struct data d1[40];
	struct data d2[40];
	
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d1[i].a>>d1[i].b;
		d2[i]=d1[i];
	}
	
	BubbleSort(d1,n);
	SelectionSort(d2,n);
	
	int flag=1;
	for(int i=0;i<n;i++){
		if(d1[i].a!=d2[i].a){
			flag=0;
			break;
		}
	}
	
	for(int i=0;i<n;i++){
		if(i>0) cout<<" ";
		cout<<d1[i].a<<d1[i].b;
	}
	cout<<endl;
	cout<<"Stable"<<endl;
	
	
	for(int i=0;i<n;i++){
		if(i>0) cout<<" ";
		cout<<d2[i].a<<d2[i].b;
	}
	cout<<endl;
	
	if(!flag){
		cout<<"Not stable"<<endl;
	}
	else{
		cout<<"Stable"<<endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string a, b;
  cin >> a >> b;
  int c = stoi(a + b);
  rep(i, 1001) {
    if (i * i == c) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;

  return 0;
}


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

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    for (int i = 0; i < H; i++) cin >> grid[i];
    int ans = 0;
    for (int i = 0; i < (1<<H); i++) {
        for (int j = 0; j < (1<<W); j++) {
            int b = 0;
            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    if ((i>>k)&1) continue;
                    if ((j>>l)&1) continue;
                    if (grid[k][l] == '#') b++;
                }
            }
            if (b == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 500 + 5;

int n;
int a[N];

int main() {
	read(n);
	for (int i = 1; i <= 2 * n; i++) read(a[i]);
	sort(a + 1, a + 2 * n + 1);
	int ans = 0;
	for (int i = 1; i <= 2 * n; i += 2) ans += min(a[i], a[i + 1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
if M == 0:
    if N == 1:
        print(0)
    else:
        print('1', '0' * (N - 1), sep='')
else:
    rst = [''] * N
    is_end = False
    for i in range(M):
        s, c = input().split(' ')
        idx = int(s) - 1
        if idx == 0 and N != 1 and c == '0':
            print(-1)
            is_end = True
            break
        if rst[idx] == '':
            rst[idx] = c
        elif rst[idx] != c:
            print(-1)
            is_end = True
            break
    if not is_end:
        for i, j in enumerate(rst):
            if i == 0 and j == '':
                print('1', end='')
            elif j == '':
                print('0', end='')
            else:
                print(j, end='')

Measured memory_bytes: 9156
#include <iostream>
#include <string>

int main() {
  std::string s;

  std::cin >> s;

  if (s == "AAA" || s == "BBB") {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
    }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
R = list(str(input()))
S = [int(s) for s in R]
count = 0

for i in range(10):
    if i in S:
        ind_i = S.index(i)
        T = S[(ind_i + 1):]
        for k in range(10):
            if k in T:
                ind_k = T.index(k)
                for l in range(10):
                    if l in T[(ind_k + 1):]:
                        count += 1

print(count)

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

int main()
{
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	if(x/k>=d)
		cout<<abs(x-k*d);
	else
	{
		long long res=x%d;
		long long cnt=(x-res)/d;
		if((k-cnt)%2)
			res=abs(res-d);
		cout<<res;
	}

	return 0; 
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

string s,t;

bool solve(int a){
  int ss=s.size();
  int ts=t.size();
  bool f=1;
  rep(i,ts){
    if(s[i+a]!='?'&&t[i]!=s[i+a])
    f=0;
  }
  if(f) return 1;
  else return 0;
}

int main(){
  cin>>s>>t;
  int ss=s.size();
  int ts=t.size();
  if(ts>ss) puts("UNRESTORABLE");
  else{
    int ans=0;
    bool f=0;
    for(int i=0;i+ts-1<ss;i++){
      if(solve(i)){
        f=1; ans=i;
      }
    }
    if(f){
      rep(i,ss){
        if(ans==i){
          cout<<t;
          i+=ts-1;
        }else{
          if(s[i]=='?')
          cout<<"a";
          else
          cout<<s[i];
        }
      }
      cout<<endl;
    }else puts("UNRESTORABLE");
  }

  return 0;
}


Measured memory_bytes: 256
import itertools
def c167(n, m, x, cali):

    ans = 10**8
    skill = [0]*m
    califlag = [True]*n

    for i in cali:
        for w in range(m):
            skill[w] += i[w+1]

    for i in skill:
        if i < x:
            return -1
    for i in range(1, n+1):
        itelist = list(itertools.combinations(range(n),i))
        for w in itelist:
            countans = 0
            countskill = [0]*m
            flag = True
            for q in w:
                countans += cali[q][0]
                for g in range(m):
                    countskill[g] += cali[q][g+1]
            for q in countskill:
                if q < x:
                    flag = False
            if flag:
                ans = min(ans, countans)

    return ans

def main():
    n, m, x = map(int, input().split())
    cali = [list(map(int, input().split()))for i in range(n)]
    print(c167(n, m, x, cali))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9388
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>

class UnionFind {
public:
    std::vector<int> par, num;

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    explicit UnionFind(int N) : par(N), num(N, 1) {
        std::iota(par.begin(), par.end(), 0);
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (num[u] < num[v]) std::swap(u, v);
        num[u] += num[v];
        par[v] = u;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return num[find(v)]; }
};

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    // 情報に基づいて頂点を繋ぐ
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int u, v, z;
        cin >> u >> v >> z;
        --u, --v;
        uf.unite(u, v);
    }

    // 親の値の集合を取れば、その大きさが連結成分の数になる
    set<int> par;
    for (int v = 0; v < N; ++v) {
        par.insert(uf.find(v));
    }
    cout << par.size() << endl;
    return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics.Contracts;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var bbb = Read();

            if (bbb == "0 0 1" || bbb == "1 1 0")
                WriteLine("Open");
            else
                WriteLine("Close");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 17836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define m 1000000007
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	    cin>>a[i];
	ll arr[n+1];
	for(ll i=0;i<=n;i++)
	   arr[i]=0;
	for(ll i=n-1;i>=1;i--)
	{
		arr[i]=(arr[i+1]+a[i])%m;
	}
	ll c=0;
	for(ll i=0;i<n-1;i++)
	{
		c=(c+(a[i]*arr[i+1])%m)%m;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 6700
#import heapq
#import itertools
#import math
#import numpy as np
import sys

S = list(input())
#A = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
for i in range(len(S)) :
    if i % 2 == 1 :
        if S[i] in 'LUD' :
            pass
        else :
            print('No')
            sys.exit()
    elif i % 2 == 0 :
        if S[i] in 'RUD' :
            pass
        else :
            print('No')
            sys.exit()
print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll dp[200010][3][2];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n + 1) rep(j, 3) rep(k, 2) dp[i][j][k] = -INF;
	dp[0][0][0] = a[0];
	dp[0][1][1] = 0;
	rep(i, n) {
		rep(j, 3) {
			chmax(dp[i + 1][j][1], dp[i][j][0]);
		}
		rep(j, 2) {
			chmax(dp[i + 1][j + 1][1], dp[i][j][1]);
		}
		rep(j, 3) {
			if (i != n - 1) chmax(dp[i + 1][j][0], dp[i][j][1] + a[i + 1]);
		}
	}
	ll ans = -INF;
	rep(j, 2) rep(k, 2) chmax(ans, dp[n][j][k]);
	if (n & 1) rep(k, 2) chmax(ans, dp[n][2][k]);
	cout << ans << '\n';
} 

Measured memory_bytes: 14292
import sys
k = int(input())
lst = [[0]*10 for i in range(10)]
for i in range(10):
  lst[0][i] = 1
l_sum = [9]  


for i in range(1,10):
  s = 0
  for j in range(10):
    if j == 0:
      lst[i][j] = lst[i-1][j] + lst[i-1][j+1]
    elif j == 9:
      lst[i][j] = lst[i-1][j] + lst[i-1][j-1] 
    else:
      lst[i][j] = lst[i-1][j-1] + lst[i-1][j] + lst[i-1][j+1] 
      
    if j !=0:
      s += lst[i][j]
  l_sum.append(s+l_sum[-1])
    

#表を逆から辿っていく、さらに手直し
i = 0
if k < l_sum[0]:
  print(k)
  sys.exit()
else:
  while True:
    if k < l_sum[i]:
      break
    i += 1
  k = k - l_sum[i-1]
   
  ans = []
  for j in reversed(range(0, i+1)):
    
    if j == i:
      p = 1
      while True:
        if k - lst[j][p] <= 0:
          ans.append(p)
          break
        else:
          k -= lst[j][p]
          p += 1
          
    else:
      if p == 0:
        if k <= lst[j][p]:
          ans.append(p)
        else:
          k -= lst[j][p]
          p += 1
          ans.append(p)
          
      elif p == 9:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          ans.append(p)
          
      else:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          if k <= lst[j][p]:
            ans.append(p)
          else:
            k -= lst[j][p]
            p = p+1
            ans.append(p)
              
l_s = [str(q) for q in ans]
print(''.join(l_s))
  

Measured memory_bytes: 9328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define mod 1000000007
using namespace std;
int n,ok;
char s[3][105];
long long sol;
int main()
{
    cin>>n;
    cin.get();
    cin.getline(s[1]+1,103);
    cin.getline(s[2]+1,103);
    sol=1;
    int i=1;
    if(s[1][1]==s[2][1])
    {
        ok=1;
        sol=3;
        ++i;
    }
    else
    {
        i+=2;
        sol=6;
        ok=2;
    }
    while(i<=n)
    {
        if(s[1][i]==s[2][i])
        {
            if(ok==1) sol=(sol*2)%mod;
            ++i;
            ok=1;
        }
        else
        {
            if(ok==1) sol=(sol*2)%mod;
            else sol=(sol*3)%mod;
            i+=2;
            ok=2;
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main() {
  int a, b, money, top;
  double cal;
  cin >> a >> money >> b >> cal;
  vector<int> c(a);
  for(int i = 0; i < a; i++) {
    cin >> c[i];
  }
  for(int i = 0; i < a; i++) {
    for(int j = 0; j < a - i - 1; j++) {
      if(c[j] < c[j + 1]) {
        swap(c[j], c[j + 1]);
      }
    }
  }
  for(int i = 0; i < a; i++) {
    if(cal / money < (cal + c[i]) / (money + b)) {
      cal += c[i];
      money += b;
    }
  }
  int ans = cal / money;
  cout << ans << endl;
}

Measured memory_bytes: 3208
def calc(s,ans1,ans2):
  if s=="o":
    if ans1=="S":
      if ans2=="S":
        return "S"
      else:
        return "W"
    else:
      if ans2=="S":
        return "W"
      else:
        return "S"
  else:
    if ans1=="S":
      if ans2=="S":
        return "W"
      else:
        return "S"
    else:
      if ans2=="S":
        return "S"
      else:
        return "W"

def check(ans0,ans1):
  ans=[""]*n
  ans[0]=ans0
  ans[1]=ans1
  ans[-1]=calc(s[0],ans[0],ans[1])
  for i in range(2,n):ans[i]=calc(s[i-1],ans[i-1],ans[i-2])
  if ans[-1]==calc(s[0],ans[0],ans[1]) and ans[0]==calc(s[-1],ans[-1],ans[-2]):
    print("".join(ans))
    exit()
  else:
    return 0
n=int(input())
s=input()
check("S","S")
check("S","W")
check("W","S")
check("W","W")
print(-1)

Measured memory_bytes: 4196
#include<stdio.h>
int main(){
  int a[100],i,j,n,t;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<10-1;i++){
    for(j=10-1;j>i;j--){
      if(a[j]>a[j-1]){
	t=a[j];
	a[j]=a[j-1];
	a[j-1]=t;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",a[i]);
  }
  return (0);
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for(int i = 0;i < H;i++){
        cin >> a.at(i);
    }
    for(int i = 0;i < W+2;i++){
        cout << "#";
        if(i == W+1) cout << endl;
    }
    for(int i = 0;i < H;i++){
        cout << "#" << a.at(i) << "#" << endl;
    }
    for(int i = 0;i < W+2;i++){
        cout << "#";
        if(i == W+1) cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

// make the "partial match" table
bool MP(vector<int> &table, string s) {
    // The size of table should be s.size() + 1
    if (table.size() != s.size() + 1) return false;
    
    table[0] = -1;
    int j = -1;
    for (int i = 0; i < s.size(); i++) {
        while (j >= 0 && s[i] != s[j]) j = table[j];
        j++;
        table[i + 1] = j;
    }
    
    return true;
}

void KMP_search(string S, string W, vector<int> MP_table, vector<bool> &match){
    fill(match.begin(), match.end(), false);
    int i = 0;
    int m = 0;
    while (m + i < S.size()) {
        if (S[m + i] == W[i]) i++;
        else {
            m = m + i - MP_table[i];
            if (i > 0) i = MP_table[i];
        }
        if (i == W.size()) {
            match[m] = true;
            m = m + i - MP_table[i];
            i = MP_table[i];
        }
    }
}

////////////////////////////////////////

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t; cin >> s >> t;
    int s_len = (int)s.size();
    int t_len = (int)t.size();
    
    for (int i = 0; i < t_len - 1; i++) {
        s += s[i % s_len];
    }
    
    // "Partial match" table
    vector<int> MP_table(t_len + 1);
    MP(MP_table, t);
    
    // KMP search
    vector<bool> match(s_len);
    KMP_search(s, t, MP_table, match);
    
    int ans = 0;
    bool flag_inf = false;
    
    vector<bool> checked(s_len, false);
    vector<int> dist(s_len, 0);
    
    for (int i = 0; i < s_len; i++) {
        int walker = i;
        
        while (match[walker]) {
            if ((walker + t_len) % s_len == i) {
                flag_inf = true;
                break;
            }
            checked[walker] = true;
            
            if (checked[(walker + t_len) % s_len]) {
                dist[i] = dist[i] + dist[(walker + t_len) % s_len] + 1;
                break;
            }
            
            dist[i]++;
            walker = (walker + t_len) % s_len;
        }
        
        if (flag_inf) break;
    }
    
    for (int i = 0; i < s_len; i++) {
        ans = max(ans, dist[i]);
    }
    
    cout << (flag_inf ? -1 : ans) << endl;
    
}


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

typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int A,B,M,i,j,ans;
    int a[100001];
    int b[100001];
    int c[100001];
    int x[100001];
    int y[100001];
    
    scanf("%d %d %d",&A,&B,&M);
    for(i = 1 ; i <= A ; i++) scanf("%d",&a[i]);
    for(i = 1 ; i <= B ; i++) scanf("%d",&b[i]);
    for(i = 1 ; i <= M ; i++) scanf("%d %d %d",&x[i],&y[i],&c[i]);
    
    int min_a = a[1];
    int min_b = b[1];
 
    for(i = 2 ; i <= A ; i++){
        if(a[i] < min_a) min_a = a[i];
    }
    for(i = 2 ; i <= B ; i++){
        if(b[i] < min_b) min_b = b[i];
    }
    
    int value = min_a + min_b; //クーポンを使わなかった場合で一番安く買える金額
    ans = value;
    
    for(i = 1 ; i <= M ; i++){
        int coopon = a[x[i]] + b[y[i]] - c[i];
        if(coopon < ans) ans = coopon; //クーポンを使って安かったら更新
    }
    
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int x;
int main()
{
    scanf("%d", &x);
    int sum = 0;
    for (int i = 1;; i++) {
        sum += i;
        if (sum >= x) {
            printf("%d\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 256