akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC127_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var r = ss[0];
            var d = ss[1];
            var x = ss[2];
            var ans = new int[10];
            for(var i=0;i<10;i++)
            {
                if(i==0)
                {
                    ans[0] = r * x - d;
                }
                else
                {
                    ans[i] = r * ans[i - 1] - d;
                }
            }
            foreach(var ch in ans)
            {
                Console.WriteLine(ch);
            }
        }
    }
}


Measured memory_bytes: 11220
import sys
import itertools
input = sys.stdin.readline

def main():
    N = int(input())
    l = [a*b for a,b in itertools.product(range(1,10),range(1,10))]

    ll = list(set(l))

    if N in ll:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int a[100100][5]={0};
  for(int i=1;i<=N;i++){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  ll dp[100100][5]={0};
  for(int i=0;i<=2;i++){
    dp[1][i]=a[1][i];
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<=2;j++){
      dp[i+1][j]=max(dp[i][(j+1)%3]+a[i+1][j],dp[i][(j+2)%3]+a[i+1][j]);
    }
    //cout << max({dp[i][0],dp[i][1],dp[i][2]}) << endl;
  }
  ll ans=max({dp[N][0],dp[N][1],dp[N][2]});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
h w
n
a1 ... an

h w 100
n hw
a1 + ... + an = hw

iro 1 ... n
 */
int h,w,n,a[10000];
int field[100][100];

int main(){
  cin>>h>>w>>n;
  REP(i,n){
    cin>>a[i];
  }

  int i=0,j=0;
  REP(k,n){
    while(a[k]>0){
      if(i%2==0){
        field[i][j] = k+1;
      } else {
        field[i][w-j-1] = k+1;
      }

      j++;
      if(j==w){
        j=0;
        i++;
      }
      a[k]--;
    }
  }

  REP(i,h){
    REP(j,w){
      cout<<field[i][j]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int N, A;
	scanf("%d", &N);
	int cnt[N];
	fill_n(cnt, N, 0);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &A);
		cnt[A - 1] += 1;
	}
	vector<int> c, p;
	for (int i = 0; i < N; ++i) {
		if (cnt[i] != 0) c.push_back(cnt[i]);
	}
	sort(c.begin(), c.end());
	p.push_back(c.front());
	for (int i = 1; i < c.size(); ++i) p.push_back(p.back() + c[i]);
	for (int i = 1; i <= N; ++i) {
		int l = 0, u = N / i, m;
		while (l != u) {
			m = (l + u) / 2 + 1;
			int id = lower_bound(c.begin(), c.end(), m) - c.begin();
			int t = c.size() - id;
			if (id != 0) t += p[id - 1] / m;
			if (t >= i) l = m;
			else u = m - 1;
		}
		printf("%d\n", l);
	}
	return 0;
}

Measured memory_bytes: 5616
/**
  * Created by ui on 2016/02/01.
  */
import scala.io.StdIn._
import Math._
object Main {
  def main(args: Array[String]) {
    val r = readDouble()
    val s = PI * pow(r, 2)
    val l = 2 * PI * r
    val ss = BigDecimal(s)
    val ll = BigDecimal(l)
    val sss = ss.setScale(6, scala.math.BigDecimal.RoundingMode.HALF_UP)
    val lll = ll.setScale(6, scala.math.BigDecimal.RoundingMode.HALF_UP)
    println(sss + " " + lll)
  }
}

Measured memory_bytes: 44020
while True:
	try:
		A=[[]]*10
		A[0]=list(map(int,input()))
		for i in range(1,10):
			A[i]=[0]*(10-i)		
		for i in range(1,10):
			for j in range(0,len(A[i])):
				A[i][j]=(A[i-1][j]+A[i-1][j+1])%10
		print(A[9][0])
	
	except EOFError:
		break

Measured memory_bytes: 7520
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
#define maxx 110000
typedef long long ll;
string a;

