akhauriyash/Code-Regression huggingface dataset:
while True:
    temp = []
    str = list(input())
    #print(str)
    if str[0] == "-":
        break

    m = int(input())
    for i in range(m):
        h = int(input())

        for j in range(h):
            temp.append(str.pop(0))

        for j in range(h):
            str.append(temp[j])

        temp.clear()
    print(''.join(str))


Measured memory_bytes: 5596
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    i64 n, m;
    scanf("%lld %lld", &n, &m);

    if (n == 1 && m == 1)
        printf("%lld\n", 1);
    else if (n == 1 || m == 1)
        printf("%lld\n", max(n, m) - 2);
    else
        printf("%lld\n", (n - 2) * (m - 2));
    return 0;
}

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

int main(){
  double a,b,h,m,dif;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  dif=M_PI*(m/30-(h*60+m)/360);
  printf("%.10lf",sqrt(a*a+b*b-a*b*cos(dif)*2));
  return(0);
}

Measured memory_bytes: 2564
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef unsigned int uii;
const int maxn=3005;
int n,a[maxn],u,v,sg[maxn];
vector<int> vec[maxn];
void dfs(int u) {
    sg[u]=0;
    for (uii i=0;i<vec[u].size();++i) {
        int v=vec[u][i];
        if (sg[v]!=-1)
            continue;
        dfs(v);
        if (a[u]>a[v]&&sg[v]==0) {
            sg[u]=1;
            break;
        }
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%d",&a[i]);
    for (int i=0;i<n-1;++i) {
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    for (int i=1;i<=n;++i) {
        memset(sg,-1,sizeof sg);
        dfs(i);
        if (sg[i])
            printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 512
s = raw_input()

s_long = len(s)
first_a_adress = -1
end_z_adress = -1
for var in range(0,s_long):
	if s[var] == 'A':
		first_a_adress = var
		break
				
for var in reversed(range(0,s_long)):
	if s[var] == 'Z':
		end_z_adress = var
		break
print end_z_adress - first_a_adress + 1

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  if(A+K-1>=B-K+1){
    for(int i=A; i<=B; i++) cout << i << endl;
  }
  else{
    for(int i=A; i<=A+K-1; i++) cout << i << endl;
    for(int i=B-K+1; i<=B; i++) cout << i << endl;
  }
}

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

typedef long long unsigned ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

//map<int,int> mmap;
int n,m,ret=0;
int cot[8][8];
int vis[10];
// n,r
void dfs(int v,int e_ct){
    if(e_ct==n-1){
        int tmp =0;
        for(int i=0;i<n;i++)
            tmp+=vis[i];
        if(tmp==n) ret++;
        return;
    }


    for(int i=0;i<n;i++){
        if(!vis[i] && cot[v][i]){
            vis[i]=1;
            //cout<< v<<" " <<i<< " "<<e_ct+1<<endl;
            dfs(i,e_ct+1);
            vis[i]=0;
        }
    }

}

int main(){

    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++){
            cin>>a>>b;
            a--;b--;
            cot[a][b]=1;
            cot[b][a]=1;
    }
    vis[0]=1;
    dfs(0,0);
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    
    long long int N,X,*L;
    long long int i,j;
    long long int stackcount=0;
    long long int count=0;
    long long int dist=0;
    char str[45000];
    scanf("%lld %lld",&N,&X);
    L=(long long int *)malloc(sizeof(long long int)*(N+1));
    (void)getchar();
    for (i=0;i<45000;i++){
        str[i]='\0';
    }
    for (i=0;i<N;i++){
        L[i]=0;
    }
    scanf("%[^\n]",str);
    //printf("%d %d\n",N,X);
    for (i=0;i<45000;i++){
        if((str[i]!=' ')&&(str[i]!='\0')){
            count++;
        }
        else{
            for(j=0;j<count;j++){
                L[stackcount]+=(str[i-j-1]-48)*pow(10,j);
            }
            stackcount++;
            count=0;
        }
        if(str[i]=='\0') break;
    }                           //ここまでで入力完了
    count=0;
    for (i=0;i<N;i++){
        if (dist<=X){
            count++;
            dist+=L[i];
            if ((i==N-1)&&(dist<=X)){
                count++;
            }
        }
        else{
            break;
        }
    }
    printf("%lld\n",count);

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for (int i = 0; i < n; i++) {
            if (s[i].equals("AC")) {
                ac++;
            } else if (s[i].equals("WA")) {
                wa++;
            } else if (s[i].equals("TLE")) {
                tle++;
            } else if (s[i].equals("RE")) {
                re++;
            }
        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }
}


Measured memory_bytes: 64336
/*
    Code by CNH_Tourist
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*----------------Define----------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const int mod=1e9+7;
int test=1;
/*--------------------------------------*/

int n;
int a[100100];
int dp[100100];

int main()
{
    FAST
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dp[n];
}



Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}
struct edge { int to, cost; };


int main() {
	int n;
	cin >> n;
	hei(int) cost(n - 1), start(n - 1), f(n - 1);
	rep(i, 0, n - 1) {
		cin >> cost[i] >> start[i] >> f[i];
		start[i] /= f[i];
	}
	rep(i, 0, n) {
		int x = 0;
		rep(j, i, n-1) {
			int s = x;
			if (s <= start[j]*f[j])x = cost[j] + start[j]*f[j];
			else {
				int m = ((x + f[j] - 1) / f[j]) * f[j];
				x = m + cost[j];
			}
		}
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *  @author: pr4shan7 (प्रशांत)
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

// #define _DEBUG

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifdef _DEBUG
  ifstream cin("input.txt");
  // ofstream cout("output.txt");
#endif

  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);

  // int* st = ar;
  unsigned long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int* x = lower_bound(ar, ar + n, ar[i] + ar[j]);
      // if (ar[i] + ar[j] > ar[n - 1]) x = ar + n;
      int* st = max(upper_bound(ar, ar + n, max(ar[i], ar[j]) - min(ar[i], ar[j])), ar + j + 1);
      if (x - st > 0)
        sum += x - st;
      // if (*x != ar[i] + ar[j]) sum++;

      // cout << *x << ' ' << *st << ' ' << ar[i] << ' ' << ar[j] << ' ' << sum << '\n';
    }
  }

  cout << sum << '\n';
  // cout << ar[1] << '\n';
  // cout << lower_bound(ar, ar + 4, 3) - st << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int LCSRe[n+1][n+1];


    memset(LCSRe, 0, sizeof(LCSRe));

    string res;
    int res_length  = 0;

    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1] == str[j-1] &&
                LCSRe[i-1][j-1] < (j - i))
            {
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1;


                if (LCSRe[i][j] > res_length)
                {
                    res_length = LCSRe[i][j];
                    index = max(i, index);
                }
            }
            else
                LCSRe[i][j] = 0;
        }
    }

    if (res_length > 0)
        for (i = index - res_length + 1; i <= index; i++)
            res.push_back(str[i-1]);

    return res;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << longestRepeatedSubstring(s).length();

    return 0;
}



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

