akhauriyash/Code-Regression huggingface dataset:
// glory be to the sky
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


int main(){

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

	ll a, b, c;

	cin >> a >> b >> c;

	for (int i = a; i <= (int) 1e6; i += a) {
		if ((i % b) == (c % b)) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF (int)1e9
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	vector<char> s(4);
	REP(i,4) cin>>s[i];
	
	sort(ALL(s));
	
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto p : mp) {
        chmax(mx, p.second);
    }
    vector<string> ans;
    for(auto p : mp) {
        if(mx == p.second) {
            ans.emplace_back(p.first);
        }
    }
    sort(ALL(ans));
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 25584
def dfs(g, v, i):
    if len(v) == len(g) - 1: return 1
    v.add(i)
    c = 0
    for u in g[i]:
        if u not in v: c += dfs(g, v, u)
    v.remove(i)
    return c

n, m = map(int, input().split())
g = [list() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
print(dfs(g, set(), 0))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long n;
	long long a[N];
	set<long long>s;
	long long x,y,ans;
	auto itr = s.begin();
	scanf("%lld", &n);
	f(i, n) {
		scanf("%lld", &x);
		a[x] = i+1;
	}
	s.insert(0);
	s.insert(n + 1);
	ans = 0;
	for (long long i = 1; i <= n; i++) {
		itr = s.upper_bound(a[i]);
		x = *itr;
        itr--;
        y=*itr;
		ans += (x - a[i])*((a[i] - y)*i);
      s.insert(a[i]);
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long min = Long.MAX_VALUE;
        long n = sc.nextLong();
        for(int i = 0; i < 5; i++) {
            min = Math.min(min, sc.nextLong());
        }
        if(n <= min) {
            System.out.println(5);
            return;
        }
        n -= min;
        long cnt = (n + min - 1) / min;
        System.out.println(5 + cnt);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <type_traits>
#include <iomanip>
#include <cstdint>
#include <string>
#include <set>
#include <map>

int main() {
    std::string str;
    
    std::cin >> str;
    
    std::map<char, int> count;
    
    for(auto&& c : str) {
        ++count[c];
    }
    
    if((count['N'] && count['S'] || count['N'] + count['S'] == 0) && (count['E'] && count['W'] || count['W'] + count['E'] == 0)) {
        std::cout << "Yes" << std::endl;
    }else {
        std::cout << "No" << std::endl;
    }
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No" << endl;
  }
  else{
    for(int i=0; i<N/2; i++){
      if(S.at(i)!=S.at(i+N/2)){
        cout << "No" << endl;
        goto finish;
      }
    }
    cout << "Yes" << endl;
  }
finish: N=0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    int[] myArgs = new int[3];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.nextInt();
    myArgs[1] = sc.nextInt();
    myArgs[2] = sc.nextInt();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);

  }

  private String exec(int[] myArgs) {
    long minCost = Long.MAX_VALUE;
    for (int i = 0;i < 3;i++) {
      for (int j = 0;j < 3;j++) {
        if (i != j) {
          long cost0 = abs(myArgs[i] - myArgs[j]);
          for (int k = 0;k < 3;k++) {
            if (i != k && j != k) {
              long cost1 = cost0 + abs(myArgs[j] - myArgs[k]);
              if (minCost > cost1) {
                minCost = cost1;
              }
              break;
            }
          }
        }
      }
    }
    return String.valueOf(minCost);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
 
using i64=int64_t;

 
void solve(){
    int N;
    cin >> N;
    vector<i64> x(N),y(N);
    rep(i,0,N){
        cin >> x[i] >> y[i];
        if(x[i]>y[i]) swap(x[i],y[i]);
    }
 
    int min_index=min_element(x.begin(),x.end())-x.begin(),max_index=max_element(y.begin(),y.end())-y.begin();
    if(min_index==max_index){
        i64 l1=x[min_index],r2=y[max_index];
        i64 r1=l1,l2=r2;
        rep(i,0,N){
            r1=max(r1,x[i]);
            l2=min(l2,y[i]);
        }
        cout << (r1-l1)*(r2-l2) << endl;
        return;
    }
 
    i64 ans1,ans2;
    {
        i64 l1=x[min_index],r1=x[max_index],l2=y[min_index],r2=y[max_index];
        rep(i,0,N){
            r1=max(r1,x[i]);
            l2=min(l2,y[i]);
        }
        ans1=(r1-l1)*(r2-l2);
    }
    {
        i64 l1=x[min_index],r1=y[max_index];
        set<pair<i64,i64>> cur,pre;
        pre.insert(make_pair(min(y[min_index],x[max_index]),max(y[min_index],x[max_index])));
        rep(i,1,N){
            for(auto &p:pre){
                int l2=p.first,r2=p.second;
                 int x_=x[i],y_=y[i];
                 if(l2<=x_ and x_<=r2){
                     cur.insert(make_pair(l2,r2));
                     continue;
                 }
                if(l2<=y_ and y_<=r2){
                    cur.insert(make_pair(l2,r2));
                        continue;
                 }
                if(y_<=l2){
                    cur.insert(make_pair(y_,r2));
                        continue;
                 }
                if(r2<=x_){
                    cur.insert(make_pair(l2,x_));
                        continue;
                 }
                cur.insert(make_pair(min(l2,x_),max(r2,x_)));
                cur.insert(make_pair(min(l2,y_),max(r2,y_)));
            }
            pre.clear();
            swap(cur,pre);
        }
        i64 ma=inf64;
        for(auto &p:pre) ma=min(ma,p.second-p.first);
        ans2=(r1-l1)*ma;
    }
    cout << min(ans1,ans2) << endl;
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000
#define REPS 1000

bool used[REPS];

void solve(int n){
  int l1, l2;
  int d;
  scanf("%d", &d);
  used[d]=true;
  if(n==1) return;

  l1=d*10;
  scanf("%d", &d);
  l1+=d;
  used[d] = used[l1] =true;
  if(n==2) return;
  
  repl(i,2,n){
    l2=l1*10;
    l1=d*10;
    scanf("%d", &d);
    l1+=d; l2+=d;
    used[d] = used[l1] = used[l2] = true;
  }
}

int main(){
  int n;

  rep(i,REPS) used[i]=false;

  scanf("%d", &n);
  solve(n);

  rep(i,REPS){
    if(!used[i]){
      printf("%d\n", i);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s;
  int a[26]={0};
  while(scanf("%c",&s)!=EOF){
    if('A'<=s&&s<='Z') a[(s-'A')]++;
    else if('a'<=s&&s<='z') a[(s-'a')]++;
  }
  for(int i=0;i<26;i++){
    cout << (char)(i+'a') << " : " << a[i] << endl;
  }
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	s64 N;
	cin >> N;
	
	map<s64, u64> A1;
	map<s64, u64> A2;
	
	for(s64 i=0; i<N; i++) {
		s64 A;
		cin >> A;
		A1[i + A]++;
		A2[i - A]++;
	}
	
	u64 ans = 0;
	for(const auto& a : A1) {
		if(A2.count(a.first)) {
			ans += A2[a.first] * a.second; 
		}
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 26640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a == 1){ return a; } else{ return a * fact(a - 1); } }

int main(){
    ll N, K, Q;
    map<ll, ll> A;
    cin >> N >> K >> Q;
    rep(i, 0, Q){
        ll temp;
        cin >> temp;
        A[temp - 1]++;
    }
    rep(i, 0, N){
        ll temp;
        temp = K - Q + A[i];
        if (temp > 0){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 7424
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 10000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)
		spf[i] = i;

	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (ll j = i * i; j < MAXN; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// sieve(MAXN);
	ll n;
	cin >> n;
	vl div(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j * i <= n; j++)
			div[i * j]++;
	}
	ll ans = 0;
	FOR(i, 1, n)	ans += i * div[i];
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 81340
// Example program
#include <iostream>
#include <string>
using namespace std;

int c;
string s,t;
int main()
{
    cin>>s>>t;
    for(int i=0;i<s.length();i++)
        if(s[i]!=t[i])
            c++;
    cout<<c;
    return 0;
}


Measured memory_bytes: 3872
#include <stdio.h>
#include <math.h>

typedef long long ll;

int dat[555555*2];
int ok[555555*2];
int isp[1555555];
ll p[1555555];
int pc;

void sieve(ll S)
{
  ll i,j;
  pc = 0;
  //for( i = 0; i <= S; i++ ) isp[i] = 1;
  isp[0] = isp[1] = 1;
  for( i = 2; i*i <= S; i++ ) {
    if( isp[i] ) continue;
    for( j = i*i; j <= S; j += i ) isp[j] = 1;
  }
  for( i = 2; i <= S; i++ ) if( !isp[i] ) p[pc++] = i;
}

int main(void)
{
  ll a,l,r,i,v;
  int b,c,j,res;
  scanf("%lld%d",&a,&b);
  sieve(sqrt(a+b)+1);
  l = a-b;
  r = a+b;
  if( l < 2 ) l = 2;
  b = r-l+1;
  res = b;
  for( i = 0; i <= b; i++ ) dat[i] = 11111;
  //printf("%lld %lld %d\n",l,r,b);
  //printf("%d\n",pc);
  for( j = 0; j < pc; j++ ) {
    for( i = l/p[j]*p[j]; i <= r; i+=p[j] ) {
      if( i-l < 0 ) continue;
      if( ok[i-l] ) continue;
      c = 0;
      v = i;
      while( v%p[j]== 0 ) {
        v/=p[j],++c;
        if( dat[i-l] < c ) break;
      }
      if( dat[i-l] < c ){ res--; ok[i-l] = 1; }
      dat[i-l] = c;
      //printf("%lld\n",i);
    }
  }
  /*
  for( i = 0; i < b; i++ ) {
    //if( ok[i] ) printf("%lld ",i+l);
    res += ok[i];
  }
  */
  //puts("");
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 17592
import sys
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
S = [list(map(str, list(input()))) for i in range(H)]
floor = [[0] * W for i in range(H)]
floor[Ch - 1][Cw - 1] = 1



def water(x, y):
    if floor[y][x] != 0:
        kouho.append([x, y])
        # 上
        if y + 1 < H:
            if S[y + 1][x] != "#" and floor[y + 1][x] == 0:
                floor[y + 1][x] = floor[y][x]
                water(x, y + 1)
        # 下
        if y - 1 >= 0:
            if S[y - 1][x] != "#" and floor[y - 1][x] == 0:
                floor[y - 1][x] = floor[y][x]
                water(x, y - 1)
        # 右
        if x + 1 < W:
            if S[y][x + 1] != "#" and floor[y][x + 1] == 0:
                floor[y][x + 1] = floor[y][x]
                water(x + 1, y)
        # 左
        if x - 1 >= 0:
            if S[y][x - 1] != "#" and floor[y][x - 1] == 0:
                floor[y][x - 1] = floor[y][x]
                water(x - 1, y)


def warp(x, y, i):
    for Y in range(max(y - 2, 0), min(y + 2, H - 1) + 1):
        for X in range(max(x - 2, 0), min(x + 2, W - 1) + 1):
            if S[Y][X] != "#" and floor[Y][X] == 0:
                floor[Y][X] = i + 1
                water(X, Y)

kouho = deque()
# スタート地点に水を流す
water(Cw - 1, Ch - 1)
# print(floor)

# ワープ回数
for i in range(1, 1000000):
    flag = False
    new_kouho = kouho.copy()
    kouho.clear()
    for n in new_kouho:
        x = n[0]
        y = n[1]
        if floor[y][x] == i:
            warp(x, y, i)
            flag = True

    if floor[Dh - 1][Dw - 1] != 0:
        print(floor[Dh - 1][Dw - 1] - 1)
        # print(floor)
        sys.exit()

    if flag == False:
        print("-1")
        sys.exit()


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

int main(void) {
	long long k, a, b;

	std::cin >> k >> a >> b;

	if (b - a > 1) {
		; // 処理なし
	}
	else {
		std::cout << k + 1 << std::endl;
		return 0;
	}

	long long bskt = 1;
	for (long long i = 0; (bskt < a) && (k != 0); i++) {
		bskt++;
		k--;
	}

	if (k == 0) {
		std::cout << bskt << std::endl;
		return 0;
	}

	if (k == 1) {
		std::cout << bskt + 1 << std::endl;
		return 0;
	}

	for (long long i = 0; i < k / 2; i++) {
		bskt = bskt - a + b;
	}

	k %= 2;

	std::cout << bskt + k << std::endl;


	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
all_sum = 0
#0から(2^n-1)-1までループ
for bit in range(1<<(n-1)):
    func = s[0]
    for i in range(n-1):
        if bit & (1<<i):
            func += "+"
        func += s[i+1]
    
    all_sum += sum(map(int, func.split('+')))
print(all_sum)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
const int maxn = (int)2e5 + 1;
const DB pi = acos((DB)-1);
int main() {
	int T = 1;
	// scanf("%d", &T);
	for(int Case = 1; Case <= T; ++Case) {
		int lim;
		static char buf[maxn];
		scanf("%d%s", &lim, buf);
		int len = strlen(buf);
		if(len > lim) {
			buf[lim] = buf[lim + 1] = buf[lim + 2] = '.';
			len = lim + 3;
			buf[len] = '\0';
		}
		printf("%s\n", buf);
	}
	return 0;
}

Measured memory_bytes: 3760
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from collections import deque

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

a = deque(list(i_s()))
b = deque(list(i_s()))
c = deque(list(i_s()))

x = a.popleft()
while True:
    if a and x == 'a':
        x = a.popleft()
    elif not a and x == 'a':
        print('A')
        exit()
    elif b and x == 'b':
        x = b.popleft()
    elif not b and x == 'b':
        print('B')
        exit()
    elif c and x == 'c':
        x = c.popleft()
    elif not c and x == 'c':
        print('C')
        exit()


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>
#include <iomanip>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

ll double_to_ll(double d){
	if(d>0)return d+0.5;
	return d-0.5;
}

void _main(istream &inp){
	string s;
	inp >> s;
	int ret = s.size();
	int m = 0;
	rep(i,s.size()){
		if(s[i]=='S'){
			m++;
		}
		else if(s[i]=='T'){
			if(m>0){
				m--;
				ret-=2;
			}
		}
	}
	cout << ret << endl;

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int *dish;
    dish = new int[5];
  int total = 0;
  int rem = 10;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&dish[i]);
    }
  for(int i=0;i<5;i++)
  {
    int r = dish[i] % 10;
    if( (r!=0) && (r < rem))
    {
      rem = r;
    }
      total += (dish[i]/10 +(r!=0));
  }
  total = total * 10;
  total += rem - 10;
    cout << total << endl;
}


Measured memory_bytes: 256
parseLine() = parse.(Int,split(readline()))
function main()
    N,M,K=parseLine()
    for x=0:N
        if N-2x!=0 && (K-x*M)%(N-2x)==0 && 0≤(K-x*M)/(N-2x)≤M
            println("Yes")
            exit()
        end
    end
    println("No")
    
end

main()

Measured memory_bytes: 171184
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class BStoneMonument {
public:
    void solve(std::istream &in, std::ostream &out) {
      int a, b;
      in >> a >> b;
      out << ((a - b) * (a - b) - (a + b)) / 2 << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BStoneMonument solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Dinic {
  struct edge {
    int to, capacity, rev, id, isrev;
    edge(){}
    edge(int to, int capacity, int rev):to(to), capacity(capacity), rev(rev){}
  };

  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int sz):graph(sz), level(sz), iter(sz){};
  void add_edge(int from, int to, int capacity) {
    graph[from].push_back(edge(to, capacity, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, (int)graph[from].size()-1));
  }
  void bfs(int source) {
    fill(level.begin(), level.end(), -1);
    queue<int> que;
    level[source] = 0;
    que.push(source);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)graph[v].size(); i++) {
	edge& e = graph[v][i];
	if(e.capacity > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int sink, int f) {
    if(v == sink) return f;
    for(int &i = iter[v]; i < (int)graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.capacity > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, sink, min(f, e.capacity));
	if(d > 0) {
	  e.capacity -= d;
	  graph[e.to][e.rev].capacity += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int source, int sink) {
    int flow = 0;
    while(1) {
      bfs(source);
      if(level[sink] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      int f; while((f = dfs(source, sink, inf)) > 0) flow += f;
    }
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M, s, t;
  cin >> N >> M >> s >> t;
  --s, --t;
  int G[202][202];
  fill(G[0], G[202], inf);
  rep(i, N) G[i][i] = 0;
  vint u(M), v(M), d(M), c(M);
  rep(i, M) {
    cin >> u[i] >> v[i] >> d[i] >> c[i];
    --u[i], --v[i];
    G[u[i]][v[i]] = d[i];
  }
  rep(i, N) rep(j, N) rep(k, N) chmin(G[j][k], G[j][i]+G[i][k]);
  Dinic dinic(N);
  rep(i, M) {
    //cout << G[s][u[i]]+d[i]+G[v[i]][t] <<" "<< G[s][t] << endl;
    if(G[s][u[i]]+d[i]+G[v[i]][t] == G[s][t]) {
      //cout<<i<<endl;
      dinic.add_edge(u[i], v[i], c[i]);
    }
  }
  cout << dinic.max_flow(s, t) << endl;

  return 0;
}



Measured memory_bytes: 3616
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = ""; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def inp(): return int(sys.stdin.readline())
def st(): return input()
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

# LCS
def main():
    s = st()
    t = st()
    slen = len(s)
    tlen = len(t)
    # まず，長さを求める
    # dp[i][j]=(sをi文字目、tをj文字目までみた時の最長共通部分列の長さ)とする
    dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
    # slenはSの長さ、tlenはTの長さとする
    for i in range(1, slen + 1):
        for j in range(1, tlen + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1  # この文字は使ったほうがいい
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])  # どっちかの最後の1文字は使わない

    # dp[slen][tlen]が求める長さ

    # 文字復元
    length = dp[slen][tlen]
    i = slen
    j = tlen
    ans = ["" for _ in range(length)]
    while length > 0:
        if s[i - 1] == t[j - 1]:
            ans[length - 1] = s[i - 1]
            i -= 1
            j -= 1
            length -= 1
        elif dp[i][j] == dp[i - 1][j]: # i文字目が無くても同じ，i文字目は使わない
            i -= 1
        else:
            j -= 1
    print("".join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 125656
#include<bits/stdc++.h>
int main() {
	long long num; std::cin >> num;
	std::vector<long long>v(num + 1, 0);
	for (long long x = 1; x <= num; x++) {
		v[x]++;
		for (long long z = x * 2; z <= num; z += x) {
			v[z]++;
		}
	}
	long long ans = 0;
	for (long long x = 1; x <= num; x++) {
		ans += (1LL * x * v[x]);
	}

	std::cout << ans;
}


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

#define ll              long long int
#define mod             1000000007

int main()
{

    string s;
    cin>>s;
    int c=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='o'){
            c++;
        }
    }

    cout<<700+(c*100)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define int long long
#define mod 1000000007

int dp[3000][3000];

int solve1(int* a, int l, int r) {
	if (l > r)return 0;
	if (dp[l][r] != -1)return dp[l][r];
	if (l == r)return dp[l][r] = a[l];
	dp[l][r] = max(a[l] - solve1(a, l + 1, r) , a[r] - solve1(a, l, r - 1));
	return dp[l][r];
}

void solve() {
	int n;
	cin >> n;
	int a[n];
	int i;
	for (i = 0; i < n; i++)cin >> a[i];

	memset(dp, -1, sizeof(dp));
	int j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i > j)dp[i][j] = 0;
			else if (i == j)dp[i][j] = a[i];
		}
	}

	int len = solve1(a, 0, n - 1);
	cout << len << endl;

	return;
}


int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 74184
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$n = $a + $b + $c;
$f = 0;
if ($n % 2 == 0) {
	$h = $n / 2;
	if ($a + $b == $h || $a + $c == $h || $b + $c == $h) $f = 1;
}
echo $f ? 'Yes' : 'No', "\n";

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, y;
	cin >> n >>y;
	
	int yy = y/1000;
	
	rep(i, 2001) rep(j,  4001){
		
		int k = n - i - j;
		if(k >=0 && 10*i+5*j+k == yy){
			printf("%d %d %d\n", i, j, k);
			return 0;
		}
	}
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	
	string s="";
	while(n!=0){
		if(n%-2==1){
			s = '1'+s;
			n /= -2;
		}else if(n%-2==-1){
			s = '1'+s;
			n /= -2;
			n += 1;
		}else{
			s = '0'+s;
			n /= -2;
		}
	}
	
	if(s.size()==0) s = "0";
	cout << s << endl;
	
	
	return 0;
}

Measured memory_bytes: 3632
import itertools
N,M,Q = map(int,input().split())
ABCD = [[int(i) for i in input().split()] for j in range(Q)]
ans = []
#数列を全部作る(組み合わせの全列挙)→各数列に対して得点を計算する
As = itertools.combinations_with_replacement(range(1,M+1),N)

for A in As:
    score = 0
    for a,b,c,d in ABCD:
        if A[b-1]-A[a-1] == c:
            score += d
    ans.append(score)
print(max(ans))

Measured memory_bytes: 12832
from collections import deque

def bfs(si, sj):
    q = deque()
    q.append([si, sj, 0])
    used = set()
    used.add((si,sj))
    ans = MAX_VALUE
    while len(q) > 0:
        prvi, prvj, d = q.popleft()
        for i, j in [[prvi-1, prvj], [prvi+1, prvj], [prvi, prvj-1], [prvi, prvj+1]]:
            if (i,j) in used:
                continue
            if grid[j][i] == '#':
                ans = min(ans, d)
                continue
            else:
                q.append([i,j,d+1])
                used.add((i,j))
    return d

H, W = map(int, input().split())
MAX_VALUE = (H+2) * (W+2) + 1
grid = ['#'*(W+2)] + [ '#' + input() + '#' for _ in range(H)] + ['#'*(W+2)]

ans = 1
for j in range(1, H + 1):
    for i in range(1, W + 1):
        if grid[j][i] == '#':
            continue
        res = bfs(i, j)
        if res != MAX_VALUE:
            ans = max(ans, res)
print(ans)



Measured memory_bytes: 3316
def main():
  n = int( input() )
  s = input()
  
  cnt = True
  
  if len(s) % 2 == 1:
    cnt = False
    
  for i in range( int(len(s)/2) ):
    if(s[i] == s[i + int(len(s)/2) ]):
      continue
    else:
      cnt = False
      
  if cnt == True:
    print("Yes")
  else:
    print("No")

if __name__ == '__main__': main()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  while(!(a % 2) && !(b % 2) && !(c % 2)) {
    ans++;
    if(a == b && a == c) {
      cout << -1 << endl;
      return 0;
    }
    int tmp1 = a, tmp2 = b;
    a = b / 2 + c / 2;
    b = tmp1 / 2 + c / 2;
    c = tmp1 / 2 + tmp2 / 2;
  }
  cout << ans << endl;
}


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

int main() {
    string s;
    cin>>s;
    int f=0,g=0;
    if(s[2]==s[3])
    {
        f=1;
    }
    if(s[4]==s[5])
    {
        g=1;
    }
    if(f&&g)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
	// your code goes here
	return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	for(int i = 0; i < n; ++i) cout << s[i] << t[i];

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cctype>
#include <cstdio>



using namespace std;



int main()
{
    int a,b;
    cin>>a>>b;
    if(a%2!=0 && b%2!=0){
        printf("Odd\n");
    }
    else{
        printf("Even\n");
    }

    return 0;
}

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n >> m;
	map < int, int > cnt;
	cur = inf;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		if (cur != inf)
			cnt[a[i] - cur] ++;

		if (cur > a[i]) cur = a[i];
	}


	ll ans = 0;
	for (auto it : cnt) {
		ans = it.S;
	}

	cout << ans << '\n';



   	return Accepted;
}

// B...a

Measured memory_bytes: 23424
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<String> Ans = new ArrayList<String>();
		String line = in.readLine();
		
		int size = Integer.parseInt(line);
		for(int n=0; n<size; n++){
			line = in.readLine();
			int num = 0;
			List<String> train = new ArrayList<String>();
			train.add(line.substring(0, 1));
			for(int i=1; i<line.length(); i+=3){
				String arrow = line.substring(i, i+2);
				String tr = line.substring(i+2, i+3);
				if(arrow.equals("->")){
					if(num == train.size()-1){
						train.add(tr);
						num += 1;
					}
					else{
						num += 1;
					}
				}
				if(arrow.equals("<-")){
					if(num == 0){
						train.add(0, tr);
					}
					else{
						num -= 1;
					}
				}
			}
			
			String str = "";
			for(int m=0; m<train.size(); m++){
				str += train.get(m);
			}
			
			Ans.add(str);
		}
		
		for(int n=0; n<Ans.size(); n++){
			System.out.println(Ans.get(n));
		}
	}
}

Measured memory_bytes: 10000
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    char s[4];
    cinf(4,s);
    if(s[0] == s[1] && s[2] == s[3] && s[0]!=s[2]) cout << "Yes";
    else if(s[0] == s[2] && s[1] == s[3] && s[0]!=s[1]) cout << "Yes";
    else if(s[0] == s[3] && s[1] == s[2]&& s[0]!=s[1]) cout << "Yes";
    else if(s[0] == s[4] && s[1] == s[1]&& s[0]!=s[1]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int y,n,i,j;
  scanf("%d%d",&n,&y);
  for(i=0;i<=n;i++)for(j=0;j<=n-i;j++)if(n+i*9+j*4==y/1000){printf("%d %d %d",i,j,n-i-j);return 0;}
  printf("-1 -1 -1");
}


Measured memory_bytes: 1676
n = int(input())
s1 = list(input())
s2 = list(input())
code = []

i = 0
while i < len(s1):
  if s1[i] == s2[i]:
    code.append('S')
    i += 1
  else:
    code.append('D')
    i += 2

mod = 1000000007
if code[0] == 'S':
  ptn = 3
else:
  ptn = 6
for i in range(1, len(code)):
  x, y = code[i-1], code[i]

  if x == 'S' and y == 'S':
    ptn = (ptn * 2) % mod
  elif x == 'S' and y == 'D':
    ptn = (ptn * 2) % mod
  elif x == 'D' and y == 'D':
    ptn = (ptn * 3) % mod
  elif x == 'D' and y == 'S':    
    ptn = ptn
print(ptn)


Measured memory_bytes: 3064
N=int(input())
keta=len(str(N))

sum = 0
if keta%2==0: #桁が偶数
  kaisuu = keta//2
  for i in range(kaisuu):
    sum = sum + 9 * (10 ** (i*2))
else: # 桁が奇数
  if keta == 1:
    sum = N
  else:
    kaisuu = (keta-1)//2
    for i in range(kaisuu):
      sum = sum + 9 * (10 ** (i*2))
    sum = sum + (N - ((10 ** (keta-1)) - 1))

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, M, Q, f[100100];
vector<int> adj[100100];
bool s[100100][11];
tuple<int, int, int> q[100100];

void go (int i, int j, int k) {
        if (j<0 || s[i][j]) return;
        s[i][j] = true, f[i] = max(f[i], k);
        for (int t : adj[i]) go(t, j-1, k);
}

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 1, M+1) {
                int a, b; scanf("%d %d", &a, &b);
                adj[a].PB(b), adj[b].PB(a);
        }
        scanf("%d", &Q);
        fo(i, 1, Q+1) {
                int a, b, c; scanf("%d %d %d", &a, &b, &c);
                q[i] = make_tuple(a, b, c);
        }
        for (int i = Q; i >= 1; i--) {
                int a, b; tie(a,b,ignore) = q[i];
                go(a, b, i);
        }
        fo(i, 1, N+1) {
                printf("%d\n", get<2>(q[f[i]]));
        }
        return 0;
}


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

