akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    while(cin >> s) {
        stack<char> st;
        for(auto c : s) {
            if(st.empty() || c == 'S' || (c == 'T' && st.top() == 'T')) {
                st.push(c);
            } else {
                st.pop();
            }
        }
        cout << st.size() << '\n';
    }
    return 0;
}

Measured memory_bytes: 720
n, a, b = gets.strip.split.map(&:to_i)
v = gets.strip.split.map(&:to_i).sort.reverse

medians = v.take(a)
result_median = (medians.inject(:+)/medians.length.to_f)

@factorial_memo=[1,1]

def memo_factor(n, r)
  (@factorial_memo[n]/(@factorial_memo[r] * @factorial_memo[n-r]))
end

(2..50).each do |i|
  @factorial_memo[i] = i * @factorial_memo[i-1]
end

# 個数が可変になる要素は最後の要素のみ
# 可変個数は固定、それを全体の中から組合せで取得
kinds = medians.group_by(&:itself)
mobile_values = kinds.values.last
mobile_value = mobile_values.first
need_mobile_value_count  = mobile_values.length

all_mobile_value_count = v.count {|e| e==mobile_value }
result_count = memo_factor(all_mobile_value_count, need_mobile_value_count)

if medians.uniq.length==1
  (a+1..b).each do |c|
    result_count += memo_factor(all_mobile_value_count, c)
  end
end


p result_median
p result_count



Measured memory_bytes: 1788
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n; cin >> n;
  vector<int> A(n), B(n), C(n-1);
  loop(i,0,n) cin >> A[i];
  loop(i,0,n) A[i]--;
  loop(i,0,n) cin >> B[i];
  loop(i,0,n-1) cin >> C[i];
  int prev = -1;
  int t = 0;
  for (auto&&i: A) {
    if (prev + 1 == i) t += C[prev];
    prev = i;
    t += B[i];
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

int arr[100000];
ll dp[100000][100][2];
string a;
int d;

ll ds(string x){
    int res=0;
    for(int i=0 ; i<x.length() ; i++){
        res+=x[i]-'0';
    }
    return res;
}

int myMod(int q){
    if(q<0){
        return (d-(abs(q)%d))%d;
    }else{
        return q%d;
    }
}

ll gs(int ind,int n,int sum,int flag){
    //cout << ind << " " << sum << endl;
    if(ind==n){
        return (sum==0 ? 1:0);
    }
    if(dp[ind][sum][flag]!=-1){
        return dp[ind][sum][flag]%1000000007;
    }
    int limit=9;
    if(!flag){
        limit=arr[ind];
    }
    ll res=0;
    for(int i=0 ; i<=limit ; i++){
        if(flag || i<limit){
            res+=gs(ind+1,n,myMod(sum-arr[ind]+i),1);
        }else{
            res+=gs(ind+1,n,myMod(sum-arr[ind]+i),0);
        }
        res%=1000000007;
    }
    return dp[ind][sum][flag]=res%1000000007;
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    cin >> a >> d;
	    memset(dp,-1,sizeof dp);
	    for(int i=0 ; i<a.length(); i++){
	        arr[i]=a[i]-'0';
	    }
	    ll left=gs(0,a.size(),ds(a),0);
	    left--;
	    if(left<0){
	        cout << left+1000000007 << endl;
	    }else{
	        cout << left << endl;
	    }
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	long sum = 0;
	for(int i = 1; i <= n; i++){
	    if(i % 3 != 0 && i % 5 != 0){
	        sum += i;
	    }
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        ArrayList<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {
            mylist.add(strinput);
            strinput = reader.readLine();
        }

        String arr01[] = mylist.get(0).split(" ");

        String n = arr01[0];

        switch (n.substring(n.length() - 1)) {
        case "0":
        case "1":
        case "6":
        case "8":
            System.out.println("pon");
            break;
        case "2":
        case "4":
        case "5":
        case "7":
        case "9":

            System.out.println("hon");
            break;

        default:

            System.out.println("bon");
            break;
        }
    }

}


Measured memory_bytes: 32652
class Node:
	def __init__(self, i, k):
		self.i = i
		self.k = k
		self.p = self.l = self.r = None
		
	def __str__(self):
		ret = 'node ' + str(self.i) + ': '
		ret += 'key = ' + str(self.k) + ', '
		if self.p != None:
			ret += 'parent key = ' + str(self.p) + ', '
		if self.l != None:
			ret += 'left key = ' + str(self.l) + ', '
		if self.r != None:
			ret += 'right key = ' + str(self.r) + ', '
		return ret

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	id = i + 1
	node = Node(id, a[id-1])
	if i != 0:
		p = int(id/2) - 1
		node.p = a[p]
	l = id*2-1
	r = id*2
	if l < n:
		node.l = a[l]
	if r < n:
		node.r = a[r]		
	print(node)



Measured memory_bytes: 5624
function isValid(input, i, j) {
    var dx = [-1, 0, 1, 0];
    var dy = [0, -1, 0, 1];
    var k;
    for (k = 0; k < 4; k++) {
        if (i + dx[k] < 0 || j + dy[k] < 0 || i + dx[k] >= input.length || j + dy[k] >= input[i].length) continue;
        if (input[i + dx[k]][j + dy[k]] === '#') {
            return true;
        }
    }
    return false;
}

function Main(inp) {
    var input = inp.split('\n').slice(1).map(function(line) {
        return line.split('');
    });
    var i, j;
    for (i = 0; i < input.length; i++) {
        for (j = 0; j < input[i].length; j++) {
            var v = input[i][j];
            if (v !== '#') continue; // # だけ
            if (!isValid(input, i, j)) {
                console.log('No');
                return;
            }
        }
    }
    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    ans=a-c;
    if(a>=k){
        cout << k << endl;
        return 0;
    }else if(a+b<k){
        cout << ans+(a+b+c-k) << endl;
        return 0;
    }else{
        cout << a << endl;
        return 0;
    }
    

    return 0;
}











Measured memory_bytes: 3636
fun main(args : Array<String>){
    val n = readLine()!!.toInt()
    var a = readLine()!!.split(' ').map(String::toInt)
    var ans = 0L
    for(i in 0 until n){
        var tmp  = a[i]
        while(tmp % 2 == 0){
            tmp /= 2
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 41660
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll field[2005][2005]={0};
ll usum[2005][2005]={0},lsum[2005][2005]={0},rsum[2005][2005]={0};
int ssum[2005][2005]={0};
const int mod=1000000007;
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      char a;
      cin>>a;
      field[i][j]=(a=='#'?0:1);
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(field[i][j]==1){
        usum[i][j]=usum[i-1][j]+1;
        lsum[i][j]=lsum[i][j-1]+1;
      }
    }
  }
  for(int i=h;i>=1;i--){
    for(int j=w;j>=1;j--){
      if(field[i][j]==1){
        ssum[i][j]=ssum[i+1][j]+1;
        rsum[i][j]=rsum[i][j+1]+1;
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      ans=max(ans,usum[i][j]+lsum[i][j]+rsum[i][j]+ssum[i][j]-3);
    }
  }
  /*
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<usum[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<lsum[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<rsum[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<ssum[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
  **/
  cout<<ans<<endl;
}


Measured memory_bytes: 141568
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Integer;
import java.lang.System;
import java.lang.Exception;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        Pattern a = Pattern.compile(">'(=+)#\\1~");
        Pattern b = Pattern.compile(">\\^(Q=)+~~");

        int n = Integer.parseInt(r.readLine());
        for (int i = 0; i < n; i++) {
            String s = r.readLine();
            Matcher ma = a.matcher(s);
            Matcher mb = b.matcher(s);
            if (ma.matches()) {
                System.out.println("A");
            } else if (mb.matches()) {
                System.out.println("B");
            } else {
                System.out.println("NA");
            }
        }
    }
}

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