int main(){
    int n, tmp, min, max;
    long long sum;

    cin >> n;

    min = 1000000;
    max = -1000000;
    sum = 0;

    for (int i = 1; i <= n; i++){
        cin >> tmp;
        if (tmp < min) min = tmp;
        if (max < tmp) max = tmp;
        sum = sum + tmp;
    }

    cout << min << " " << max << " " << sum << endl;

}



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

int balls[10];

bool dfs(int idx, int b, int c){
	if(idx > 9) return true;
	
	bool ok = false;
	if(b < balls[idx]){
		ok = dfs(idx+1, balls[idx], c);
	}
	if(c < balls[idx]){
		ok = dfs(idx+1, b, balls[idx]);
	}
	return ok;
}

int main() {
	int n; cin >> n;
    while(n--){
        for(int i = 0; i < 10; i++){
            cin >> balls[i];
        }
         
        if(dfs(0, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll K;
    cin >> K;

    ll even = K / 2;
    ll odd = (K + 1) / 2;
       
    cout << even * odd << endl;

    return 0;
}

Measured memory_bytes: 3524
using System;

namespace abc110_a_2_
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int[] inputs = new int[array.Length];
            for(int i = 0; i < array.Length; i++)
            {
                inputs[i] = int.Parse(array[i]);
            }
            Array.Sort(inputs);

            Console.WriteLine(inputs[2] *10+ inputs[1] + inputs[0]);
        }
    }
}


Measured memory_bytes: 11092
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()

alpha = defaultdict(str)
for i in range(26):
    alpha[i] = chr(ord('a')+i)