int main()
{
    cin>>a;
    int n =(int)a.size();
    string b;
    b=a;
    int tans1 = 0;
    int tans2 = 0;
    if(b[0]=='0') tans1++,b[0]='1';
    for(int i=1;i<n;i++)
    {
        if(b[i]==b[i-1])
        {
            if(b[i-1]=='0') b[i]='1';
            else b[i]='0';
            tans1++;
        }
    }
    b=a;
    if(b[0]=='1') tans2++,b[0]='0';
    for(int i=1;i<n;i++)
    {
        if(b[i]==b[i-1])
        {
            if(b[i-1]=='0') b[i]='1';
            else b[i]='0';
            tans2++;
        }
    }
    cout<<min(tans1,tans2)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll N;
    cin >> N;

    vector<string> name(N);
    vector<int> score(N);
    vector<tuple<string,int,int>> R(N);
    REP (i,N) {
        cin >> get<0>(R[i]) >> get<1>(R[i]);
        get<1>(R[i]) *= -1;
        get<2>(R[i]) = i+1;
    }

    sort(ALL(R));
    REP (i,N) {
        cout << get<2>(R[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

const inf = 1 << 60

func main() {
	var aPrice, bPrice, aANDbPrice, aNeed, bNeed int
	fmt.Scan(&aPrice, &bPrice, &aANDbPrice, &aNeed, &bNeed)
	aANDbPrice *= 2

	ans := inf
	for i := 0; i < 100010; i++ {
		price := aANDbPrice * i
		if i < aNeed {
			price += aPrice * (aNeed - i)
		}
		if i < bNeed {
			price += bPrice * (bNeed - i)
		}
		if price < ans {
			ans = price
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
    while(cin>>a>>b>>c>>d)
    {
        if(abs(a-c)<=d)
        {
            cout<<"Yes\n";
        }
        else
        {
            if(abs(a-b)<=d&&abs(b-c)<=d)
            {
                cout<<"Yes\n";
            }
            else
                cout<<"No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;

ll a,b,c,d;
map<ll,ll> dp;
map<ll,bool> done;

ll solve(ll x)
{
    if(!x)
        return 0;
    if(done[x])
        return dp[x];
    done[x]=1;
    ll v1=solve(x/2)+min(a+(x&1)*d,min((x-(x/2)),(ll)4e9)*d);
    ll v2=solve(x/3)+min(b+(x%3)*d,min((x-(x/3)),(ll)4e9)*d);
    ll v3=solve(x/5)+min(c+(x%5)*d,min((x-(x/5)),(ll)4e9)*d);
    dp[x]=min(v1,min(v2,v3));
    v1=solve((x/2)+1)+a+(2-(x%2))*d;
    v2=solve((x/3)+1)+b+(3-(x%3))*d;
    v3=solve((x/5)+1)+c+(5-(x%5))*d;
    dp[x]=min(min(dp[x],v1),min(v2,v3));
//    cout << dp[x] << ' ' << x << '\n';
    return dp[x];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while(t--)
    {
        dp.clear();
        done.clear();
        ll n;
        cin >> n >> a >> b >> c >> d;
        db(solve(n))
//        db("")
    }

    return 0;
}
/**
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321
**/


Measured memory_bytes: 6064
x, y = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(x-y+1):
    if i == 0:
        z = sum(p[:y])
    else:
        z = z - n + p[i+y-1]
    n = p[i]
    if z > ans:
        ans = z

print((ans+y)/2)

Measured memory_bytes: 71792
import sys

N = int(raw_input())
A = map(int, raw_input().split())
a_str = map(str, A)
print(" ".join(a_str))
for i in range(1, len(A)):
	key = A[i]
	j = i - 1
	while j >= 0 and A[j] > key:
		A[j + 1] = A[j]
		j -= 1
	A[j + 1] = key
	a_str = map(str, A)
	print(" ".join(a_str))

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5050;
int n, a, b;
int loc[N];
ll f[N][2 * N];
int main() {
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++) {
		int t; scanf("%d", &t); loc[t] = i;
	}
	memset(f, 127, sizeof f);
	memset(f[0], 0, sizeof f[0]);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= 2 * n; j++) {
			f[i][j] = f[i - 1][j - (j & 1)];
			if (j < loc[i] * 2) f[i][j] += b;
				else if (j > loc[i] * 2) f[i][j] += a;
			f[i][j] = min(f[i][j - 1], f[i][j]);
		}
	}
	ll ans = 1e18;
	for(int j = 1; j <= 2 * n; j++) ans = min(ans, f[n][j]);
	cout << ans << endl;
}

Measured memory_bytes: 398848
import math
from fractions import Fraction
import sys


class multipliable_2x2matrix(object):
    def __init__(self, a, b, c, d):
        self.a = a;
        self.b = b;
        self.c = c;
        self.d = d;
    def mul(self, b):
        return multipliable_2x2matrix(
            self.a * b.a + self.b * b.c,
            self.a * b.b + self.b * b.d,
            self.c * b.a + self.d * b.c,
            self.c * b.b + self.d * b.d)
    
def fib(n):
    if n == 0: return 0
    m = multipliable_2x2matrix(1, 1, 1, 0)
    f = multipliable_2x2matrix(1, 0, 0, 1)
    n = n - 1
    while n > 0:
        if n & 1 == 1:
            f = f.mul(m)
        n = n >> 1
        m = m.mul(m)
    return f.a



n, m =map(int, input().split())  #複数数値入力
a = [-1]
for i in range(m):
    ai = int(input())
    a.append(ai)
a.append(n+1)

count = 1
root5 = math.sqrt(5)
for i in range(m+1):
    x = a[i+1] - a[i] -1
    if x == 0:
        count = 0
        break
    else:
#         y = 1/root5 *(((1+root5)/2)**x - ((1-root5)/2)**x) 
        count *= fib(x)
print(int(count)%1000000007)

Measured memory_bytes: 9108
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <vector>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;
int compare_int(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}
typedef struct Item {
	int num;
	string name;
	int point;
}Item;
int main(void) {
	/*int a, p;
	scanf("%d %d", &a, &p);
	printf("%d", (p+3 * a) / 2);
	return 0;*/
	map<int, Item>mp;
	int n;
	scanf("%d", &n);
	int p[101];
	char s[101][13];
	for (int i = 0; i < n; i++) {
		scanf("%s %d", &s[i], &p[i]);
		Item item = {i+1, s[i], p[i] };
		mp[i] = item;
	}
	for (int i = n - 1; i >= 1; i--) {
		for (int j = i - 1; j >= 0; j--) {
			if (mp[j].name.compare(mp[i].name) > 0) {
				Item temp;
				temp = mp[j];
				mp[j] = mp[i];
				mp[i] = temp;
			}
		}
	}
	for (int i = n - 1; i >= 1; i--) {
		for (int j = i - 1; j >= 0; j--) {
			if (mp[j].point < mp[i].point && mp[j].name.compare(mp[i].name)==0) {
				Item temp;
				temp = mp[j];
				mp[j] = mp[i];
				mp[i] = temp;
			}
		}
	}
	
	for (int i = 0; i < n; i++) {
		printf("%d\n", mp[i].num);
	}
	
	

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int ans = 0;
		if(a < b) {
			ans += a;
		} else {
			ans += b;
		}
		if(c < d) {
			ans += c;
		} else {
			ans += d;
		}
		System.out.println(ans);
	}

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    if (n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - (n % 1000) << endl;
}

Measured memory_bytes: 3636
# 2019/07/25

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

one=a.index(1)
ans=float('inf')

for i in range(k):
    l=one
    r=n-one-1

    l-=i
    r-=(k-i-1)
    ans=min(-(-l//(k-1))+-(-r//(k-1))+1,ans)

print(ans)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

set<int> ban;
int n, k, d;

bool valid (int x) {
    while (x) {
        if (ban.count(x % 10)) {
            return false;
        }
        x /= 10;
    }
    return true;
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> k;
    REP (i, k) {
        cin >> d;
        ban.insert(d);
    }

    while (true) {
        if (valid(n)) {
            cout << n << endl;
            return 0;
        }
        n++;
    }
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

int n, q;
vector<int> G[300000];
int cost[300000];

void dfs(int x, int y) {
  cost[x] += cost[y];
  arep(i, G[x]) if (i != y) dfs(i, x);
}

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cin >> n >> q;
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  rep(i, 0, q) {
    int p, x;
    cin >> p >> x;
    cost[p] += x;
  }

  dfs(1, 0);

  rep(i, 1, n + 1) cout << cost[i] << ' ';

  cout << '\n';
  return 0;
}

Measured memory_bytes: 26880
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()
    i = len(S)
    while i > 0:
        ok = False
        for x in ["dreamer", "eraser", "dream", "erase"]:
            if S.startswith(x, i - len(x)):
                i -= len(x)
                ok = True
                break
        if not ok:
            print(NO)
            return
    print(YES)


if __name__ == '__main__':
    main()


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    N %= 1000;
    if (N == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - N << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
require 'scanf'

n = gets.to_i
n.times{
    x1, y1, x2, y2, x3, y3 = gets.scanf("%f %f %f %f %f %f ")
    
    dnm = (2*x2*y3-2*x1*y3+(2*x1-2*x3)*y2+(2*x3-2*x2)*y1)
    numx = -(y2*(y3**2-y1**2+x3**2-x1**2)+y1*((-y3**2)-x3**2+x2**2)+y1**2*y3-x2**2*y3+x1**2*y3+y2**2*(y1-y3))
    numy = (x2*(y3**2+x3**2-x1**2)+x1*((-y3**2)-x3**2)+(x1-x3)*y2**2+(x3-x2)*y1**2+x1**2*x3+x2**2*(x1-x3))

    x = numx / dnm
    y = numy / dnm

    r = Math.sqrt( (x1 - x) ** 2 + (y1 - y)**2)

    print "%.3f %.3f %.3f\n" % [x, y, r]

    # p numx, numy, dnm

}

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

bool verify (lli a)
{
    if (a == 0 || a == 1)
    {
        return true ;
    }
    if (a == 2 || a == 3)
    {
        return true ;
    }
    if (a % 2 == 0)
    {
        return false ;
    }
    for (lli i = 3 , end = sqrt(a) ; i <= end; i += 2)
    {
        if(a % i == 0)
        {
            return false ;
        }
    }
 
    return true ;
} 
int main ()
{
    lli a ;
    cin >> a ;

    while (1)
    {
        if (verify(a))
        {
            cout << a << endl ;
            return 0 ;
        }

        a++;
    }

    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main() {
  int N,K,now;
  cin >> N >> K;
  vector<int> D(K);
  rep(i,0,K){cin >> D[i];}
  bool sw = true;
  bool fin = false;
  
  for(int i = N; ; i++){
    sw = true;
    now = i;
    while(true){
      rep(j,0,K){
        if(now % 10 == D[j]){sw = false; break;}
      }
      if(sw == false){break;}
      now /= 10;
      if(now == 0){fin = true;break;}
    }
    if(fin == true){now = i; break;}
  }
  co(now);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll n = 50; ll k; cin >> k;
    vector<ll> ans;
    ll r = k % n;
    ll q = k / n;
    rep(i, n-r) ans.push_back(49-r);
    rep(i,r) ans.push_back(50);
    rep(i,n) ans[i] += q;
    cout << n << endl;
    rep(i,n) printf("%lld%c", ans[i], i == n-1 ? '\n' : ' ');
}

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

void main_()
{
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));

    for (ll i = 0; i < N; ++i) {
        ll w, v;
        cin >> w >> v;
        for (ll j = 0; j <= W; ++j) {
            if (j - w >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
            }

            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }
    ll ans = (sum * sum) % MOD;
    for(int i = 0; i < n; i++) {
        ans -= (a[i] * a[i]) % MOD;
        ans = (ans + MOD) % MOD;
    }
    ans = ans * 500000004;
    cout << ans % MOD << endl;
}

Measured memory_bytes: 4800
from operator import mul
from functools import reduce

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

    
if __name__ == '__main__':
  n,k  = list(map(int, input().split(" ")))
  
  
  for i in range( 2, N + 1 ):
      g1.append( ( g1[-1] * i ) % mod )
      inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
      g2.append( (g2[-1] * inverse[-1]) % mod )
  
  for i in range(1, k+1):
  	#print(cmb(n - k + 1, i, mod))
  	#print(cmb(k -1, i - 1, mod))
  	print((cmb(n - k + 1, i, mod) * cmb(k -1, i - 1, mod)) % mod)


Measured memory_bytes: 5220
#include <iostream>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main()
{
	int n, count = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	rep(i, n) {
		while (a.at(i) % 2 == 0) {
			a.at(i) /= 2;
			count++;
		}
	}	

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=LI()

	A=np.array(A)

	B=np.cumsum(A)
	C=np.cumsum(A[::-1])

	#print(B,C)

	D=abs(B[:-1]-C[:-1][::-1])
	#print(D)

	print(np.min(D))









if __name__ == "__main__":
	main()


Measured memory_bytes: 46168
N = int(input())
a = [int(input())-1 for _ in range(N)]

i = 0
c = 0
flag = 0
for _ in range(N):
    i = a[i]
    c += 1
    if i == 1:
        flag = 1 
        break

ans = c if flag else -1
print(ans)

Measured memory_bytes: 80092
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr Int INF = 1e18;
	int N;
	cin >> N;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	int skip = 1 + N % 2;
	vector<vector<Int>> dp(N + 2, vector<Int>(skip + 1, -INF));
	dp[0][0] = 0;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= skip; ++j) {
			if (j < skip) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
			}
			if (i < N) {
				dp[i + 2][j] = max(dp[i + 2][j], dp[i][j] + a[i]);
			}
		}
	}
	cout << dp[N + 1][skip] << endl;

	return 0;
}


Measured memory_bytes: 15664
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
    char *pp = (char*)malloc(size) + size;  \
    __asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (int)(1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
int n,a,b,c,d;
char s[200020];
signed main(){
    n=read(),a=read(),b=read(),c=read(),d=read();
    scanf("%s",s+1);
    FOR(i,a,c-1)if(s[i]=='#'&&s[i+1]=='#')return puts("No"),0;
    FOR(i,b,d-1)if(s[i]=='#'&&s[i+1]=='#')return puts("No"),0;
    if(a<b&&c>d){
    	bool v=0;
    	if(b>1)if(s[b-1]=='.'&&s[b]=='.'&&s[b+1]=='.')v=1;
    	if(d<n)if(s[d-1]=='.'&&s[d]=='.'&&s[d+1]=='.')v=1;
    	FOR(i,b,d-2)if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')v=1;
    	if(!v)return puts("No"),0;
    }
	puts("Yes");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int N;
long long T[100];

long long lcm(long long a,long long b){
    long long x = a;
    long long y = b;
    long long t;
    if(a < b){
        t = b;
        b = a;
        a = t;
    }
    while(b != 0){
        t = a % b;
        a = b;
        b = t;
    }
    return x / a * y;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> T[i];
    long long m = 1;
    for(int i=0;i<N;i++){
        m = lcm(m,T[i]);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y>>z;
std::vector<int> v(y);
rep(i,y)std::cin >> v[i];
rep(i,x){
  Rep(j,y){
    std::cin >> w;
    n+=w*v[j];
  }
  if(n+z>0)m++;
  n=0;
}
std::cout << m << '\n';
return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    char num[1001]; // 1000?
    int sum,i,n;
    for(;;){
        scanf("%s",num);
        i= 0;
        sum = 0;
        while(num[i] != 0){
            sum = sum + (num[i] - '0');
            i++;
            }
        if(sum == 0){
            break;
        }
        printf("%d\n", sum);
    }
        return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const double EPS = 1e-7;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char S[100];
    string A="Yes";
    for(int i=0;i<100;i++){
        cin >>S[i];
    }
    for(int j=0;j<50;j++){
        if(S[2*j]=='L'){
            A="No";
            break;
        }
       
        if(S[2*j+1]=='R'){
            A="No";
            break;
        } 
    }
    cout<<A;
    
}


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

using namespace std;

using ll = long long int;
using ld = long 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 vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

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

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	for (int i = n; i >= 0; i--) {
		int a = (int)sqrt((double)i);

		if (a * a == i) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var answers[]string

	for i:= 0; i != -1; i++ {
		fmt.Scan(&n)
		if n == 0 {
			break
		}
		answers = append(answers, "Case " + strconv.Itoa(i+1) + ": " + strconv.Itoa(n))
	}

	for _, answer :=  range answers {
		fmt.Println(answer)
	}
}


Measured memory_bytes: 2836
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl
int p;
int MOD;

int BE(int b,int e){
    int r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

map<int,int> inv_memo;
int inv(int b){
    if(inv_memo[b]==0){
        inv_memo[b]=BE(b,MOD-2);
    }
    return inv_memo[b];
}

signed main(void){
    int A[3141];
    cin >> p;
    MOD=p;
    REP(i,p){
        cin >> A[i];
    }
    //Q_i:=A_i/Π[k!=i](x_i - x_k)
    //R(x) :=Π[k](x - x_k)
    //then P(x) = Σ[i=0~p-1](Q_i*R(x)/x-x_i)
    //Answer[] = coefficients of P(x)
    
    int P[3141]={},Q[3141]={};
    int R[3141]={},Rt[3141]={},Rh[3141]={};
    
    //下ごしらえ
    //Q_iは初期値をA_iとし、i以外のkについてinv(x_i - x_k)をかけておく
    //今回はx_i=iなので、そうする
    //この処理はΟ(p^2+log(p))
    
    REP(i,p){
        Q[i]=A[i];
    }
    REP(i,p){
        REP(k,p){
            if(i==k)continue;
            Q[i]=(Q[i]*inv((i-k+MOD)%MOD))%MOD;
        }
    }
    
    //R(x)は二項係数を使えば求まるかもしれない(超適当)けど今回は愚直に行く
    //最初はR(x)=1なのでR[0]=1を入れておく
    //この処理はΟ(p^2)
    
    R[0]=1;
    REP(j,p){
        REP(i,p){
            Rt[i]=R[i];
            R[i]=0;
        }
        REP(i,j+2){
            if(i==0){
                R[0]=(-(Rt[0]*j)%MOD+MOD)%MOD;//jはx_j
            }else{
                R[i]=(Rt[i-1]-((Rt[i]*j)%MOD) + MOD)%MOD;
            }
        }
    }
    
    //本調理
    //まずR(x)/(x-x_i)を計算し、終わったらQ_iを掛けてPに足しておく
    //これをp回繰り返して最後に出来たPが答え
    //この処理はΟ(p^2)
    
    REP(j,p){
        REP(i,p+1){
            Rh[i]=0;
        }
        RREP(i,p){
            if(i==p-1){
                Rh[p-1]=R[p];
            }else{
                Rh[i]=(R[i+1]+(Rh[i+1]*j)%MOD)%MOD;
            }
        }
        REP(i,p){
            P[i]=(P[i]+((Q[j]*Rh[i])%MOD))%MOD;
        }
    }
    
    //Pを出力して完成
    
    REP(i,p){
        cout << P[i] << " ";
    }cout << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

using EdgeList = vector<vector<int>>;

// ?????£?????????????????°?????? E ????????£????????????????§£
// O(N + M) N: ????????°, M: ?????°
vector<vector<int>> strongly_connected_components(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    stack<int> stk;
    vector<bool> on_stack(N);
    vector<vector<int>> scc;    
    function<void(int, int)> dfs = [&] (int now, int pre) {
        stk.push(now);
        on_stack[now] = true;
        ord[now] = cnt++;
        low[now] = ord[now];
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
            } else if(on_stack[nxt]) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
        if(ord[now] == low[now]) {
            scc.push_back({});
            while(true) {
                int v = stk.top(); stk.pop();
                scc.back().push_back(v);
                on_stack[v] = false;
                if(v == now) break;
            }
        }
    };
    // ??£?????°????????????dfs(0)????????§OK?????????
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return scc;
}

#define all(v) v.begin(),v.end()

struct UnionFind{
    int n;
    vector<int> p;
    UnionFind(int nn):n(nn) {
        p.resize(n);
        rep(i, n) p[i] = i;
    }
    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }
    void unite(int x,int y) {
        x = root(x); y = root(y);
        if(x != y) p[y] = x;
    }
    bool query(int x,int y){
        return root(x) == root(y);
    }
};

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        EdgeList E(N);
        rep(i, M) {
            int a, b; cin >> a >> b;
            E[a].push_back(b);
        }
        auto scc = strongly_connected_components(E);
        
        UnionFind uf(N);
        for(auto &group : scc) for(int v : group) uf.unite(group.front(), v);

        int Q; cin >> Q;

        rep(i, Q) {
            int u, v; cin >> u >> v;
            cout << uf.query(u, v) << endl;
        }
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

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

int mod = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<long long> dp(n + 2, 0);
    dp[0] = 1;
    vector<bool> warning(n + 2, 1);
    int x;
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        warning[x] = false;
    }
    for (int i = 0; i < n; i++)
    {
        if (warning[i]){
            dp[i + 1] += dp[i];
            dp[i + 2] += dp[i];
            dp[i + 1] %= mod;
            dp[i + 2] %= mod;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    s1 = S()
    s2 = S()
    r = 6
    i = 2
    c = 2
    if s1[0] == s2[0]:
        r = 3
        i = 1
        c = 1
    while i < n:
        if s1[i] == s2[i]:
            if c == 1:
                r *= 2
            else:
                pass
            c = 1
            i += 1
        else:
            if c == 1:
                r *= 2
            else:
                r *= 3
            c = 2
            i += 2
        r %= mod

    return r

print(main())



Measured memory_bytes: 6736
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[4];

int main(){

	scanf("%s",buf);

	switch(buf[0]){
	case 'S':
		if(buf[1] == 'U'){

			printf("7\n");
		}else{

			printf("1\n");
		}
		break;
	case 'M':
		printf("6\n");
		break;
	case 'T':
		if(buf[1] == 'U'){

			printf("5\n");

		}else{

			printf("3\n");
		}
		break;
	case 'F':
		printf("2\n");
		break;
	case 'W':
		printf("4\n");
		break;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    double res = 0;
    
    for (int i = 1; i <= N; ++i) {
        double div = 1. * K / i;
        int n = div - EPS <= 1. ? 0. : ceil(log2(div));
        res += 1. / N * pow(1. / 2, n);
    }

    cout << setprecision(15) << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105],k,head=99;
void change(){
	int j=101;
	for(int k=j-1;k>=head+1;k--){
		if(a[k]!=a[k-1]+1&&a[k]!=9){
			j=k; break;
		}
	}
	if(j!=101){
		a[j]++;
		for(int k=j+1;k<=100;k++){
			if(a[k-1]-1>=0)
			    a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	else{
		if(a[head]!=9){
		    a[head]++;
		    for(int k=head+1;k<=100;k++){
			    if(a[k-1]-1>=0)
			        a[k]=a[k-1]-1;
			    else a[k]=a[k-1];
		    }
		    return;
	    }
	    else{
	    	head--;
		    a[head]=1;
		    for(int k=head+1;k<=100;k++)
		        a[k]=0;
		}
	}
}
int main(){
	cin>>k;
	if(k<=9){
		cout<<k<<endl;
		return 0;
	}
	k-=10;
	a[99]=1;
	a[100]=0;
	for (int i=1;i<=k;i++)
	    change();
	for (int i=head;i<=100;i++)
	    cout<<a[i];
	return 0; 
}

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

int main() {
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<3;i++){
		if(s[i]=='R'){
			cnt++;
		}
	}
	if(cnt==1){
		cout <<1;
		return 0;
	}
	if(cnt==0){
		cout <<0;
		return 0;
	}
	if(cnt==3){
		cout << 3;
		return 0;
	}
	if(s[1]!='R'){
		cout << 1;
	}
	else{
		cout << 2;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int a = s.nextInt();
	int b = s.nextInt();
	int c = s.nextInt();
	int count = 0;

	for(int i = a; i <= b; i++){
	    if(c % i == 0) count++;
	}
	System.out.println(count);
    }
}



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

int main() {
  int N, c;
  c = 1;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  string s;
  s = S.at(0);
  for(int i = 0; i < N; i++) {
    if(s != S.at(i)) {
      s = S.at(i);
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 9548
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>

using namespace std; 
#define Endl '\n'
int main()
{
    float n;
    cin>>n;
    n=3.14*n*2;
    printf("%.2f\n",n );
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>k>>n;
    vl v(n),d;
    fo(i,n)cin>>v[i];
    sort(all(v));
    fo(i,n-1)d.pb(v[i+1]-v[i]);
    sort(all(d));
    for(int i=0;i<n-k;i++)kv+=d[i];
    cout<<kv;
    return 0;
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		double n = sc.nextDouble();
		double answer = n/1.08;
		//System.out.println((int)answer);
		double check = (int)answer*1.08;
		//System.out.println(check);
		if(n==(int)check)
			System.out.println((int)answer);
		else {
			answer = (int)answer+1;
			check = (int)answer*1.08;
			if(n==(int)check)
				System.out.println((int)answer);
			else
				System.out.println(":(");
		}
	}
}

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

int main() {
    ll N, D;
    cin >> N >> D;
    D *= D;
    vector<ll> X(N), Y(N);
    for (ll i=0; i<N; i++) {
        cin >> X[i] >> Y[i];
        X[i] *= X[i];
        Y[i] *= Y[i];
    }
    ll count = 0;
    for (ll i=0; i<N; i++) {
        ll d = X[i] + Y[i];
        if (d <= D) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 6368