int main(){

    int N; cin >> N;
    string s, t; cin >> s >> t;
    
    for(int i = 0; i <= N; i++){
        bool ok = true;
        for(int j = i; j < N; j++){
            if(s[j] != t[j - i]) ok = false;
        }
        if(ok){
            cout << N + i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	_ "math"
	"os"
	_ "sort"
)

func Min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func Max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanln(a ...interface{})           { fmt.Fscanln(reader, a...) }

func main() {
	defer writer.Flush()

	var x, l, r int64
	scanln(&x)
	l = -1
	r = 10e9
	for l+1 < r {
		// println(l, r)
		m := (l + r) / 2
		y := m * (m + 1) / 2
		if y >= x {
			r = m
		} else {
			l = m
		}
	}

	println(r)
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void) {
	int n, m, i, j, z, q;
	int x = 0;
	int c[100];
	char s[100][10],t[100][10];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%s", t[i]);
	}
	for (i = 0; i < n; i++) {
		c[i] = 1;
	}
	while (x < n) {
		 for (i = x + 1; i < n; i++) {
			if (strcmp(s[x], s[i]) == 0)c[x]++;
		}
		for (i = 0; i < m; i++) {
			if (strcmp(s[x], t[i]) == 0)c[x]--;
		}
		if (x == 0)z = c[x];
		if (c[x] > z)z = c[x];
		x++;
	}
	printf("%d\n", (z <= 0) ? 0:z);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
import sys
i4 = np.int32
i8 = np.int64

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    from numba import njit
    from numba.types import int64, Array
    cc = CC('my_module')

    @njit
    def factorization(N):
        p = np.zeros(N + 1, i8)
        n_max = int(np.sqrt(N)) + 1
        p[0] = 1
        p[1] = 1
        for i in range(2, n_max):
            if p[i] == 0:
                j = i
                while j <= N:
                    p[j] = i
                    j += i
        for i in range(n_max, N + 1):
            if p[i] == 0:
                p[i] = i
        return p

    @cc.export('solve', (Array(int64, 1, 'C'),))
    def solve(A):
        a = np.sort(A)
        p_max = a[-1]
        p = factorization(p_max)
        primes_num = 0
        for i in range(p.shape[0]):
            if i == p[i]:
                primes_num += 1
        a_start = 0
        while a[a_start] == 1:
            a_start += 1
            if a_start == a.shape[0]:
                return 0
        a = a[a_start:]
        if len(a) > primes_num:
            return 1
        check = np.zeros(p_max + 1, i8)
        stack = np.empty(20, i8)
        p_stack = 0
        for d in a:
            while d > 1:
                x = p[d]
                for i in range(p_stack):
                    if stack[i] == x:
                        break
                else:
                    stack[p_stack] = x
                    p_stack += 1
                d //= x

            while p_stack > 0:
                p_stack -= 1
                check[stack[p_stack]] += 1

        if check.max() > 1:
            return 1
        else:
            return 0
    cc.compile()
    exit()


def main(in_file):
    stdin = open(in_file)
    stdin.readline()
    A = np.array([int(x) for x in stdin.readline().split()])
    ans = solve(A)
    if ans:
        g = np.gcd.reduce(A)
        if g > 1:
            ans = 2
        else:
            ans = 1
    p = ['pairwise coprime', 'setwise coprime', 'not coprime']
    print(p[ans])


if __name__ == '__main__':
    from my_module import solve
    main('/dev/stdin')


Measured memory_bytes: 145332
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  if(n>=30)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int H, W, D;
char F[512][512];
const char* S = "RYGB";

void place(int t, int d, int s, int p) {
  for (int c = 0; c < W; ++c) {
    int r = t - c;
    if (0 <= r && r < H) {
      F[r][c] = S[s + (p >= d)];
    }
    p = (p + 1) % (2 * d);
  }
}

int main() {
  H = in();
  W = in();
  D = in();
  if (D % 2 == 1) {
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        putchar("RY"[(i + j) % 2]);
      }
      puts("");
    }
  } else {
    int p = 0, o = 0;
    for (int t = 0; t <= H + W - 2; t += 2) {
      place(t, D / 2, (p >= D / 2) * 2, o);
      p = (p + 1) % D;
      o = (o + D - 1) % D;
    }
    p = 0; o = 0;
    for (int t = 1; t <= H + W - 2; t += 2) {
      place(t, D / 2, (p >= D / 2) * 2, o);
      p = (p + 1) % D;
      o = (o + D - 1) % D;
    }
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        putchar(F[i][j]);
      }
      puts("");
    }
  }

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C,cnt=0;
  cin>>N>>M>>C;
  vector<int> A(N);
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin>>B[i];
  }
  int a[N][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
     A[i]+=a[i][j]*B[j];
    }
  }
  for(int i=0;i<N;i++){
    if(A[i]+C>0){cnt++;
                }
  }
  cout<<cnt<<endl;
    
  }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    int g = gcd(a, b);
    return a / g * b;
}