# p桁でi+1番目に大きい
def calc(p,i):
    p -= 1
    ans = []
    while p >= 0:
        d = i//(26**p)
        ans.append(alpha[d])
        i -= (26**p)*d
        p -= 1
    return ''.join(ans)

c = 1
n = 0
while True:
    n += 26**c
    if n >= N:
        break
    else:
        c += 1

sum_ = 0
for i in range(1,c):
    sum_ += 26**i

print(calc(c,N-sum_-1))

Measured memory_bytes: 65664
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}



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

using namespace std;

int main() {
  string s;
  cin >> s;
  
  bool is_easy = true;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0 && s[i] == 'L') is_easy = false;
    if (i % 2 != 0 && s[i] == 'R') is_easy = false;
  }
  if (!is_easy) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    int cost[10][10];
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> cost[i][j];
        }
    }
    int cnt[10]={};
    for(int i = 0; i < h*w; i++) {
        int tmp;
        cin >> tmp;
        if(tmp==-1) continue;
        else cnt[tmp]++;
    }

    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                cost[i][j] = min(cost[i][j],(cost[i][k]+cost[k][j]));
            }
        }
    }

    int ans=0;
    for(int i = 0; i < 10; i++) {
        ans+=cnt[i]*cost[i][1];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	return scanInt(sc)
}

func resolve(n int) string {
	for i := 1; i < 10; i++ {
		if div := n / i; n%i == 0 && div < 10 {
			return "Yes"
		}
	}
	return "No"
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=510;
int bit[maxn];
int n,m,q,ans[100010];
vector<int> train[maxn];
vector<pii> qry[maxn];
inline int lowbit(int x){
	return x&-x;
}
inline void modify(int pos,int add){
	for(int i=pos;i<=n;i+=lowbit(i))
		bit[i]+=add;
}
inline int query(int pos){
	int res=0;
	for(int i=pos;i;i-=lowbit(i))
		res+=bit[i];
	return res;
}
inline int get_sum(int l,int r){
	return query(r)-query(l-1);
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	int l,r;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&l,&r);
		train[l].push_back(r);
	}
	for(int i=1;i<=q;i++){
		scanf("%d%d",&l,&r);
		qry[l].push_back(pii(r,i));
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<(int)train[i].size();j++)
			modify(train[i][j],1);
		for(int j=0;j<(int)qry[i].size();j++)
			ans[qry[i][j].second]=get_sum(i,qry[i][j].first);
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3584
(n, y) = map(int, input().split())


for i in range(n + 1):
    for j in range(n + 1 - i):
        sum = 10000 * i + 5000 * j + (n - i - j) * 1000
        if y == sum:
            print("{} {} {}".format(i, j, n - i - j))
            exit(0)
print("-1 -1 -1")


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }
    val ans = IntArray(n)
    ans[0] = xs.mapIndexed { i, x -> if (i % 2 == 0) x else -x }.sum() / 2
    for (i in 1 until n) {
        ans[i] = xs[i - 1] - ans[i - 1]
    }
    println(ans.map { it * 2 }.joinToString(" "))
}


Measured memory_bytes: 67476
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


void func() {
  LD N;
  cin >> N;
    
  LD A = ceil(N / 2) / N;
  cout << A;


}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	int ans = MOD;
	rep(i, n - k + 1) {
		ans = min(h[i + k - 1] - h[i], ans);
	}
	cout << ans<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  int n= s.size();
  bool ok = true;
  rep(i,n){
    if(s[i] != s[n-1-i]) ok = false;
  }
  rep(i,(n-1)/2){
    if(s[i] != s[(n-1)/2-1-i]) ok = false;
  }
  for(int i= (n+3)/2; i<n;i++){
    if(s[i] != s[n-1-i]) ok = false;
  }
  if(!ok) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
from fractions import gcd

N = int(input())
A_List = list(map(int,input().split()))

LCM = 1

for i in A_List:
    LCM = LCM * i // gcd(LCM, i)

ans = 0

for i in A_List:
    ans += LCM // i

print(ans%(10**9+7))

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

struct Unionfind {
	vector<int>p;
	Unionfind(int n) {
		p.resize(n, -1);
	}

	int find(int x) {
		if (p[x-1] == -1)return x;
		else return p[x-1] = find(p[x-1]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		p[x-1] = y;
	
	
	}
};


int main() {
	int n, m, x, y;
	cin >> n >> m;
	Unionfind uf(n);

	
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		uf.unite(x, y);
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (uf.p.at(i) == -1)count++;
	}
	cout << count - 1 << endl;
}