using namespace std;

string S;

int main()
{
	cin >> S;

	if (S[0] == S[1]) printf("Bad");
	else if (S[1] == S[2]) printf("Bad");
	else if (S[2] == S[3]) printf("Bad");
	else printf("Good");

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, d = 0, e;
	scanf("%d %d %d", &a, &b, &c);
	for (e = a; e <= b; e++)
	{
		if (c%e == 0)d += 1;
	}
	printf("%d\n", d);
	return 0;
}


Measured memory_bytes: 2128
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

long calc(int k, int[][] ps) {
    ps.sort!((a, b) => a[0] < b[0]);

    long ans = long.max;
    auto n = ps.length;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (j - i + 1 < k)
                continue;

            int[] ys;
            for (int m = i; m <= j; m++)
                ys ~= ps[m][1];
            ys.sort();

            int[] us;
            for (int m = 0; m < ys.length; m++) {
                if (us.length >= k) {
                    us = us[1 .. $];
                }

                us ~= ys[m];

                if (us.length >= k) {
                    long x = cast(long) ps[j][0] - cast(long) ps[i][0];
                    long y = cast(long) us[$ - 1] - cast(long) us[0];
                    long area = x * y;
                    ans = min(ans, area);
                }
            }
        }
    }

    return ans;
}