int main() {
    int N; cin >> N;
    int A = 1;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        A = lcm(A, x);
    }
    cout << A << endl;
    return 0;
}

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

int main() {
	int n;
	set<int> d;
	cin >> n;
	rep(i, n) {
		int di;
		cin >> di;
		d.insert(di);
	}
	cout << d.size() << endl;
	return 0;
}

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

const int N = 1e5 + 50;

int a[N], n, tab[N], dp[105][105];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++)
    scanf("%d", &a[i]), tab[i] = a[i];
  sort(tab + 1, tab + n + 1);
  for (int i = 1; i <= n; i ++)
    a[i] = lower_bound(tab + 1, tab + n + 1, a[i]) - tab;
  for (int i = 1; i <= n; i ++) dp[1][i] = (i != a[1]);
  for (int i = 2; i <= n; i ++) {
    for (int j = 1; j <= n; j ++) {
      dp[i][j] = 1e9;
      for (int k = 1; k <= n; k ++)
        if (k != j) dp[i][j] = min(dp[i][j], dp[i - 1][k]);
      dp[i][j] += (j != a[i]);
    }
  }
  int ans = 1e9;
  for (int i = 1; i <= n; i ++) ans = min(ans, dp[n][i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll L[51],P[51];
ll n,x;

ll layer(ll x){
    return ((ll)pow(2,x+2)-3ll);
}
ll patty(ll x){
    return ((ll)pow(2,x+1)-1ll);
}
ll solve(ll n,ll x){
    if(x<=n-1||x==0) return 0;
    else if(n==0) return 1;
    else if(x==L[n-1]+1) return P[n-1];
    else if(x==L[n-1]+2) return P[n-1]+1;
    else if(x<L[n-1]+1) return solve(n-1,x-1);
    else return solve(n-1,x-2-L[n-1])+P[n-1]+1;
}
int main(){
    for(ll i=0;i<51;i++){
        L[i]=layer(i);P[i]=patty(i);
    }
    cin>>n>>x;

    /*
    レベルKバーガー
    Layer(k)=2*Layer(k-1)+3
      Layer(k)=2^(k+2)-3
      →Layer(50)=4*10^15とか
    Patty(k)=2*patty(k-1)+1
      
    Ban(k)=2*Ban(k-1)+2
    Layer(k)=lのときlは奇数
    下からl/2と上からl/2は対象、一番真ん中はパティ
     */

    cout<<solve(n,x)<<endl;
    return 0;
}

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

int N, K;
map<int,bool> dmap;

bool is_ok(int value) {
  string s = to_string(value);
  int ns = s.size();
  rep(i,ns) {
    if ( dmap.count(s.at(i) - '0') ) {
      return false;
    }
  }
  return true;
}

int main() {
  //input
  cin >> N >> K;
  vector<int> D(K);
  rep(i,K) {
    cin >> D.at(i);
  }
  //calc
  rep(i,K) {
    dmap[D.at(i)] = true;
  }
  int answer = N;
  while(!is_ok(answer)) {
    answer++;
  }
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
import math
x = int(input())
a = []
for i in range(1,int(math.sqrt(x))+1):
    if x % i == 0:
        a.append(i)
for j in range(len(a)):
    for k in range(int(math.sqrt(x))+1):
        y = k - a[j]
        if (k-y) * (k**4 + y * k**3 + (k**2)*(y**2) + k * (y**3) + y **4) == x:
            print(k,y)
            exit()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define arr(n) array<int,n>
#define INF 1e9
typedef long long ll;
typedef pair<int,int> pii;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  int x,y,xx,yy;
  cin >> x >> y >> xx >> yy;
  x--;y--;xx--;yy--;
  string c[H];
  rep(i,H) cin >> c[i];
  int ans[H][W];
  rep(i,H)rep(j,W){
    if(c[i][j]=='@') ans[i][j] = -2;
    else ans[i][j] = -1;
  }
  ans[x][y] = 0;
  queue<pair<int,int>> q;
  q.push(make_pair(x,y));
  while(!q.empty()){
    pair<int,int> now = q.front();
    q.pop();
    rep(i,4){
      for(int j=1;j<=K;j++){
        int nx = now.first+dx[i]*j;
        int ny = now.second+dy[i]*j;
        if(nx>=0 and ny>=0 and nx<H and ny<W){
          if(ans[nx][ny] == -1){
            ans[nx][ny] = ans[now.first][now.second] + 1;
            q.push(make_pair(nx,ny));
          }
          else if(ans[nx][ny] < ans[now.first][now.second] + 1) break;
        }
        else break;
      }
    }
  }
  cout << ans[xx][yy] << endl;
  return 0;
}

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

string ans;
char C[]="BR";
char Sol[1<<8];
bool query(int a,int b)
{
    cout<<"? ";
    for(int i=a;i<=b;++i) cout<<i<<' ';
    cout<<'\n';
    cout.flush();
    cin>>ans;
    if(ans=="-1")
        while(1);
    return ans[0]==C[1];
}
bool qquery(int a,int b,int x)
{
    cout<<"? ";
    for(int i=a;i<=b;++i) cout<<i<<' ';
    cout<<x<<'\n';
    cout.flush();
    cin>>ans;
    if(ans=="-1")
        while(1);
    return ans[0]==C[1];
}
bool qqquery(int a,int b,int c,int d,int x)
{
    cout<<"? ";
    for(int i=a;i<=b;++i) cout<<i<<' ';
    for(int i=c;i<=d;++i) cout<<i<<' ';
    cout<<x<<'\n';
    cout.flush();
    cin>>ans;
    if(ans=="-1")
        while(1);
    return ans[0]==C[1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    if(n==1)
    {
        bool x=query(1,1);
        cout<<"! "<<C[x]<<C[x^1]<<'\n';
        cout.flush();
        return 0;
    }
    bool x=query(1,n);
    int p=1;
    for(int step=1<<8;step;step>>=1)
        if(p+step<=n+1)
            if(x==query(p+step,p+step+n-1)) p+=step;
    Sol[p]=C[x];
    Sol[p+n]=C[x^1];
    for(int i=1;i<=n+n;++i)
        if(i<p||i>p+n)
            Sol[i]=C[qquery(p+1,p+n-1,i)];
        else if(i>p&&i<p+n)
            Sol[i]=C[qqquery(1,p-1,p+n+1,n+n,i)];
    cout<<"! "<<(Sol+1)<<'\n';
    cout.flush();
    return 0;
}


Measured memory_bytes: 724
N = int(input())

d = {"AC":0,"WA":1,"TLE":2,"RE":3}
ans = [0]*4
for i in range(N):
    S = input()
    ans[d[S]]+=1

print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

llong N, M, Q;
vector<llong> a, b, c, d;

llong solve(vector<int> v) {
  if (v.size() == N) {
    llong res = 0;
    for (int i = 0; i < Q; ++i) {
      if (v[b[i] - 1] - v[a[i] - 1] == c[i]) {
        res += d[i];
      }
    }
    return res;
  }

  llong ret = 0;
  for (int i = (v.size() == 0 ? 1 : v.back()); i <= M; ++i) {
    v.push_back(i);
    ret = max(ret, solve(v));
    v.pop_back();
  }

  return ret;
}

int main() {

  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  llong ans = 0;
  cout << solve(vector<int>()) << endl;

  return 0;
}

Measured memory_bytes: 3632
M=10**9+7
def sum(l, h)
  (l+h)*(h-l+1)/2 % M
end
N,K=gets.split.map(&:to_i)
p K.upto(N+1).inject(0){|s,i|(s+sum(N-i+1,N)-sum(0,i-1)+1)%M}

Measured memory_bytes: 14312
#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <cstring>
#include <bitset>

using namespace std;
void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using ld = long double;


void precalc() {}

void solve() {

    string a;
    string b;
    ll a_cnt;
    ll b_cnt;
    string u;

    cin >> a >> b >>a_cnt >> b_cnt >> u;


    if (a == u)
        cout << a_cnt - 1 << " " << b_cnt;
    else
        cout << a_cnt << " " << b_cnt - 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(20);
    precalc();
    solve();

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ull N, M;
    cin >> N >> M;
    vector<ull> a(M + 2);
    a.at(0) = -1;
    if(M != 0) for(ll i = 1; i < M + 1; i++) cin  >> a.at(i);
    a.at(M + 1) = N + 1;
    
    vector<ull> fib(100005);
    fib.at(0) = 0;
    fib.at(1) = 1;
    for(ull i = 2; i < 100005; i++) fib.at(i) = (fib.at(i - 1) + fib.at(i -2)) % 1000000007;
   
    vector<ull> deff(M + 1);
    ull ans = 1;
    for(ll i = 0; i < M + 1; i++) deff.at(i) = a.at(i + 1) - a.at(i) - 1;
    for(ll i = 0; i < M + 1; i++){
        ans = ans * (fib.at(deff.at(i) % 1000000007) ) % 1000000007;
    }
    cout << ans % 1000000007<< endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

typedef std::pair<int, int> P;

int main(void) {

  bool isprime[1000000];
  isprime[0] = isprime[1] = false;
  for(int i = 2; i < 1000000; ++i) {
    isprime[i] = true;
  }
  for(int i = 2; i < 1000; ++i) {
    if( isprime[i] ) {
      for(int j = i + i; j < 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }

  int totalprime[1000000] = {};
  int total = 0;
  for(int i = 0; i < 1000000; ++i) {
    if( isprime[i] ) {
      total += 1;
    }
    totalprime[i] = total;
  }
  
  for(;;) {
    int n;
    std::cin >> n;
    if( n == 0 ) break;

    std::cout << totalprime[n * 2] - totalprime[n] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 6048
#include <iostream>

using namespace std;

void solve()
{
	int a, b;
	bool firstFlag = true;
	while(cin >> a >> b, a || b)
	{
		if(!firstFlag)
		{
			cout << endl;
		}
		firstFlag = false;
		int count = 0;
		for(int i = a; i <= b; ++i)
		{
			if(i % 4 == 0)
			{
				if(i % 100 == 0 && i % 400 == 0)
				{
					cout << i << endl;
					++count;
				}
				else if(i % 100 != 0)
				{
					cout << i << endl;
					++count;
				}
			}
		}
		if(count == 0)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
/// F: DP and square root decomposition.
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const int Mod = 1e9 + 7;
const ll inf = 1e18;
const int mx = 100000;

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, k;
        cin >> n >> k;

        ll root = sqrt(n) + 1;
        ll dpS[root][k];
        ll dpL[root][k];

        for (int i = 0; i < root; i++) {
            for (int j = 0; j < k; j++) {
                dpS[i][j] = 0;
                dpL[i][j] = 0;
            }
        }

        ll countLarge[root];
        for (int i = 0; i < root; i++)
        {
            countLarge[i] = max(n / (i + 1), (int) root) - max(n / (i + 2), (int)root);
        }

        ll sufS[root], preL[root];

        for (int i = 0; i < root; i++) {
            sufS[i] = 0;
            preL[i] = 0;
        }

        sufS[root - 1] = 1;
        preL[0] = 1;

        for (int i = 0; i < k; i++) {
            ll curSum = 0;
            for (int j = root - 1; j >= 0; j--) {
                curSum += sufS[j];
                sufS[j] = 0;
                curSum = curSum % Mod;
                dpS[j][i] = curSum;
            }
            curSum = 0;
            for (int j = 0; j < root; j++) {
                curSum += preL[j];
                curSum = curSum % Mod;
                preL[j] = 0;
                dpL[j][i] = (curSum * countLarge[j]) % Mod;
            }

            for (int j = 0; j < root; j++) {
                ll maxVal = n / (j + 1);
                if (maxVal > root) maxVal = root;
                sufS[maxVal - 1] += dpS[j][i];
                sufS[maxVal - 1] = sufS[maxVal - 1] % Mod;
                preL[j] += dpS[j][i];
                preL[j] = preL[j] % Mod;
            }

            for (int j = 0; j < root; j++) {
                sufS[j] +=  dpL[j][i];
                sufS[j] %= Mod;
            }
        }

        ll ans = 0;
        for (int i = 0; i < root; i++) {
            ans += dpL[i][k - 1] + dpS[i][k - 1];
            ans = ans % Mod;
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 50432
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e5;

int n, tab[nax + 2], gcd[nax + 2], dcg[nax + 2];

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

    cin >> n;
    
    for (int i = 1; i <= n; ++i)
        cin >> tab[i];

    for (int i = 1; i <= n; ++i)
        gcd[i] = __gcd(tab[i], gcd[i - 1]);
    for (int i = n; i >= 1; --i)
        dcg[i] = __gcd(tab[i], dcg[i + 1]);
    int res = 0;
    for (int i = 1; i <= n; ++i)
        res = max(res, __gcd(gcd[i - 1], dcg[i + 1]));
    print(res);
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int MAX = 101010;
	vector<int> is_prime(MAX, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < MAX; ++i) {
		if (!is_prime[i])
			continue;
		for (int j = i * 2; j < MAX; j += i)
			is_prime[j] = 0;
	}

	vector<int> a(MAX, 0);
	for (int i = 0; i < MAX; ++i) {
		if (i % 2 == 0)
			continue;
		if (is_prime[i] && is_prime[(i+1)/2])
			a[i] = 1;
	}

	vector<int> s(MAX+1, 0);
	for (int i = 0; i < MAX; ++i)
		s[i + 1] = s[i] + a[i];

	int Q;
	cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int l, r;
		cin >> l >> r;
		++r;

		cout << s[r] - s[l] << endl;
	}
}

Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

int main(){	
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif

	int n;
	cin>>n;
	int a1=0,a2=0,a4=0;
	REP(i,n){
		int x;
		scanf("%d",&x);
		if(x%4==0)a4++;
		else if(x%2==0)a2++;
		else a1++;
	}
	if(a1>a4+1) puts("No");
	else if(a1==a4+1){
		if(a2==0)puts("Yes");
		else puts("No");
	}else{
		puts("Yes");
	}

#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

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

int main(){
	int N,M;
	cin>>N>>M;
	priority_queue<long long>q;
	for(int i=0;i<N;i++){
		long long a;
		cin>>a;
		q.push(a);
	}
	for(int i=0;i<M;i++){
		long long top=q.top();
		q.pop();
		top/=2;
		q.push(top);
	}
	long long ans=0;
	while(!q.empty()){
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MOD = 1e9 + 7;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    ll cnt_b = 0;

    for (int i = 0; i < S.size(); i++){
        if (S[i] == 'B') cnt_b += 1;
        if (S[i] == 'W') {
            ans += cnt_b;
        }
        
    }
    cout << ans << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  ll n, a;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    vector<ll> dp(n, -INFL);
    cin >> dp[0];  // n番目に切った時の最大値
    for (int i = 0; i < n - 1; i++) {
      cin >> a;
      dp[i + 1] = max(dp[i] + a, a);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
  }
}



Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <set>
using namespace std;
int main(void){
    char a[3]; cin>>a[0]>>a[1]>>a[2];
  	int ans=700;
  	for(int i=0;i<3;i++){
      if(a[i]=='o') ans+=100;
    }
  	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 998244353
N, K = map(int, input().split())
kukan = [tuple(map(int, input().split())) for _ in range(K)]

dp = [0] * (N+1)
dp[1] = 1

sumdp = [0] * (N+1)
sumdp[1] = 1

for i in range(2, N+1):
    for l, r in kukan:
        li = max(i - l, 0)
        ri = max(i - r - 1, 0)

        dp[i] += sumdp[li] - sumdp[ri]
        dp[i] %= MOD

    sumdp[i] = sumdp[i-1] + dp[i]

print(dp[N])

Measured memory_bytes: 27860
n = int(input())
A = []

if n == 0:
    print(0)
else:
    while n != 0:
        if n % -2 != 0:
            A.append('1')
            n = n // -2 + 1
        else:
            A.append('0')
            n = n // -2

A.reverse()
print(''.join(A))

Measured memory_bytes: 3060
use proconio::marker::*;
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: Chars,
    };
    let mut ans = 0;
    for x in n.iter().map(|x| x.to_digit(10).unwrap()) {
        ans = (ans + x) % 9;
    }

    println!("{}", if ans % 9 == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 2972
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007

using namespace std;
using ll = long long int;

int main(void) {
    int h, w; cin >> h >> w;
    vector<vector<bool>> m(h, vector<bool>(w));
    REP(i, h) {
        REP(j, w) {
            char c; cin >> c;
            if (c == '#') m[i][j] = true;
        }
    }
    vector<vector<ll>> dp(h, vector<ll>(w));
    dp[0][0] = 1;
    int s = 0, t = 0;
    while (s < h) {
        if (m[s][0]) break;
        dp[s][0] = 1;
        s++;
    }
    while (t < w) {
        if (m[0][t]) break;
        dp[0][t] = 1;
        t++;
    }
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] += dp[i][j - 1];
            if (m[i][j]) dp[i][j] = 0;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 8320
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print((A-1) * (B-1))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    string S1, S2; cin >> S1 >> S2;

    ll ans = 1;
    int i1 = 0, i2 = 0;
    while(true) {
        if(S1[i1] == S2[i2]) {
            if(i1 == 0 and i2 == 0) ans *= 3;
            else {
                if(S1[i1 - 1] == S2[i2 - 1]) ans *= 2;
                else ans *= 1;
            }
            i1++; i2++;
        }
        else {
            if(i1 == 0 and i2 == 0) ans *= 6; 
            else {
                if(S1[i1 - 1] == S2[i2 - 1]) ans *= 2;
                else ans *= 3;
            }
            i1 += 2; i2 += 2;
        }
        ans %= mod;
        if(i1 >= S1.size()) break;
    }
    cout << ans << endl;
    return 0;
    
}



Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
x = 10**10
ans = 0
for i in range(n):
    if abs(t-h[i]*0.006-a) < x:
        x = abs(t-h[i]*0.006-a)
        ans = i
print(ans+1)


Measured memory_bytes: 3060
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
alias invmod=(long x,long n,long m=10^^9+7)=>powmod(x,m-2,m);alias powmod=(long x,long n,long m=10^^9+7)=>
std.math.powmod(cast(ulong) x,cast(ulong) n,cast(ulong) m);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto cnt1 = new long[](N);
    auto cnt2 = new long[](N);
    foreach (i; 0 .. N)
    {
        cnt1[abs(i - (N - 1 - i))]++;
        cnt2[A[i]]++;
    }
    if (zip(cnt1, cnt2).any!"a[0] != a[1]"())
    {
        writeln(0);
        return;
    }
    writeln(Mod(2) ^^ (N / 2));

}

struct Mod
{
    alias T = long;
    T data, m;
    alias data this;
    this(T x, T m = 10 ^^ 9 + 7)
    {
        this.data = x;
        this.m = m;
    }

    Mod opBinary(string op, R)(R rhs)
    {
        static if (op == "-")
            return Mod((m + data - rhs) % m, m);
        static if (op == "^^")
            return Mod(std.math.powmod(cast(ulong) data, cast(ulong) rhs, cast(ulong) m), m);
        static if (op == "/")
            return Mod(data * std.math.powmod(cast(ulong) rhs, cast(ulong) m - 2, cast(ulong) m) % m,
                    m);
        return Mod(mixin("data " ~ op ~ " rhs") % m, m);
    }

    Mod opUnary(string op)()
    {
        static if (op == "-")
            return Mod((m + data - 1) % m, m);
        return Mod(mixin(op ~ "data") % m, m);
    }
}


Measured memory_bytes: 8076
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Max = 1, MaxValue = 0;
		int count = 0;
		

		for (int i = 1; i <= N; i++) {
			int tempI = i;

			while(true) {
				if (tempI % 2 == 0) {
					++count;
					tempI /= 2;
				}
				else {
					if(MaxValue < count) {
						Max = i;
						MaxValue = count;
						
					}
					break;
				}
			}
			count = 0;

		}
		System.out.println(Max);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  
  int h,w;
  cin >> h >> w;
  vector<vector<int>> tab(h+1,vector<int>(w+1));
  vector<int> x,y,u,v;
  int ans;
  rep1(i,h) rep1(j,w) cin >> tab[i][j];
  rep1(i,h-1){
    rep1(j,w){
      if(tab[i][j]%2){
        tab[i][j] --;
        tab[i+1][j] ++;
        ans ++;
        x.push_back(i);
        y.push_back(j);
        u.push_back(i+1);
        v.push_back(j);
      }
    }
  }
  rep1(j,w-1){
    if(tab[h][j]%2){
      tab[h][j] --;
      tab[h][j+1] ++;
      ans ++;
      x.push_back(h);
      y.push_back(j);
      u.push_back(h);
      v.push_back(j+1);
    }
  }
  cout << ans << endl;
  rep(i,ans){
    cout << x[i] << " ";
    cout << y[i] << " ";
    cout << u[i] << " ";
    cout << v[i];
    cout << endl;
  }
}


Measured memory_bytes: 5220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=Long.parseLong(sc.next());
      System.out.println((n%11==0)?n/11*2:(n%11<=6)?n/11*2+1:n/11*2+2);
    }
}


Measured memory_bytes: 23508
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    
    int average = (int)Math.ceil( (a+b)/2 );
    System.out.println(average);
  }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>

typedef struct city {
  int idx;
  int year;
  int prefecture;
  int order;
} city;

int cmp_year(const void *x, const void *y) {
  if (((city *)x)->prefecture == ((city *)y)->prefecture) return ((city *)x)->year-((city *)y)->year;
  else return ((city *)x)->prefecture-((city *)y)->prefecture;
}

int cmp_idx(const void *x, const void *y) {
  return ((city *)x)->idx-((city *)y)->idx;
}

int main() {
  int n, m, num = 1, pre = 0;
  scanf("%d%d", &n, &m);
  city a[m];
  for (int i=0; i<m; i++) {
    scanf("%d%d", &(a[i].prefecture), &(a[i].year));
    a[i].idx = i;
  }
  qsort(a, m, sizeof(city), cmp_year);
  for (int i=0; i<m; i++) {
    if (pre == a[i].prefecture) {
      a[i].order = num;
      num++;
    } else {
      pre = a[i].prefecture;
      num = 1;
      a[i].order = num;
      num++;
    }
  }
  qsort(a, m, sizeof(city), cmp_idx);
  for (int i=0; i<m; i++) {
    printf("%06d%06d\n", a[i].prefecture, a[i].order);
  }
  return 0;
}


Measured memory_bytes: 4580
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

ll chmax(ll &a, ll b){ return a = (a>b) ? a : b;}

int main(){
  ll R, C, K;
  cin >> R >> C >> K;
  vector<ll> r(K), c(K), v(K);
  vector<vector<ll>> item(R+3, vector<ll>(C+3, 0));
  for(int i=0; i<K; i++){
    cin >> r[i] >> c[i] >> v[i];
    item[r[i]][c[i]] = v[i];
  }

  // cout << " item: "; print_vec2(item);
  // dp[i][j][k]:: (i, j)にいる時にi行目でk個拾った　ときの最大価値
  vector<vector<vector<ll>>> dp(R+3, vector<vector<ll>>(C+3, vector<ll>(4, 0)));
  dp[1][1][0] = 0;
  if(item[1][1] != 0) dp[1][1][1] = item[1][1];

  for(int i=1; i<=R; i++){
    for(int j=1; j<=C; j++){
      for(int k=0; k<=3; k++){
        
        //アイテム拾わない
        chmax(dp[i+1][j][0], dp[i][j][k]);
        chmax(dp[i][j+1][k], dp[i][j][k]);
        
        if(item[i+1][j] != 0){
          chmax(dp[i+1][j][1], dp[i][j][k] + item[i+1][j] );
        }
        if(item[i][j+1] != 0){
          if(k<=2) chmax(dp[i][j+1][k+1], dp[i][j][k] + item[i][j+1]);
        }
      }
    }
  }

  
  ll ans = -1;
  ans = max(ans, dp[R][C][0]);
  ans = max(ans, dp[R][C][1]);
  ans = max(ans, dp[R][C][2]);
  ans = max(ans, dp[R][C][3]);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 712100