Measured memory_bytes: 3768
N = int(input())
S = input()
whsum = [0]*(N+1)
blsum = [0]*(N+1)
for i in range(N):
    whsum[i+1] = whsum[i]+(1 if S[i]=="." else 0)
    blsum[i+1] = blsum[i]+(1 if S[i]=="#" else 0)
res = 10**6
for left in range(N+1):
    tmp = 0
    tmp += blsum[left]-blsum[0]
    tmp += whsum[N]-whsum[left]
    res = min(res,tmp)
print(res)

Measured memory_bytes: 19108
n, d = map(int, input().split())
x_array = [[int(x) for x in input().split()] for y in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if i == j:
            continue
        tmp_i = x_array[i]
        tmp_j = x_array[j]
        tmp = sum([abs(x-y)**2 for x, y in zip(tmp_i, tmp_j)])
        if tmp ** 0.5 %1 == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    string start;
    string p, q;
    int tmp;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        p.push_back('0' + tmp);
        start.push_back('1' + i);
    }
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        q.push_back('0' + tmp);
    }
    int a, b;
    int count = 0;
    do {
        count++;
        if(start == p) a = count;
        if(start == q) b = count;
    } while(next_permutation(start.begin(), start.end()));
    cout << abs(a - b) << endl;
    return 0;
}

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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

 
int main()
{
     string s;
     cin>>s;
     string ans="";
     for(int i=0;i<3;i++)
     {
          ans+=s[i];
     }
     cout<<ans;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> vec;
  bool ok=false;
  while (n--){
    int x, y;
    cin>>x>>y;
    if (x==y) vec.push_back(1);
    else vec.push_back(0);
  }
  int curr=0;
  for (int i=0; i<vec.size(); i++){
    if (vec[i]==1){
      curr++;
    }
    else{
      if (curr>=3){
        ok=true;
        break;
      }
      curr=0;
    }
  }
  if (curr>=3) ok=true;
  if (ok==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
	IoSetup() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
		cerr << fixed << setprecision(10);
	}
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}



signed main() {

	int n, m, k;

	cin >> n >> m >> k;

	vector<int> a(n), b(m);

	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}

	int l = 0, j = 0;
	ll sum = 0;

	while(l < n and sum + a[l] <= k) {
		sum += a[l];
		++l;
	}
	while(j < m and sum + b[j] <= k) {
		sum += b[j];
		++j;
	}
	int max_c = l + j;
	while(l > 0) {
		sum -= a[l - 1];
		l--;
		while(j < m and sum + b[j] <= k) {
			sum += b[j];
			++j;
		}
		chmax(max_c, l + j);
	}

	cout << max_c << endl;
	
	return 0;
}


Measured memory_bytes: 4788
var s:String;i:Longint;a:array[97..122]of boolean;
begin
	setlength(s,100000);
	readln(s);
	for i:=1 to length(s) do begin
		a[ord(s[i])]:=true;
	end;
	for i:=97 to 122 do begin
		if not a[i] then begin
			writeln(chr(i));
			exit;
		end;
	end;
	writeln('None');
end.


Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val S = Array(N){ readLine()!! }

    val map = mutableMapOf<String, Long>()
    S.forEach { s ->
        val a = IntArray(26)
        s.forEach { c ->
            a[c - 'a']++
        }
        val key = a.joinToString(separator = "")
        map[key] = (map[key] ?: 0) + 1
    }

    var ans = 0L
    for(v in map.values){
        ans += v * (v - 1) / 2
    }
    println(ans)
}

Measured memory_bytes: 103916
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int y,m,d;
    scanf("%d/%d/%d",&y,&m,&d);
    if(m<=4)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

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

