akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 22222
int a[N],b[N];
int dp[N];//生命值为I是的最小花费 
signed main(){
	int n,m;
	memset(dp,999999,sizeof(dp));
	cin>>n>>m;
	for(int i=1;i<=m;i++) cin>>a[i]>>b[i];
	dp[0]=0;
	for(int i=1;i<=m;i++){
		for(int j=a[i];j<=10000;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}int ans=99999999999;
	for(int i=n;i<=10000;i++) ans=min(ans,dp[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

ll ngcd(vector<ll> a){
    ll res;
    res = a.at(0);
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a.at(i), res);
    }
    return res;
}

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
           if(i*i != n){
               ret.push_back(n/i);
           }
       }
   }
   return ret;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    vector<ll> d(N-1), e(N-1);
    d.at(0) = A.at(0);
    e.at(0) = A.at(N-1);
    rep(i, N-2){
        d.at(i+1) = gcd(d.at(i), A.at(i+1));
        e.at(i+1) = gcd(e.at(i), A.at(N-i-2));
    }
    ll ans = 0;
    rep(i, N){
        if(i == 0){
            chmax(ans, e.at(N-2));
        }
        else if(i == N-1){
            chmax(ans, d.at(N-2));
        }
        else{
            chmax(ans, gcd(d.at(i-1), e.at(N-i-2)));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5552
#include<bits/stdc++.h>
using namespace std;
typedef __int128  Val;

const Val MOD=1e18+9;
vector<Val > var;


void skip(string &s,int &p){
  while(p<s.size() && s[p]==' ') p++;
}

Val formula(string &s,int &p);

Val num(string &s,int &p){
  Val res=0.;
  while(p<s.size() && isdigit(s[p])){
    res*=10.;
    res+=s[p]-'0';
    res%=MOD;
    p++;
  }
  skip(s,p);
  return res;
}

Val var_val(string &s,int &p){
  Val res=var[s[p]-'a'];
  p++;
  skip(s,p);
  return res;
}

Val get_val(string &s,int &p){
  if(s[p]=='('){
    p++;
    skip(s,p);
    Val  res=formula(s,p);
    assert(s[p]==')');
    p++;
    skip(s,p);
    res%=MOD;
    return res;
  }
  if(isalpha(s[p])){
    return var_val(s,p);
  }
  if(isdigit(s[p])){
    return num(s,p);
  }
  assert(0);
}

Val term2(string &s,int &p){
  Val res=get_val(s,p);
  if(p<s.size() && s[p]=='^'){
    p++;
    skip(s,p);
    Val val=term2(s,p);
    Val a=res;
    res=1;
    for(int i=0;i<val;i++){
      res*=a;
      res%=MOD;
    }
    return res;
  }
  return res;
}

Val term1(string& s,int &p){
  Val res=term2(s,p);
  while(p<s.size() && s[p]!=')' && s[p]!='+' && s[p]!='-'){
    skip(s,p);
    assert(isalpha(s[p])||isdigit(s[p])||s[p]=='(');
    Val val=term2(s,p);
    res*=val;
    res%=MOD;
  }
  return res;
}

Val formula(string& s,int &p){
  Val res=term1(s,p);
  while(p<s.size() && s[p]!=')'){
    char op=s[p];
    assert(op=='+' || op=='-');
    p++;
    skip(s,p);
    Val val=term1(s,p);
    if(op=='+') res+=val;
    else res-=val;
    res%=MOD;
  }
  return res;
}

void solve(vector<string> &state){
  random_device rnd;
  var.resize('z'-'a'+1);
  for(int i=1;i<state.size();i++){
    bool isok=true;
    const int TIME=1000;
    for(int j=0;j<TIME;j++){
      int p=0;
      for(int i=0;i<='z'-'a';i++){
	var[i]=rnd()%TIME;
      }
      Val cor=formula(state[0],p);
      cor%=MOD;
      cor+=MOD;
      cor%=MOD;
      p=0;
      Val ans=formula(state[i],p);
      ans%=MOD;
      ans+=MOD;
      ans%=MOD;
      isok&=(cor==ans);
    }
    cout<<(isok ? "yes" : "no")<<endl;
  }
  cout<<"."<<endl;
  return;
}

int main(){
  while(true){
    vector<string> state;
    while(true){
      string buf;
      getline(cin,buf);
      if(buf==".") break;
      state.push_back(buf);
    }
    if(state.size()==0) break;
    solve(state);
  }
  return 0;
}

Measured memory_bytes: 3332
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

map<ll, ll> pot;
// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll x;
	cin >> x;
	for(ll a = 0; a <= 3500; a++) {
		ll p = a * a * a * a * a;
		pot[p] = pot[-p] = a;
	}
	for(ll a = 0; a <= 3500; a++) {
		ll p = a * a * a * a * a;
		if (pot.count(p - x)) {
			ll ans = pot[p - x];
			if (p - x < 0) ans *= -1;
			cout << a << " " << ans << endl;
			return 0;
		}
	}
	assert(false);
	return 0;
}
 


Measured memory_bytes: 4096
#include <stdio.h>
int main(void)
{
	int i, n;
	char t[4];
	int c[4];
	for (i=0; i<4; ++i) c[i]=0;
	while (scanf("%d,%s", &n, t) != EOF) {
		switch (t[0]) {
			case 'A': if (t[1]=='B') c[2]++; else c[0]++; break;
			case 'B': c[1]++; break;
			case 'O': c[3]++; break;
		}
	}
	if (c[2] == 11) return 1;
	for (i=0; i<4; ++i) printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long N, M, X;
    cin >> N >> M >> X;
    vector<long long> A(M);
    X--;
    for(int i = 0; i < M; i++) {
        cin >> A[i];
        A[i]--;
    }
    vector<long long> cost(N + 1, 0);
    for(int i = 0; i < M; i++) cost[A[i]]++;
    long long ans = 0;
    for(int i = 0; i < X; i++) ans += cost[i];
    cout << min(ans, M - ans) << endl;
}

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

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

    int max = 0;
    for (int i = 1; i < n; i++) {
        vector<char> a();
        string x = s.substr(0, i);
        string y = s.substr(i);
        int count = 0;
        for (char j = 'a'; j <= 'z'; j++) {
            if (x.find(j) != string::npos && y.find(j) != string::npos) {
                count++;
            }
        }
        if (max < count) {
            max = count;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		double[][]A = new double[N][];
		var list1 = new List<int>();
		var list2 = new List<int>();
		var list3 = new List<int>();
		var list4 = new List<int>();
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = new double[2]{double.Parse(str[0]),double.Parse(str[1])};
			if(A[i][0]>0 && A[i][1]>=0){
				list1.Add(i);
			} else if(A[i][0]<=0 && A[i][1]>0){
				list2.Add(i);
			} else if(A[i][0]<0 && A[i][1]<=0){
				list3.Add(i);
			} else {
				list4.Add(i);
			}
		}
		list1.Sort((x,y)=>(A[x][1]/A[x][0]).CompareTo(A[y][1]/A[y][0]));
		list2.Sort((x,y)=>(-A[x][0]/A[x][1]).CompareTo(-A[y][0]/A[y][1]));
		list3.Sort((x,y)=>(A[x][1]/A[x][0]).CompareTo(A[y][1]/A[y][0]));
		list4.Sort((x,y)=>(-A[x][0]/A[x][1]).CompareTo(-A[y][0]/A[y][1]));
		var list = new List<int>();
		list.AddRange(list1);
		list.AddRange(list2);
		list.AddRange(list3);
		list.AddRange(list4);
		double ans = 0;
		for(var i=0;i<N;i++){
			for(var j=0;j<N;j++){
				double a1x = 0;
				double a1y = 0;
              	for(var k=i;k<=i+j;k++){
					a1x += A[list[k%N]][0];
					a1y += A[list[k%N]][1];
				}
				double a1 = a1x*a1x+a1y*a1y;
				ans = Math.Max(ans,a1);
            }
		}
		ans = Math.Pow(ans,0.5);
		Console.WriteLine(ans);
	}
}

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



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
    
    
    
    
    int n;cin>>n;
    string word;
    int cnt=0;
    cin>>word;
    for(int i=0;i<n;i++){
       if(word[i]=='A'&&word[i+1]=='B'&&word[i+2]=='C'){
           cnt++;
       }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,k;
    cin>>n>>k;
    cout<<(n>=k*2-1?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long w4,w2,wn;
    w4=w2=wn=0;

    long i,N;
    long long tmp;

    scanf("%ld",&N);

    for(i=0;i<N;i++){
        scanf("%lld",&tmp);
        switch(tmp%4){
            case 0:
                w4++;
                break;
            case 2:
                w2++;
                break;
            default:
                wn++;
        }
    }

    if(wn<=w4)
        puts("Yes");
    else if(wn==w4+1 && w2==0)
        puts("Yes");
    else
        puts("No");

    return 0;

}

Measured memory_bytes: 128
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln((a+b)%24);
}