void main() {
    auto nk = readints;
    int n = nk[0], k = nk[1];

    int[][] ps;
    for (int i = 0; i < n; i++) {
        auto p = readints;
        ps ~= p;
    }

    writeln(calc(k, ps));
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using i64 = long long;

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

int main() {
    i64 n, x, d;
    std::cin >> n >> x >> d;

    if (!d) {
        std::cout << (x ? n + 1 : 1) << std::endl;
        return 0;
    }

    if (d < 0) {
        d = -d;
        x = -x;
    }

    i64 g = gcd(llabs(x), llabs(d));
    x /= g;
    d /= g;

    i64 ret = 1;
    std::map<i64, std::pair<i64, i64>> done;
    i64 minsum = 0, maxsum = 0;
    done[0] = std::make_pair(0, 0);
    for (int i = 1; i <= n; i++) {
        minsum += i - 1;
        maxsum += n - i;
        i64 min = x * i + d * minsum,
            max = x * i + d * maxsum;
        if (min > max) std::swap(min, max);

        i64 rem = (d + min % d) % d;
        if (done.count(rem)) {
            auto p = done[rem];
            i64 ll = std::max(min, p.first), rr = std::min(max, p.second);
            if (ll <= rr) ret -= (rr - ll) / d + 1;
            ret += (max - min) / d + 1;
            done[rem] = std::make_pair(std::min(p.first, min), std::max(p.second, max));
        } else {
            ret += (max - min) / d + 1;
            done[rem] = std::make_pair(min, max);
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 12800
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int n,N;
vector<int> v;

void init(){
    N=1;
    while(N<n) N*=2;
    v.assign(2*N-1,inf); //変更点
}

void init_u(){
    for(int i=N-2;i>=0;i--)
    v[i]=min(v[2*i+1],v[2*i+2]); //変更点
}

void update(int k,int a){
    k+=N-1;
    v[k]=a;
    while(k>0){
        k=(k-1)/2;
        v[k]=min(v[k*2+1],v[k*2+2]); //変更点
    }
}

//query(a,b,0,0,N);
int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return inf; //変更点
    if(a<=l && r<=b) return v[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr); //変更点
}

int main(){
    cin>>n; n+=2;
    init();
    n-=2;
    rep(i,n) cin>>v[i+N];
    v[N-1]=0; v[n+N]=0;
    init_u();
    ll ans=0;
    rep(i,n){
        ll a=v[i+N],L,R;
        int l=0,r=i+1,c;
        while(l!=r){
            c=(l+r+1)/2;
            int d=query(c,i+2,0,0,N);
            if(d<a) l=c;
            else r=c-1;
        }
        L=i+1-l;
        l=i+1; r=n+1;
        while(l!=r){
            c=(l+r)/2;
            int d=query(i+1,c+1,0,0,N);
            if(d<a) r=c;
            else l=c+1;
        }
        R=l-(i+1);
        ans+=L*R*a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string a,c;
    ll i,j=0,k,l;
    cin>>a>>c;
    for(i=0;i<a.size();i++)
    {
        if(a[i]!=c[i])
        {
            j=1;
        }
    }
    if(j) printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi a(n);
    rep(i, 0, n) { cin >> a[i]; }

    // O(n)
    vi ans(n, 0);
    rep(i, 0, n) { ans[0] += a[i] * (i % 2 == 0 ? 1 : -1); }
    rep(i, 1, n) { ans[i] = 2 * a[i - 1] - ans[i - 1]; }

    rep(i, 0, n) { cout << ans[i] << " "; }
    cout << endl;

    return 0;
}

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

int main(){
  multiset<int>max;
  int N;
  cin >> N;
  for(int i=1; i<=N; i++){
    int M;
    cin >> M;
    for(int j=1; j<=M; j++){
      int c;
      cin >> c;
      max.insert(c);
      if(max.size() > i) max.erase(max.begin());
    }
  }
  unsigned long long ans=0;
  for(auto it=max.begin(); it!=max.end(); it++)ans += *it;
  cout << ans << endl;
}



Measured memory_bytes: 17068
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll f[1000005];

int main() {
  int n;
  scanf("%d",&n);
  f[1]=n;
  ll s=n-1;
  for(int i=2;i<=n;i++) {
  	if (i>=4) s=(s+f[i-3]-1+MOD)%MOD;
  	f[i]=(f[i-1]+(ll)(n-1)*(n-1)+s)%MOD;
  }
  printf("%lld\n",f[n]);
  return 0;
}

Measured memory_bytes: 7936