int main()
{
    std::string s;
    std::cin >> s;
    std::map<char,int> map;
    for(int i = 0; i < (int)s.size(); i++){
        map[s[i]]++;
    }
    bool res = true;
    for(auto i : map)if(i.second & 1)res = false;
    std::cout << (res ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
import re


def main(text):
    hash = {}
    keys = 'abcdefghijklmnopqrstuvwxyz'
    for k in keys:
        hash[k] = 0
    for char in re.findall('[a-zA-Z]', text):
        hash[char.lower()] += 1
    return list(map(lambda k: '{} : {}'.format(k, hash[k]), keys))


if __name__ == "__main__":
    text = ''
    while True:
        try:
            input_str = str(input())
        except EOFError:
            break
        text += input_str
    results = main(text)
    print('\n'.join(results))



Measured memory_bytes: 6516
#include<stdio.h>
int main(void){
int n,x,i,r,t;
int kekka=0;
while(1){
scanf("%d %d",&n,&x);
if(n==0&&x==0){break;}
else{
for(i=1;i<=n;i++){
for(r=i+1;r<=n;r++){
for(t=r+1;t<=n;t++){
if(i+r+t==x){kekka+=1;break;}
}
}
}
printf("%d\n",kekka);
kekka=0;
}
}
return 0;
}

Measured memory_bytes: 600
#include <iostream>

 using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i % 3600/60;
   s = i % 3600 % 60;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>

int main(void)
{
	int n, pm, pe, pj;
	char m[10000];
	int i;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100){
				m[i] = 'A';
			}
			else if ((pm + pe) / 2 >= 90){
				m[i] = 'A';
			}
			else if ((pm + pe + pj) / 3 >= 80){
				m[i] = 'A';
			}
			else if ((pm + pe + pj) / 3 >= 70){
				m[i] = 'B';
			}
			else if ((pm + pe + pj) / 3 >= 50 && pm >= 80 || pe >= 80){
				m[i] = 'B';
			}
			else {
				m[i] = 'C';
			}
		}
		for (i = 0; i < n; i++){
			printf("%c\n", m[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <tuple> 
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll, ll, ll> T;

int main(){
	ll X, Y, Z;
	cin >> X >> Y >> Z;
	vector<string> v;
	for(int i=0;i<X;i++)
		v.push_back("a");
	for(int i=0;i<Y;i++)
		v.push_back("b");
	for(int i=0;i<Z;i++)
		v.push_back("c");
	while(v.size()>1){
		v[0] = v[0] + v.back();
		v.pop_back();
		sort(v.begin(), v.end());
	}
	cout << v[0] << endl;
	return 0;
}

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

int main(){
	string str;
	int n;
	string command;
	int a, b;
	string rep;

	cin >> str >> n;

	for(int i = 0; i < n; i++){
		cin >> command >> a >> b;
		if(command.find("replace") != string::npos)
		{
			cin >> rep;
			str =str.substr(0, a) + rep + str.substr(b+1, str.length() - b - 1);
		}
		else if(command.find("reverse") != string::npos)
		{
			for(int j = 0; j < (b-a + 1)/2; j++){
				swap(str[a+j], str[b-j]);
			}
		}
		else if(command.find("print") != string::npos)
		{
			cout << str.substr(a,b - a + 1) << endl;;
		}
		//cout << endl <<  str << ":" << i << endl;
	}
	return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	string s;
	cin>>s;
	vector<ll> v(3,0);
	ll maxi=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R') v[i]=1;
		if(i>0&&s[i]=='R'&&s[i-1]=='R') v[i]+=v[i-1];
		maxi=max(maxi,v[i]);
	}
	cout<<maxi<<endl;
}

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

using namespace std;

int n,l;


int main()
{
    cin>>n>>l;
    vector<string> a;
    for(int i=0;i<n;i++)
    {
        string s; cin>>s;
        a.push_back(s);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++) cout<<a[i];
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let x: usize = sc.read();
    let y: usize = sc.read();
    println!("{}", x + y / 2);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
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
INF = float("inf")
 
 
def main():
    N = int(input())
    ans = 0
    for i in range(10**9):
        if i * i <= N:
            ans = max(ans, i * i)
        else:
            break
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[][] t=new int[n][3];
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
t[i][j]=sc.nextInt();
}
if(triangle(i,t)){System.out.println("YES");}
else{System.out.println("NO");}
}
}
public static boolean triangle(int i,int[][] t){
double max=Math.max(Math.max(t[i][0],t[i][1]),t[i][2]);
double res=Math.min(Math.min(Math.hypot(t[i][0],t[i][1]),Math.hypot(t[i][0],t[i][2])),Math.hypot(t[i][2],t[i][1]));
if(res==max){return true;}
else{return false;}
}
}

Measured memory_bytes: 21604
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n,p;