Measured memory_bytes: 256
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(1, k + 1):
        if n - k + 1 >= i:
            print((alg_combination_mod(n - k + 1, i, mod) * alg_combination_mod(k - 1, i - 1, mod)) % mod)
        else:
            print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42480
# 3  つの整数 A,B,C が与えられます。
# 整数 C が A 以上 かつ B 以下であるかを判定してください。

input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
c = input[2].to_i

if a <= c && c <= b
    puts "Yes"
else
    puts "No"
end

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

using namespace std;
int ans=0,a;
string s;
int main()
{
	getline(cin,s);
	a=s.size();
	for(int i=1;i<s.size()-1;i++)
	{
		ans++;
	}
	cout<<s[0]<<ans<<s[a-1];
      
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    set<int> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]); // 挿入します
    }

    // set のサイズを出力します
    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  long long a, b, x, ans = 0;
  cin >> a >> b >> x;

  long long vv = (a / x);
  if (a % x == 0) vv -= 1;
  long long v2 = (b / x);

  cout << v2 - vv << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=502;
int dp[M][M],n;
bool vis[M][M];
vector<int> dx = {-1,0,0,1};
vector<int> dy = {0,-1,1,0};
bool check(int p,int q)
{
	if(p<1 || q<1 || p>n || q>n)
		return 1;
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	vector<int> vec;
	for(int i=1;i<=n*n;i++)
	{
		int x;
		cin>>x;
		vec.pb(x);
	}
	// sort(all(vec));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i][j]=min({i,j,n-i+1,n-j+1});
		}
	}
	// cout<<dp[2][2]<<endl;
	int ans=0;
	for(auto x:vec)
	{
		x--;
		int a=x/n+1,b=x%n+1;
		// cout<<a<<" "<<b<<endl;
		int mn=dp[a][b];
		if(mn)
			ans+=mn-1;
		vis[a][b]=1;
		mn=mn-1;
		for(int j=0;j<4;j++)
			mn=min(mn,dp[a+dx[j]][b+dy[j]]);
		dp[a][b]=mn;
		queue<pair<int,int>> q;
		q.push({a,b});
		while(!q.empty())
		{
			auto p = q.front();
			q.pop();
			int x=p.ff,y=p.ss;
			// cout<<x<<" "<<y<<" "<<a<<" "<<b<<endl;
			for(int j=0;j<4;j++)
			{
				int f=0;
				if(check(x+dx[j],y+dy[j]))
					continue;
				if(vis[x+dx[j]][y+dy[j]]==0)
					f++;
				if(dp[x+dx[j]][y+dy[j]]>dp[x][y]+f)
				{
					dp[x+dx[j]][y+dy[j]]=dp[x][y]+f;
					q.push({x+dx[j],y+dy[j]});
				}
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(){
    double ans = 0;

    int n;
    cin >> n;

    double x;
    string u;

    for(int i = 0; i < n; ++i){
        cin >> x >> u;

        if(u == "JPY") ans += x;
        else ans += x * 380000;
    }

    cout << fixed << setprecision(6) << ans << endl;

}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

MOD = 10 ** 9 + 7
L = sys.stdin.readline().rstrip()

# 桁 DP
# [桁][fixed]: fixed=0 ならなんでも OK、fixed=1 なら今より小さいやつしかだめ
dp = np.zeros((len(L) + 1, 2), dtype=int)
dp[1][0] = 1  # 00
dp[1][1] = 2  # 01, 10
for i in range(1, len(L)):
    # 01, 10, 00
    dp[i + 1][0] += dp[i][0] * 3
    if L[i] == '1':
        # 00 は今の桁より小さくなる
        dp[i + 1][0] += dp[i][1]
        # 01, 10
        dp[i + 1][1] += dp[i][1] * 2
    elif L[i] == '0':
        # 00 だけ
        dp[i + 1][1] += dp[i][1]
    dp[i + 1] %= MOD
print(dp[-1].sum() % MOD)


Measured memory_bytes: 17116
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n;
   cin >> n;
   vector<ll> a(n);
   map<ll, ll> mp_a;
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      mp_a[a[i]]++;
   }

   ll q;
   cin >> q;
   vector<ll> b(q), c(q);
   for (int i = 0; i < q; i++)
   {
      cin >> b[i] >> c[i];
   }
   ll ans = 0;
   for (auto itr = mp_a.begin(); itr != mp_a.end(); ++itr)
   {
      ans += itr->first * itr->second;
   }
   for (int i = 0; i < q; i++)
   {
      ans += mp_a[b[i]]*(c[i]-b[i]);
      mp_a[c[i]]+=mp_a[b[i]];
      mp_a[b[i]] = 0;
      cout << ans << endl;
   }
}

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

int main() {
	int n;
	cin >> n;
	string color;
	string kazu = "Three";
	for(int i=0; i<n; i++){
		cin >> color;
		if(color == "Y"){
			kazu = "Four";
		}
	}
	cout << kazu << endl;
}


Measured memory_bytes: 3564
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

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

	string x;
	cin >> x;

	string kx;
	stack<int>st;
	REP(i, 200030) {
		if (kx == x) break;
		if (x.empty()) break;

		kx = x;
		for (int i = x.size(); i >= 1; i--) {
			if (x[i] == 'T' && x[i - 1] == 'S') {
				x.erase(i - 1, 2);
			}
		}
	}

	cout << x.size() << "\n";
	return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  pair< string, string > S;
  cin >> S.first >> S.second;
  debug(S.first);
  debug(S.second);
  
  ll ans = 1ll;
  
  int last = -1;
  // 0: 縦/ 1: 横
  int state;
  REP(i, N) {
    debug(S.first[i]);
    debug(S.second[i]);
    if (S.first[i] == S.second[i]) {
      // 縦
      state = 0;
    } else {
      // 横
      state = 1;
      i++;
    }
    debug(state);

    if (last == -1) {
      // 初回
      if (state == 0) {
	// 縦
	ans *= 3ll;
      } else {
	ans *= 3ll * 2ll;
      }
    } else if (last == 0) {
      // 縦
      (ans *= 2ll) %= MOD;
    } else {
      // 横
      if (state == 1) {
	// 縦
	(ans *= 3ll) %= MOD;
      }
    }
    last = state;
    debug(last);
    debug(ans);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let cand = vec!["maerd", "remaerd", "esare", "resare"];
    let rev: String = s.chars().rev().collect();

    let mut i = 0;
    while i < rev.len() {
        let mut found = false;
        for &c in cand.iter() {
            if i + c.len() <= rev.len() && c == &rev[i..i + c.len()] {
                i += c.len();
                found = true;
                break;
            }
        }
        if !found {
            println!("NO");
            return;
        }
    }
    println!("YES")
}


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

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

    for (int i = 1; i <= 3; ++i){
        if( A*B*i %2 ==1){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m, k, x;
string s;



integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int p[15];
    p[0] = 0;
    p[1] = 26;
    for (int i = 2; i < 15; i++){
        p[i] = p[i-1] * 26;
    }
    int n;
    cin >> n;
    n--;
    int prev = 0;
    int len = 1;
    while (1){
        if (prev + p[len] > n){
            break;
        }
        prev += p[len];
        len++;
    }
//    cout << len << endl;

    for (int i = len-1; i >= 0; i--){
        n -= p[i];
    }
//    cout << n << endl;
    for (int i = 0; i < len; i++){
        for (int j = 0; j < 26; j++){
            if ((j+1) * max(1ll, p[len-i-1]) > n){
                s += (char) ('a' + j);
                n -= j * max(1ll, p[len-i-1]);
                break;
            }
        }
//        n--;
//        cout << n << endl;
    }
    cout << s << endl;

}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
string s, t; int n; char u[210];
int main(){
  cin >> n;
  int m = 0; cin >> s >> t;
  for(int i = 0; i < n; i++){
    u[m] = s[i];
    m++;
    u[m] = t[i];
    ++m;
  }
  for(int i = 0; i < 2 * n;i++){
    cout << u[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

const long long MOD = 1000000007;

long long ModPow(long long x, long long n) {
        long long res = 1;
        while (n > 0) {
                if (n & 1) res = res * x % MOD;
                x = x * x % MOD;
                n >>= 1;
        }
        return res;
}

int main() {
        //input
        int n;
        scanf("%d", &n);
        vector<long long> h(n);
        for (int i = 0; i < n; i ++) {
                scanf("%lld", &h[i]);
        }
        // create a tree
        vector<vector<int>> g(n);
        map<int, pair<long long, int>> hw;
        int k = 0;
        function<void (int, int, long long, int)> dfs = [&](int l, int r, long long bottom, int prev) {
                int node = k ++;
                if (prev != -1) { 
                        g[prev].push_back(node);
                }
                long long mi = 10000000000;
                for (int i = l; i <= r; i ++) {
                        mi = min(mi, h[i]);
                }
                int ww = 0;
                int cnt = 0;
                for (int i = l; i <= r; i ++) {
                        ww += mi == h[i];
                        cnt ++;
                }
                long long hh = mi - bottom;
                hw[node] = make_pair(hh, ww);
                if (ww == cnt) {
                        return;
                }
                bool in = false;
                int tl, tr;
                vector<pair<int, int>> seg;
                for (int i = l; i <= r; i ++) {
                        if (h[i] > mi) {
                                if (!in) {
                                        in = true;
                                        tl = i;
                                }
                        } else {
                                if (in) {
                                        in = false;
                                        tr = i - 1;
                                        seg.emplace_back(tl, tr);
                                }
                        }
                }
                if (in) {
                        seg.emplace_back(tl, r);
                }
                for (auto s : seg) {
                        dfs(s.first, s.second, mi, node);
                }
        };
        dfs(0, n - 1, 0, -1);
        // solve
        vector<long long> dp(n), dp2(n);
        function<void (int)> solve = [&](int u) {
                long long mul1 = 1, mul2 = 1;
                for (auto v : g[u]) {
                        solve(v);
                        (mul1 *= dp[v]) %= MOD;
                        (mul2 *= (dp[v] + dp2[v])) %= MOD;
                }
                (dp[u] = ModPow(2LL, hw[u].first) * mul1) %= MOD;
                (dp2[u] = ModPow(2LL, hw[u].second) * mul2 % MOD + ((ModPow(2LL, hw[u].first) - 2) + MOD % MOD) * mul1 % MOD) %= MOD;
        };
        solve(0);
        //output
        printf("%lld\n", dp2[0]);
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <limits>

using namespace std;

int main(){
  int n, max=0, min=std::numeric_limits<int>::max();
  cin >> n;

  for (int i=0; i<n; i++) {
    int t;
    cin >> t;
    if (t>max) max=t;
    if (t<min) min=t;
  }
  
  printf("%d\n", max-min);
  return 0;
}

Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
lld p1=1e9 + 7,p2=998244353;

void judge(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
}

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }


lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;
vector<lld> parent(200000+5);

lld find_set(lld a)
{
    if(parent[a]==a)
    {
        return a;
    }
    return parent[a]= find_set(parent[a]);
}

void union_set(lld a, lld b)
{
    a = find_set(a);
    b = find_set(b);
    if(a!=b)
    {
        parent[b]=a;
    }
}

void solve()
{  
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        parent[i]=i;
    }
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        union_set(x,y);
    }
    vector<lld> w(n+1);
    for(i=1;i<=n;i++)
    {
        parent[i] = find_set(i);
        // cout<<parent[i]<<"  ";
        w[parent[i]]+=1;
    }
    // cout<<"\n";
    ans=1;
    for(i=1;i<=n;i++) ans = max(ans,w[i]);
    cout<<ans;
}

int main()
{
    // judge();
    fastio();
    lld t=1;
    // cin>>t;
    // lld p1 = 1e9 + 7;
    // getfac(p1);
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        // cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6316
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] a) {
    a.sort();

    auto n = a.length;
    auto p = n / 2;
    return a[p] - a[p - 1];
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[1000],b[1000];
	scanf("%s%s",a,b);
	for(int i=0;i<max(strlen(a),strlen(b));i++){
		if(a[i]>='a'&&a[i]<='z')printf("%c",a[i]);
		if(b[i]>='a'&&b[i]<='z')printf("%c",b[i]);
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

typedef string::const_iterator State;
string number(State&);
string factor(State& );
string term(State& );
string expression(State& );

// 数字の列をパースして、その数を返す。
string number(State &begin) {
	int c = 0;
	string ret;
	while(*begin == '+' or *begin == '-' or isalpha(*begin)){
		if(*begin == '+'){
			c++;
		}else if(*begin == '-'){
			c--;
		}else{
			int t = *begin - 'A';
			t += c;
			t += 26 * 100000;
			t %= 26;
			c = 0;
			ret += 'A' + t;
		}
		begin++;
	}
	return ret;
}

// 括弧か数をパースして、その評価結果を返す。
string factor(State &begin) {
	if (*begin == '[') {
		begin++; // '('を飛ばす。
		string ret = expression(begin);
		begin++; // ')'を飛ばす。
		reverse(all(ret));
		return ret;
	} else {
		string ret;
		ret += number(begin);
		return ret;
	}
	return 0;
}


string expression(State &begin) {
	string ret = factor(begin);

	for (;;) {
		if(*begin == '[') {
			ret += factor(begin);
		} else if (*begin == '-' or *begin == '+' or isalpha(*begin)){
			ret += number(begin);
		} else {
			break;
		}
	}

	return ret;
}

//beginがexpectedを指していたらbeginを一つ進める。
void consume(State &begin, char expected) {
	if (*begin == expected) {
		begin++;
	} else {
		cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl;
		cerr << "Rest string is '";
		while (*begin) {
			cerr << *begin++;
		}
		cerr << "'" << endl;
		//throw ParseError();
	}
}

void dfs(string& ans, string& s, vector<char> a, vector<int>& tmp){
	if(tmp.size() == a.size()){
		rep(i,tmp.size()){
			s[ tmp[i] ] = a[i];
		}
		State state = s.begin();
		string res = expression(state);
		ans = min(ans, res);
		return;
	}

	rep(i,26){
		a.emplace_back('A' + i);
		dfs(ans, s, a, tmp);
		a.pop_back();
	}
}

int main(){
	string s;
	while(cin >> s, s[0] != '.'){

		string ans = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";

		//s = "[[" + s + "]]";
		vector<int> q;
		rep(i,s.size()){
			if(s[i] == '?') q.emplace_back(i);
		}
		dfs(ans, s, vector<char>(), q);

		cout << ans << endl;
	}
}



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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (100000)

signed main() {
    int H, W;
    cin >> H >> W;

    vector< vector<int>> m(H, vector<int>(W, 0));

    REP(i, H) {
        string s;
        cin >> s;

        REP(j, W) {
            if (s[j] == '#') m[i][j] = 1;
        }
    }

    vector< pint > q;
    REP(i, H) {
        REP(j, W) {
            if (m[i][j]) {
                q.pb( mp(i, j) );
            }
        }
    }

    int ans = 0;

    while (true) {
        vector< pint > next_q;
        for (pint &p: q) {
            int y = p.first;
            int x = p.second;

            if (x > 0 && m[y][x-1] == 0) {
                m[y][x-1] = 1;
                next_q.pb(mp(y, x-1));
            }

            if (y > 0 && m[y-1][x] == 0) {
                m[y-1][x] = 1;
                next_q.pb(mp(y-1, x));
            }

            if (W-1 > x && m[y][x+1] == 0) {
                m[y][x+1] = 1;
                next_q.pb(mp(y, x+1));
            }

            if (H-1 > y && m[y+1][x] == 0) {
                m[y+1][x] = 1;
                next_q.pb(mp(y+1, x));
            }
        }

        if (SZ(next_q) == 0) {
            break;
        }

        q = next_q;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18536
N = int(input())
A = list(map(int,input().split()))
ans = 1e+10
list = []
for i in range(N):
  count = 0
  while A[i] > 0:
    if A[i] % 2 == 0:
        A[i] //= 2
        count += 1
    else:
        break
  list.append(count)
print(min(list))

Measured memory_bytes: 8976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int INF = 1000000000;

int h, w, k, x, xx, y, yy;
string s[1000010];
pair<int, int> d[1000010][4];
priority_queue<pair<pair<int, int>, pair<int, int>>, vector< pair<pair<int, int>, pair<int, int>>>, greater< pair<pair<int, int>, pair<int, int>>>>que;
int dy[4] = { 0,-1,0,1 }, dx[4] = { 1,0,-1,0 };

signed main() {
	cin >> h >> w >> k >> x >> y >> xx >> yy; x--; xx--; y--; yy--;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < h*w; i++)for (int j = 0; j < 4; j++)d[i][j] = make_pair(INF, INF);
	for (int i = 0; i < 4; i++) {
		d[x*w + y][i] = make_pair(1, 0);
		que.push(make_pair(make_pair(1, 0), make_pair(x*w + y, i)));
	}
	while (!que.empty()) {
		int p = que.top().first.first, q = que.top().first.second, v = que.top().second.first, l = que.top().second.second; que.pop();
		if (d[v][l] < make_pair(p, q))continue;
		//cout << p << " " << q << " " << v/w<<" "<<v%w << " " << l << endl;
		for (int i = 0; i < 4; i++) {
			int tx = v / w + dx[i], ty = v % w + dy[i], t = tx * w + ty;
			if (i == l)continue;
			if (tx < 0 || h <= tx || ty < 0 || w <= ty || s[tx][ty] == '@')continue;
			if (make_pair(p + 1, 1) < d[t][i]) {
				d[t][i] = make_pair(p + 1, 1);
				que.push(make_pair(make_pair(p + 1, 1), make_pair(t, i)));
			}
		}
		int pp = 0, qq = 0;
		if (q == k)pp = p + 1, qq = 1;
		else pp = p, qq = q + 1;
		int tx = v / w + dx[l], ty = v % w + dy[l], t = tx * w + ty;
		if (tx < 0 || h <= tx || ty < 0 || w <= ty || s[tx][ty] == '@')continue;
		if (make_pair(pp, qq) < d[t][l]) {
			d[t][l] = make_pair(pp, qq);
			que.push(make_pair(make_pair(pp, qq), make_pair(t, l)));
		}
	}
	int ans = INF;
	for (int i = 0; i < 4; i++)ans = min(ans, d[xx*w + yy][i].first);
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 71320
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * (n+1)
    if n == 0:
        x = A[0]
        if x == 1:
            print(1)
        else:
            print(-1)
        exit()
    # Adが葉の個数、Bdが葉でないものの個数
    # A0 + B0 = 1
    # Bd ≤ Ad+1 + Bd+1 ≤ 2Bd --> B[d-1] - A[d] ≤ B[d] ≤ 2B[d-1] - A[d]
    # Bd ≤ Ad+1 + Ad+2 + · · · + AN = s - (A1 + ... + Ad)

    # now_s :葉の数
    now_s = sum(A)
    s = now_s
    for i in range(n+1):
        if i == 0:
            B[i] = 1 - A[i]
        else:
            now_s -= A[i]
            B[i] = min(now_s, 2 * B[i - 1] - A[i])
            #print(A,B,now_s)
            if B[i] < 0:
                print(-1)
                exit()

    print(sum(B) + s)


if __name__ == "__main__":
    main()


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

int main(){
  int H,R;
  cin>>H>>R;
  if(H+R>0){
    cout<<1<<endl;
  }else if(H+R==0){
    cout<<0<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}
    



Measured memory_bytes: 3096
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

from math import floor
def f(x):
  return (A*x)//B - A * (x//B)

print(max(f(n*B-1), f(N), 0) if n>0 else max(f(N),0))


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;
}


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

int main( int argc, char *argv[] )
{
int A;
char op;
int B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> op;
	cin >> B;
	if( op == '+' )
		cout << A + B << endl;
	else
		cout << A - B << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==1)
    {
        n=14;
    }
    if(m==1)
    {
        m=14;
    }
    if(n==m)
    {
        cout<<"Draw";
    }
    else if(n<m)
    {
        cout<<"Bob";
    }
    else
    {
        cout<<"Alice";
    }
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int cnt = 0;

    for(int i = 0; i < N-2; i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3536
#include <cstdio>
#include <cctype>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	constexpr sieve() : s(), v() {
		for (int i = 0; i < N; i++)
			s[i] = true;
		for (int i = 4; i < N; i += 2)
			s[i] = false;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	constexpr int N = sqrt(100000000);
	sieve<N> s;
	int n = in(), c = in();
	while (--n)
		c = __gcd(c, in());

	vector<pair<int, int>> a;
	for (int i = 0; ; i++) {
		if (c >= s.v[i] * s.v[i]) {
			while (c % s.v[i] == 0) {
				c /= s.v[i];
				if (a.size() && a.back().first == s.v[i])
					a.back().second++;
				else
					a.push_back({s.v[i], 1});
			}
		} else if (c == 1)
			break;
		else {
			a.push_back({c, 1});
			break;
		}
	}

	vector<int> r = {1};
	for (auto p: a) {
		size_t i = 0;
		while (p.second--) {
			size_t e = r.size();
			for (; i < e; i++)
				r.push_back(r[i] * p.first);
		}
	}
	sort(r.begin(), r.end());

	for (int x: r)
		outl(x);
}


Measured memory_bytes: 2748
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int main() {
	int m, d;
	cin >> m >> d;
	int cnt = 0;
	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= d; ++i) {
			int d1 = i % 10;
			int d2 = i / 10;
			if (d1*d2 == j && d1>=2 && d2>=2) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

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

namespace Tasks
{
    public class B
    {
        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 NM = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, M) = (NM[0], NM[1]);
            var A = new string[N].Select(x => x = Console.ReadLine()).ToArray();
            var B = new string[M].Select(x => x = Console.ReadLine()).ToArray();
            var answer = true;
            for (var i = 0; i < N - M; i++)
            {
                for (var j = 0; j < N - M; j++)
                {
                    answer = true;
                    for (var y = 0; y < M; y++)
                    {
                        for (var x = 0; x < M; x++)
                        {
                            if (A[i + y][j + x] != B[y][x]) answer = false;
                            if (!answer) break;
                        }
                        if (!answer) break;
                    }
                    if (answer) break;
                }
                if (answer) break;
            }

            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28360
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <vector>
#define loop(n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;


ll solve(ll n,ll W,ll* wt,ll* val)
{
	ll dp[n+1][W+1];
	for(ll i=0;i<=n;i++)
	{
		for(ll w=0;w<=W;w++)
		{
			if(i == 0 || w == 0)
				dp[i][w] = 0;
			else
			{
				if(w >= wt[i-1])
				{
					dp[i][w] = max(val[i-1] + dp[i-1][w - wt[i-1]],dp[i-1][w]);
				}
				else
				{
					dp[i][w] = dp[i-1][w];
				}
			}
		}
	}
	return dp[n][W];
}
	
int main()
{
    fastio;
    ll n,w;
    cin>>n>>w;
    ll wt[n];
    ll val[n];
    for(ll i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	
	ll ans = solve(n,w,wt,val);
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 82476
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n; cin >> n;
	while (n > 0) {
		if (n % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
		n /= 10;
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3632