while(cin>>p){
i=0; j=p;
while(p>0){
    i+=(p%10);
    p/=10;
}
if(j%i==0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
} return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, m;
	cin >> n >> m;
	vi c(m);
	rep(i, m) cin >> c[i];
	vector<vi> dp(m+1, vi(n+1, INF));
	for(int i = 0; i <= m; i++) dp[i][0] = 0;

	for(int i = 1; i <= m; i++) {
		for(int j = 0; j <= n; j++) {
			dp[i][j] = dp[i-1][j];
			if(j - c[i-1] >= 0) dp[i][j] = min(dp[i][j-c[i-1]] + 1, dp[i-1][j]);
		}
	}
	cout << dp[m][n] << endl;
}



Measured memory_bytes: 7088
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()
D2 = np.array(D)
answer = 0
for d in D:
    answer += (d * D2).sum() - (d ** 2)

print(answer // 2)


Measured memory_bytes: 12488
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

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

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

    int n;cin>>n;
    cout<<n/3<<endl;
}


Measured memory_bytes: 256
/**
*    created: 23.06.2020 23:57:58
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

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

    int x;
    cin >> x;
    int ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N%2==0) {
        auto b = S.substr(0, N/2);
        auto a = S.substr(N/2);
        if (a == b) {
            print("Yes");
        } else {
            print("No");
        }
    } else {
        print("No");
    }
}

int main()
{
    solve();

    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;
  
  vector<ll> sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  vector<ll> sub;
  rep(i,n){
    for(ll j=i;j<n;++j){
      sub.emplace_back(sum[j+1]-sum[i]);
    }
  }

  auto f = [&](ll a)->bool{
    ll cnt=0;
    for(const auto& x:sub){
      if((x&a)==a)cnt++;
    }
    return cnt>=k;
  };

  ll ans=0;
  for(ll i=45;i>=0;--i){
    if( f(ans|(1LL<<i)) ){
      ans|=(1LL<<i);
    }
  }
  cout<<(ans)<<endl;


}


Measured memory_bytes: 6384
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}else{
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import sys
input = lambda: sys.stdin.readline().rstrip()
import math

A, B, H, M = map(int, input().split())

cos = math.cos(math.radians(6 * M - 0.5 * (H * 60 + M)))

ans = A ** 2 + B ** 2 - 2 * A * B * (cos)
print(ans ** 0.5)

Measured memory_bytes: 62472
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int> p(N, 0);

	for (int i = 0; i < Q; ++i) {
		int A;
		cin >> A;
		--A;
		++p[A];
	}

	for (int i = 0; i < N; ++i) {
		p[i] += K - Q;
		if (p[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b[10000000],c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ss;
bool Sfl=false;

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

        cin>>n>>s>>ss;
        rep(i,n){
                if(s[i]==ss[i]){
                        a[cnt]=0;
                        cnt++;
                }
                else{
                        a[cnt]=1;
                        cnt++;
                        i++;
                }
        }
        if(a[0]==0){
                ans=3;
        }
        else{
                ans=6;
        }
        rrep(i,1,cnt){
                if(a[i]==0){
                        if(a[i-1]==0){
                               ans*=2; 
                        }
                }
                else{
                        if(a[i-1]==0){
                                ans*=2;
                        }
                        else{
                                ans*=3;
                        }
                }
                ans%=MOD;
        }
        Cout(ans);
return 0;
}


Measured memory_bytes: 2304
N,K=map(int,input().split())
dp=[0]*(N)
dp[0]=1
mod=998244353
L=list()
for i in range(K):
  a,b=map(int,input().split())
  L.append([a,b])
R=[0,1]
for i in range(1,N):
  for j in range(K):
    a,b=L[j]
    if i>=b:
      dp[i]+=R[i-a+1]-R[i-b]
    elif i>=a:
      dp[i]+=R[i-a+1]
    dp[i]%=mod
  R.append(R[-1]+dp[i])
print(dp[-1])

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

const int MAX = 1e4 + 100;
const int MOD = 1e9 + 7;

int dp[MAX][2][105];
string s;
int d;

inline int add(int a, int b)
{
	int r = a + b;
	if(r >= MOD)
		r -= MOD;
	return r;
}

inline int sub(int a, int b)
{
	int r = a - b;
	if(r < 0)
		r += MOD;
	return r;
}

int dp_solve(int idx, bool lim, int mod)
{
	if(idx == (int) s.size())
		return (int) mod == 0;

	int &ans = dp[idx][lim][mod];
	if(~ans) return ans;
	ans = 0;
	int limit = lim ? 9 : s[idx] - '0';
	for(int i = 0; i <= limit; i++)
		ans = add(ans, dp_solve(idx+1, lim || i < s[idx] - '0', (mod + i) % d));
	return ans;
}

int main()
{
	cin >> s >> d;
	memset(dp, -1, sizeof dp);
	cout << sub(dp_solve(0, 0, 0), 1) << endl;

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int P[N];
    int ans = 0;
    int maxval = N + 10;
    for (int i = 0; i < N; ++i){
        cin >> P[i];
    }
    
    for (int i = 0; i < N; ++i){
        if (P[i] < maxval) {
            maxval = P[i];
            ans += 1;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) {
        cout << "bust\n";
    } else {
        cout << "win\n";
    }
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    double a, b;
    a = stdInt.nextDouble();
    b = stdInt.nextDouble();

  if (a > b) {
    System.out.println("a > b");
  } else if (a < b) {
    System.out.println("a < b");
  } else {
    System.out.println("a == b");
  }

  }
}


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

using namespace std;
using ll = long long;

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

  int h, w, m;
  cin >> h >> w >> m;
  vector<int> cnth(h);
  vector<int> cntw(w);
  set<pair<int, int>> s;
  for (int i = 0; i < m; i++) {
    int hh, ww;
    cin >> hh >> ww;
    hh--;
    ww--;
    s.insert({hh, ww});
    cnth[hh]++;
    cntw[ww]++;
  }

  vector<int> hi;
  vector<int> wi;
  int maxh = *max_element(cnth.begin(), cnth.end());
  int maxw = *max_element(cntw.begin(), cntw.end());
  for (int i = 0; i < h; i++) {
    if (cnth[i] == maxh)
      hi.push_back(i);
  }
  for (int i = 0; i < w; i++) {
    if (cntw[i] == maxw)
      wi.push_back(i);
  }

  for (auto i : hi) {
    for (auto j : wi) {
      if (s.count({i, j}) == 0) {
        cout << maxh + maxw << endl;
        return 0;
      }
    }
  }
  cout << maxh + maxw - 1 << endl;

  return 0;
}


Measured memory_bytes: 23780
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int A, B;

	scanf("%d %d", &A, &B);

	if (A <= 8 && B <= 8) {
		printf("Yay!\n");
	}
	else {
		printf(":(\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  int A[N];
  int x[N][N-1];
  int y[N][N-1];
  rep(i,N) {
    cin >> A[i];
    rep(j,A[i]) cin >> x[i][j] >> y[i][j];
  }

  int ans = 0;
  for(int bit = 1; bit < (1<<N); bit++) {
    bool ok = true;
    rep(i,N) {
      if (((bit >> i) & 1)) {
        rep(j,A[i]) {
          if (((bit >> (x[i][j]-1)) & 1) != y[i][j]) {
            ok = false;
            break;
          }
        }
        if (!ok) break;
      }
    }
    if (ok) {
      int hnum = 0;
      rep(i,N) {
        if (((bit >> i) & 1)) hnum++;
      }
      ans = max(ans, hnum);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s[100];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		cin>>s[i];
	int sum=1e9+1;
	for(int mask=0;mask<(1<<(n-1));mask++)
	{
		int cnt,t;
		cnt=__builtin_popcount(mask);
		t=cnt;
		vector<int>v(cnt+1,0);
		for(int j=0;j<m;j++)
		{
			int x=0;
			for(int i=0;i<n;i++)
			{
				v[x]+=(s[i][j]=='1');
				if((mask>>i)&1)
					x++;
			}
			bool ok=false;
			for(int i=0;i<v.size();i++)
			{
				if(v[i]>k)
					ok=true;
			}
			if(ok)
			{
				t++;
				fill(v.begin(),v.end(),0);
				int x=0;
				for(int i=0;i<n;i++)
				{
					v[x]+=(s[i][j]=='1');
					if((mask>>i)&1)
						x++;
				} 
				bool ok=false;
				for(int i=0;i<v.size();i++)
				{
					if(v[i]>k)
						ok=true;
				}
				if(ok)
					t=1e9+1;
			}
		}
		if(t<sum)
			sum=t;
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 256