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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   string s;
   cin>>s;
   int cnt[3]={};

   rep(i,0,s.size()){
      ++cnt[int(s[i]-'a')];
   }

   if(max({cnt[0],cnt[1],cnt[2]}) - min({cnt[0],cnt[1],cnt[2]}) <= 1)
      cout<<"YES\n";
   else cout<<"NO\n";
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

l=[]
temp=2
while True:
    l.append(temp)
    temp*=2
    if temp>B:
        break

ans=0

judge=((B//2+B%2)-(A//2+A%2))
if A%2==1:
    judge+=1
if judge%2==1:
    ans+=1

for i in range(len(l)):
    temp=0
    if (A%(2*l[i]))>=l[i]:
        if (A%l[i])%2 == 1:
            temp^=1
        
    if (B%(2*l[i]))>=l[i]:
        if (B%l[i])%2 == 0:
            temp^=1
    else:
        #temp^=1
        pass
        
    if temp==1:
        ans+=l[i]

print(ans)

"""
1 4つの内2で割れるところが何個あるか
01010101
2 4つの内であまりが2以上で何個あるか
00110011
4 8つの内であまりが4以上で何個あるか
0000111100001111
"""


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		String odd = r.str();
		String even = r.str();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i<odd.length(); i++)
		{
			sb.append(odd.charAt(i));
			if(i<even.length())
				sb.append(even.charAt(i));
		}
		print(sb.toString());
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 21076
use whiteread::parse_line;

fn is_bingo(check: &Vec<Vec<bool>>, x: usize, y: usize, mode: i32) -> bool {
    if !check[x][y] {
        return false;
    }
    match mode {
        0 => {
            for i in 0..3 {
                let i = i as usize;
                if !check[i][y] {
                    return false;
                }
            }
            true
        }
        1 => {
            for i in 0..3 {
                let i = i as usize;
                if !check[x][i] {
                    return false;
                }
            }
            true
        }
        2 => {
            for i in 0..3 {
                let i = i as usize;
                if !check[i][i] {
                    return false;
                }
            }
            true
        }
        3 => {
            for i in 0..3 {
                if !check[i][2 - i] {
                    return false;
                }
            }
            true
        }
        _ => {
            unreachable!();
        }
    }
}

fn bingo(card: &Vec<Vec<i32>>, check: &mut Vec<Vec<bool>>, num: i32) {
    for i in 0..3 {
        let i = i as usize;
        for k in 0..3 {
            let k = k as usize;
            if card[i][k] == num {
                check[i][k] = true;
            }
        }
    }
}

fn main() {
    let mut a: Vec<Vec<i32>> = Vec::with_capacity(3);
    let mut check = vec![vec![false; 3]; 3];
    for _ in 0..3 {
        a.push(parse_line().unwrap());
    }
    let n: usize = parse_line().unwrap();

    for _ in 0..n {
        bingo(&a, &mut check, parse_line().unwrap())
    }

    let mut ans = false;
    for i in 0..3 {
        let i = i as usize;
        for k in 0..3 {
            let k = k as usize;
            if ans {
                break;
            }
            ans = is_bingo(&mut check, i, k, 0) || is_bingo(&mut check, i, k, 1);
            // 左斜めと右斜め
            if i == k {
                ans = ans || is_bingo(&mut check, i, k, 2);
            }
            if i + k == 2 {
                ans = ans || is_bingo(&mut check, i, k, 3);
            }
        }
    }
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2180
n=int(input())
la=[]
lb=[]
for i in range(n):
  a,b=map(int,input().split())
  la.append(a)
  lb.append(b)
l=[]
for i in range(n):
  l.append([la[i]+lb[i],i])
l=sorted(l)
l=l[::-1]
now=1
countt=0
counta=0
for i in range(n):
  if now==1:
    countt+=la[l[i][1]]
  else:
    counta+=lb[l[i][1]]
  now*=-1
print(countt-counta)
    

Measured memory_bytes: 28744
# 2019-11-11 16:07:35(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

like = 753
def main():
    S = sys.stdin.readline().rstrip()
    min_diff = 642
    for i in range(len(S)-2):
        x = int(S[i:i+3])
        diff = abs(753 - x)
        min_diff = min(min_diff, diff)
    print(min_diff)

if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i, a, b) for(int i = a; i < b; i++)
#define pool(i, a, b) for(int i = a; i > b; i--)
#define pb push_back

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define MAX 3000

double a[MAX];
double f[MAX][MAX];

int main()
{
	int n;
	fastIO
	cin >> n;
	loop(i, 1, n + 1)
		cin >> a[i];
	f[1][0] = ((double)1 - a[1]), f[1][1] = a[1];
	loop(i, 2, n + 1)
	{
		f[i][0] = f[i - 1][0] * ((double)1 - a[i]);
		loop(j, 1, i + 1)
		{
			f[i][j] = f[i - 1][j - 1] * a[i];
			if(i != j)
				f[i][j] += f[i - 1][j]*((double)1 - a[i]);
		}
	}
	double ans = 0;
	loop(i, n/2 + 1, n + 1) ans += f[n][i];
	// cout << ans << "\n";
	printf("%.10f\n", ans);

	return 0;
}

Measured memory_bytes: 68992
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
int m = sc.nextInt();
int f = sc.nextInt();
int r = sc.nextInt();
if (m == -1 && f == -1 && r == -1){
break;
}
if(m == -1 || f == -1){
System.out.println("F");
}else{
if (m + f >= 80){
System.out.println("A");
}else if(m + f >= 65){
System.out.println("B");
}else if(m + f >= 50){
System.out.println("C");
}else if(m + f >= 30){
if(r >= 50){
System.out.println("C");
}else{
System.out.println("D");
}
}else{
System.out.println("F");
}
}
}
sc.close();
}
}


Measured memory_bytes: 26260
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
K = INT()

cnt = 0
while B <= A:
    B *= 2
    cnt += 1

while C <= B:
    C *= 2
    cnt += 1

print("Yes" if cnt <= K else "No")


Measured memory_bytes: 10044
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 5e5 + 10; 
const int block_size = 2000;

int cnt[N];
int A[N];
int cur = 0;

void remove(int idx){
   cnt[A[idx]]--;
   if(cnt[A[idx]] == 0) --cur;
}

void add(int idx){
   if(cnt[A[idx]] == 0) ++cur;
   cnt[A[idx]]++;
}

int get_answer(){
   return cur;
}

struct Query {
    int l, r, idx;
    bool operator<(Query other) const
    {
        return make_pair(l / block_size, r) <
               make_pair(other.l / block_size, other.r);
    }
};

vector<int> mo_s_algorithm(vector<Query> queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end());

    // TODO: initialize data structure

    int cur_l = 0;
    int cur_r = -1;
    // invariant: data structure will always reflect the range [cur_l, cur_r]
    for (Query q : queries) {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        answers[q.idx] = get_answer();
    }
    return answers;
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,q;
   cin >> n >> q;
   vector<Query> Q(q);
   f(i,0,n){
      cin >> A[i];
   }
   f(i,0,q){
      int l,r;
      cin >> l >> r;
      --l,--r;
      Q[i].l = l, Q[i].r = r;
      Q[i].idx = i;
   }
   vector<int> R = mo_s_algorithm(Q);
   f(i,0,q){
      cout << R[i] << '\n';
   }
   return 0;
} 

Measured memory_bytes: 38328
#include <iostream>
#include <map>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <vector>


using namespace std;

int main(){
  long long h, w, d, q, grids;
  long long total_cost = 0;
  vector<vector<long long>> v;
  long long a[301][301];
  map<long long, pair<long long, long long>> m;
  cin >> h >> w >> d;
  grids = h*w;
  for (long long j=0;j<h;j++) {
    for (long long i=0;i<w;i++) {
      long long aa;
      cin >> aa;
      pair<long long, long long> p = make_pair(i, j);
      m[aa] = p;
      a[j][i] = aa;
    }
  }

  
  for (long long i=1;i<=d;i++) {
    long long a = i;
    long long prev_a = a;
    vector<long long> acc_cost;
    acc_cost.push_back(0);
    a += d;
    while (a <= grids) {
      long long cost = abs(get<0>(m[a]) - get<0>(m[prev_a])) + abs(get<1>(m[a]) - get<1>(m[prev_a]));
      cost += acc_cost.back();
      acc_cost.push_back(cost);
      prev_a = a;
      a += d;
    }
    v.push_back(acc_cost);
  }
  
  cin >> q;
  for (long long i=0;i<q;i++) {
    long long l, r;
    cin >> l >> r;
    long long start = l%d == 0?d:l%d;
    long long offset = (l-start)/d;
    long long steps = (r - l)/d;
    // cout << start << "\t" << offset << "\t" << steps << endl; 
    // for (auto it=v[start-1].begin();it != v[start-1].end();it++) {
    //   cout << *it << "\t";
    // }
    // cout << endl;

    cout << v[start-1][offset + steps] - v[start-1][offset] << endl;
  }
  return(0);
}


Measured memory_bytes: 10932
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV& S, ll d, V& prev, V& C, ll j) {
    ll temp = 0;
    temp += S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width = 360;
    vector<tuple<ll, V, V>> vec;
    V temp;
    rep(i, 26) temp.push_back(-1);
    V temp2;
    vec.push_back({0, temp, temp2});
    rep3(i, 0, d) {
        priority_queue<tuple<ll, V, V>> q;
        for (auto j : vec) {
            ll score = get<0>(j);
            V prev = get<1>(j);
            V history = get<2>(j);
            rep(k, 26) {
                if(!history.empty()&&history.back()==k)continue;
                ll value = evaluate(S, i, prev, C, k);
                ll prev2 = prev[k];
                
                prev[k] = i;
                history.push_back(k);
                q.push({score + value, prev, history});
                history.pop_back();
                prev[k] = prev2;
            }
        }
        vec = {};
        for (ll j = 0; j < width && !q.empty(); j++) {
            vec.push_back(q.top());
            q.pop();
        }
    }
    for (auto i : get<2>(vec[0])) {
        cout << i + 1 << endl;
    }
}


Measured memory_bytes: 33936
#include <stdio.h>

int main () {
	
	int count = 0, n, x[100];
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	
	for(int j = 1; j < n - 1; j++){
		if(x[j] > x[j-1] && x[j] < x[j+1]){
			count++;
		}
		else if(x[j] < x[j-1] && x[j] > x[j+1]){
			count++;
		}
	}
	
	printf("%d", count);
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))
mod = 1000000007
ans = 1
cnt = [3 if i==0 else 0 for i in range(n+1)]

for a in A:
    ans = ans*cnt[a]%mod
    if ans==0: break
    cnt[a] -= 1
    cnt[a+1] += 1
print(ans)

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

using namespace std;

#define X first
#define Y second
#define mP make_pair

double INF = 1000 * 1000 * 1000;

typedef complex<double> point;
typedef vector<point> poly;

#define EPS 1e-9
#define all(a) a.begin(), a.end()

struct BipartiteMatcher {
	vector<vector<int>> G;
	vector<int> L, R, Viz;

	BipartiteMatcher(int n, int m) :
		G(n), L(n, -1), R(m, -1), Viz(n) {}

	void AddEdge(int a, int b) {
		G[a].push_back(b);
	}

	bool Match(int node) {
		if(Viz[node]) 
			return false;
		Viz[node] = true;
	
		for(auto vec : G[node]) {
			if(R[vec] == -1 || Match(R[vec])) {
				L[node] = vec;
				R[vec] = node;
				return true;
			}
		}

		return false;
	}
	int Solve() {
		bool ok = true;
		while(ok) {
			ok = false;
			fill(Viz.begin(), Viz.end(), 0);
			for(int i = 0; i < L.size(); ++i)
				if(L[i] == -1)
					ok |= Match(i);
		}
		
		int ret = 0;
		for(int i = 0; i < L.size(); ++i)
			ret += (L[i] != -1);
		return ret;
	}
};

int main(){
	int n;
	cin >> n;
	pair<int , int> a[n + 10];
	pair<int , int> b[n + 10];
	for(int i = 0 ; i < n ; ++i){
		int x ,y;
		cin >> x >> y;
		a[i] = mP(x , y);
	}

	for(int i = 0 ; i < n ; ++i){
		int x ,y;
		cin >> x >> y;
		b[i] = mP(x , y);
	}

	struct BipartiteMatcher bm(n , n);

	int ans = 0;

	for(int i = 0 ; i < n ; ++i){
		for(int j = 0 ; j < n ; ++j){
			if(a[i].X < b[j].X && a[i].Y < b[j].Y){
				bm.AddEdge(i , j);
			}
		}
	}

	cout << bm.Solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 


char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 

int numDivisors(int n){
    int cnt = 0; 
    for(int i =1; i*i<=n; i++){
        if(n% i == 0){
            cnt++; 
        }
        if(n/i != i && n%i == 0){
            cnt++; 
        }
    }
    
    return cnt; 
}

int main(){

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

int n; cin >> n; 
int ans = 0; 

for(int c = 1; c<n; c++){
    ans+=numDivisors(n - c); 
    //cout << c << bl << numDivisors(n - c) << endl; 
}

cout << ans; 


}



Measured memory_bytes: 3636
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let total: usize = a.iter().sum();
    let count: usize = a.iter().filter(|&&it| 4 * m * it >= total).count();

    return if count >= m {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

set<string> ss;

int main(){
	int n;
	cin >> n;
	REP(i,n){
		string str;
		cin >> str;
		int k=str.length();
		ss.clear();
		ss.insert(str);
		REP(i,k){
			string s1, s2, rs1, rs2;
			rs1=s1=str.substr(0,i);
			rs2=s2=str.substr(i,k-i);
			reverse(rs2.begin(), rs2.end());
			reverse(rs1.begin(), rs1.end());
			ss.insert(s2+s1);
			ss.insert(rs2+s1);
			ss.insert(s2+rs1);
			ss.insert(rs2+rs1);
			ss.insert(s1+rs2);
			ss.insert(rs1+rs2);
			ss.insert(rs1+s2);
		}
		cout << ss.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
unittest
{
	assert( [ "3 5 4", "11100", "10001", "00111" ].parse.expand.solve == 2 );
	assert( [ "3 5 8", "11100", "10001", "00111" ].parse.expand.solve == 0 );
	assert( [ "4 10 4", "1110010010", "1000101110", "0011101001", "1101000111" ].parse.expand.solve == 3 );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwk = input.front.split.to!( long[] );
	auto css = new dchar[][]( hwk[ 0 ], hwk[ 1 ] );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front.to!( dchar[] );
	}
	return tuple( hwk[ 2 ], css );
}

auto solve( long k, dchar[][] css )
{
	// 横方向に分割する位置をbit全列挙する
	auto ans = long.max;
	LOOP: foreach( yb; 0L .. 1L << ( css.length.signed - 1 ) )
	{
		auto bp = yb._popcnt;
		auto r = bp;
		auto vts = new long[ 1 + bp ];
		auto vtm = 0L;
		auto vtc = 0L;
		foreach( x; 0L .. css[ 0 ].length.signed )
		{
			auto vs = new long[ 1 + bp ];
			auto vi = 0L;
			
			// 縦方向に分割が必要か判定
			for( auto y = 0L; y < css.length; y++ )
			{
				if( css[ y ][ x ] == '1' )
				{
					vts[ vi ]++;
					vs[ vi ]++;
					vtm = max( vtm, vts[ vi ] );
				}
				if( yb & ( 1L << y ) ) vi++;
			}
			
			if( k < vtm )
			{
				// 縦方向に分割する
				if( vtc == 0 ) continue LOOP;		// 1列だけでKマス超えてしまったので無理
				r++;
				vts[] = vs[];
				vtm = vts.reduce!max;
				if( vtm == 0 ) continue LOOP;		// 1列だけでKマス超えてしまったので無理
				vtc = 1;
			}
			else
			{
				// 縦方向に分割しない
				vtc++;
			}
		}
		ans = min( ans, r );
	}
	return ans;
}


Measured memory_bytes: 1404
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a;
	int count;
	int ccount;
	vector<int> c = { 0 };
	while (cin >> a)
	{
		a = a + 1;
		count = 0;
		/*
		// ?´???°?????????
		// ??????????????°
		for (size_t i = 2; i < a; i++)
		{
			ccount = 0;
			// ????????°
			for (size_t j = 1; j <= i; j++)
			{
				//cout << "i= " << i << "j= " << j << endl;
				if (i % j == 0) {
					ccount++;
				}
			}
			if (ccount > 2) {
				count++;
			}
		}*/
		// ?????§????????§????????????0??§???????????????
		c.resize(a);

		
		// 2*i????????§????????§?????????????????????1?????????
		for (size_t i = 2; i < a; i++)
		{
			for (size_t j = 2; i*j < a; j++)
			{
				//cout << i*j << endl;
				c[i*j] = 1;
			}
		}
		// ??????????????????0??????????????°????????????
		for (size_t i = 0; i < a; i++)
		{
			if (c[i] == 0) {
				count++;
			}
		}
		cout << count-2 << endl;

		// ?¢??????¨
		/*
		for (size_t i = 0; i < a; i++)
		{
			cout << i << " = " << c[i] << endl;
		}
		*/
		
	}
	return 0;
}

Measured memory_bytes: 8300
import sys
import math
import itertools
N,M=map(int,input().split())
result=[[0]*2 for _ in range(N)]
AC=0
pena=0
for _ in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        if result[p-1][1]==0:
            AC+=1
            result[p-1][1]=1
    else:
        if result[p-1][1]==0:
            result[p-1][0]+=1
for i in range(N):
    if result[i][1]==1:
        pena+=result[i][0]
print(AC,pena)

Measured memory_bytes: 13300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S; cin >> S;
    if(S.size() == 26){
        auto T = S;
        if(!next_permutation(T.begin(), T.end())){
            cout << -1 << endl;
        } else {
            for(int i=0;i<26;i++){
                cout << (char)T[i];
                if(T[i] != S[i]) break;
            }
            cout << endl;
        }
    } else {
        cout << S;
        for(int i=0;i<26;i++){
            if(S.find('a'+i) == string::npos){
                cout << (char)('a'+i) << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


#define MAX_V 1000000
struct edge{
    int to,cap,rev;
};

vector<vector<edge>> G(MAX_V);
bool used[MAX_V];

void add_edge(int from,int to,int cap){
    edge F;
    edge T;
    F.to = to;
    F.cap = cap;
    F.rev = G[to].size();
    G[from].push_back(F);

    T.to = from;
    T.cap = 0;
    T.rev = G[from].size()-1;
    G[to].push_back(T);
}

int dfs(int v,int t,int f){
    if(v == t) return f;
    used[v] = true;
    for(int i=0; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] and e.cap > 0){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s,t,inf);
        if(f == 0) return flow;
        flow += f;
    }
}


int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    vector<bool> last(26,false);
    for(int i=0; i<N; i++){
        last[S[i].back()-'a'] = true;
    }
    for(int c=0; c<26; c++){
        if(!last[c]) continue;
        int s=26,t=27;
        int cnt = 0;
        memset(used,0,sizeof(used));
        for(int i=0; i<30; i++){
            G[i].clear();
        }
        for(int i=0; i<N; i++){
            int u = (S[i].front() == c+'a') ? s : (S[i].front()-'a');
            int v = (S[i].back() == c+'a') ? t : (S[i].back()-'a');
            // cout << u << " " << v << enld;
            add_edge(u,v,1);
            if(S[i].front() == c+'a') cnt++; 
        }
        // cout << G[s].size() << enld;
        int flow = max_flow(s,t);
        // cout << "check:" << char(c+'a') << " " << flow << " " << cnt << enld;
        if(flow == cnt){
            cout << char(c+'a') << enld;
        }
    }
    return 0;
}


Measured memory_bytes: 29584
import java.util.*;
 
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int M = s.nextInt();

        if(N == M){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
	}
} 

Measured memory_bytes: 23892
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define REP(i,n) for(i=0;i<(n);++i)
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}

bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i==0)
			return false;
	}
	return (num < 2) ? false : true;
}

bool check(int num) {
	return (sosuu_check(num) && sosuu_check((num+1)/2)) ? true : false;
}

int main() {
	int Q, l, r, rmax = 0, i,j;
	vector<int> vec(100001);
	ll ans = LL_MAX, sum;
	cin >> Q;
	vec[0] = 0;
	for(i=0;i<Q;++i){
//	REP(i, Q) {
		cin >> l >> r;
		if (r > rmax) {
			FOR(j, rmax + 1, r + 1) {
//				cout << i << endl;
				vec[j] = check(j) ? vec[j - 1] + 1 : vec[j - 1];
//				cout << vec[i] << endl;
			}
			rmax = r;
		}
		ans = vec[r] - vec[l];
		ans += check(l) ? 1 : 0;
		cout << ans << endl;
	}
}

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

int main(){
  int x,y;
  char s[100];
  int st[200],sp;
  sp = 0;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
		x = st[--sp];
		y = st[--sp];
		st[sp++] = y + x;
    } else if ( s[0] == '-' ){
		x = st[--sp];
		y = st[--sp];
		st[sp++] = y - x;
    } else if ( s[0] == '*' ){
		x = st[--sp];
		y = st[--sp];
		st[sp++] = y * x;
    } else {
      x = atoi(s);
	  st[sp++] = x;
    }
  }
  printf("%d\n", st[--sp]);

  return 0;
}

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

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

#define INF 1000000000

int dp[5][40000];

int main(){
    fill(dp[0],dp[5],0);
    rep(i,4)dp[i][0]=1;
    repl(i,1,200) rep(k,4) rep(j,40000-i*i) dp[k+1][j+i*i] += dp[k][j];

    int n;
    while(cin>>n ,n){
        cout<<dp[4][n]<<endl;
    }

    return 0;
}

Measured memory_bytes: 1940
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(30, 100), 100)

    def test_2(self):
        self.assertEqual(think(12, 100), 50)

    def test_3(self):
        self.assertEqual(think(0, 100), 0)


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    if a <= 5:
        return 0
    elif a <= 12:
        return b // 2
    return b


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int K, X;
    cin >> K >> X;
    string sp = "";
    FOR (i, X - K + 1, X + K) {
        cout << sp << i;
        sp = " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


int main(){
    int n,m;
    char hen[100][2],c;
    while(1){
    scanf("%d\n",&n);
    if(n==0) break;
    for(int i=0;i<n;i++){
        scanf("%c %c\n",&hen[i][0],&hen[i][1]);
    }
    
    scanf("%d\n",&m);
    
    for(int i=0;i<m;i++){
        scanf("%c\n",&c);
        for(int j=0;j<n;j++){
            if(c==hen[j][0]){
                c=hen[j][1];
                break;
            }
        }
        printf("%c",c);
    }
    
    printf("\n");
    }
    return 0;
    
}

Measured memory_bytes: 1164
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int X,Y;
int H[305],S[205];
signed main(){
    scanf("%lld %lld",&X,&Y);
    int ans=0;
    if(X==1)ans+=300000;
    if(Y==1)ans+=300000;
    if(X==2)ans+=200000;
    if(Y==2)ans+=200000;
    if(X==3)ans+=100000;
    if(Y==3)ans+=100000;
    if(X==1&&Y==1)ans+=400000;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void){
    int n, m, a, b;cin >> n >> m;
    int test[101]={0};int uiop[101]={0};int hjkl[101]={0};
    for(int h=0;h<m;h++){
       cin>>a;
       test[h] = a;
    }
    for(int h=0; h<m;h++){
       for(int i=1;i<=n;i++){
           cin>>b;
           uiop[i]=b;
       }
       for(int i=1;i<=n;i++){
           if(i == test[h]){
             hjkl[i]++;
           }
           else if(uiop[i]==test[h]){
             hjkl[i]++;
           }
           else {
             hjkl[test[h]]++;
           }
       }
    }
    for(int h=1; h<=n;h++){
        cout<<hjkl[h]<<endl;
    }
}



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

m, d = wi()

for i in range(1, m + 1):
    for j in range(20, d + 1):
        if int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2:
            if int(str(j)[0]) * int(str(j)[1]) == i:
                ans += 1
print(ans)

Measured memory_bytes: 66416
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int a,b,c;
   cin >> a >> b >> c;

   int ans = min({a+b,a+c,b+c});
   cout << ans << endl;


   return 0;
}

Measured memory_bytes: 256
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
#define F first
#define pii pair<int,int>
#define S second
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
#define mod 1000000007
#define pb push_back
const long long INF = 1000000000000000000LL;
//const int WASTE=∞
const int N=1e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  	// cout<<fixed;
  	// cout.precision(10);
   	// ofstream cout (".out");
    // ifstream cin  (".in");
	int n;
	cin>>n;
	int a[n],b[n];
	for(int x=0;x<n;x++) cin>>a[x]>>b[x];
	bool f=0;
	for(int x=2;x<n;x++){
		if(a[x]==b[x]&&a[x-1]==b[x-1]&&a[x-2]==b[x-2]) f=1;
	}
	cout<<(f?"Yes":"No");
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
  	return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<string.h>
#include<cstring>
#define pb push_back
#define FAST ios::sync_with_stdio(0);cin.tie(),cout.tie();
typedef long long ll;
//const long double pi = acos(-1.0);
//const int mod = 1e9+7;
using namespace std;
int main()
{
    FAST
    ll t,i;
//    cin>>t;
//    for(i=1;i<=t;i++)
//    {
        int a,b,c;
    cin>>a>>b>>c;
    //swap(a,c);
    //swap(a,b);
    cout<<c<<" "<<a<<" "<<b<<endl;
    //}
    return 0;
}


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m];
  REP(i, n)REP(j, m) cin >> a[i][j];
  REP(i, m) cin >> b[i];
  REP(i, n){
    int x = 0;
    REP(j, m) x += a[i][j]*b[j];
    cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))
Y = []
for i in range(n):
    tmp = t - H[i]*0.006
    Y.append(abs(tmp-a))
miny = Y[0]
for item in Y:
    miny = min(miny, item)
res = Y.index(miny)
print(res+1)

    

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	int N;
	map<int, int>mp;
	cin >> N;
	vector<int>a(N);
	rep(i, N) {
		cin >> a[i];
		mp[a[i]]++;
	}
	int ans = 0;
	rep(i, N) {
		if(mp[a[i]] < a[i]){
			ans += mp[a[i]];
			mp[a[i]] = 0;
		}
		else {
			ans += abs(mp[a[i]] - a[i]);
			mp[a[i]] = a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;


string a, b;
int main() {
    cin >> a >> b;
    int ans = 0;
    rep (i, 0, 2) ans += (a[i] == b[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	while (1){
		scanf("%d %d", &a, &b);
		
		if ((a < b) || (a == b)){
			if ((a == 0) && (b == 0)){
				break;
			}
			printf("%d %d\n", a, b);
			}
			else if (a > b){
				printf("%d %d\n", b, a);
			}
	}
	
	return (0);
}

Measured memory_bytes: 600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NR = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine(9 < NR[0] ? NR[1] : NR[1]+(100 * (10 - NR[0])));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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

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

   int a[3];
   cin >> a[0] >> a[1] >> a[2];
   sort(a, a+3);
   cout << a[2] * 10 + a[1] + a[0] << endl;

   return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
mod=998244353

dp=[[0]*(d+1) for i in range(c+1)]
for i in range(1,c+1):
  for j in range(1,d+1):
    if i>=a and j>=b:
      if i==a and j==b:
        dp[i][j]=1
      else:
        dp[i][j]=(dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%mod
print(dp[i][j])

Measured memory_bytes: 134060
import sys
def input(): return sys.stdin.readline().strip()
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

x, y, a, b, c = MAP()
p = LIST()
q = LIST()
r = LIST()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pq = p[:x] + q[:y]
pq.sort()
pqsum = 0
rsum = 0
d = 0
for i in range(min(c, x + y)):
    pqsum += pq[i]
    rsum += r[i]
    if rsum - pqsum > d:
        d = rsum - pqsum
print(sum(pq) + d)

Measured memory_bytes: 23328
#   AtCoder abc083 a
#   ストレッチ課題

#   入力
a, b, c, d = map(int, input().split())

#   判定
diff = (a + b) - (c + d)
if diff == 0:
    print("Balanced")
elif diff > 0:
    print("Left")
else:
    print("Right")


Measured memory_bytes: 9084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long N = sc.nextLong();
		int K = sc.nextInt();
		for(int i = 0; i < 40; i ++) {
			long pow = (long)Math.pow(K, i);
			if(N < pow) {
				pw.print(i);
				break;
			}
		}
		pw.close();
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 21204
# https://atcoder.jp/contests/abc117/tasks/abc117_d
N, upper_bit = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
beki_ary = (1..39).to_a.each_with_object([1]) { |i, obj| obj << (obj.last * 2)}
already_min = false

ans = 0
mask = 1 << 40
39.step(0, -1) do |digest|
  mask = mask >> 1
  ones = A.count { |str| (str & mask) > 0 }
  if ones * 2 >= N
    already_min = true if upper_bit[digest] == 1
    ans += beki_ary[digest] * ones
  else
    if already_min || (upper_bit[digest] == 1)
      ans += beki_ary[digest] * (N - ones)
    else
      ans += beki_ary[digest] * ones
    end
  end
end
p ans


Measured memory_bytes: 8844
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
ll tmp;
cin>>tmp;
if(tmp==1){
cout<<"Hello World"<<endl;


  return 0;
}
ll A,B;
cin>>A>>B;
cout<<A+B<<endl;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split(' '))
    s = input()

    happiness = 0
    for i in range(n-1):
        if s[i:i+2] in ['LL', 'RR']:
            happiness += 1
    
    ope = 0
    while ope < k:
        happiness += 2
        ope += 1
    print(min(n-1, happiness))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

typedef pair<int,int> P;
ll manhattan(const P &a,const P &b){return llabs(a.first-b.first)+llabs(a.second-b.second);}
int main(){
    int H,W,D;cin>>H>>W>>D;
    vector<vector<int>> A(H,vector<int>(W));
    map<int,pair<int,int>> mp;
    REP(i,H) REP(j,W){
        cin>>A[i][j];
        mp[A[i][j]]=make_pair(i,j);
    }
    vector<int> dp(H*W+1);
    REP(i,H*W-D){
        int c=manhattan(mp[i+1],mp[i+D+1]);
        dp[i+D+1]=dp[i+1]+c;
    }
    int Q;cin>>Q;
    REP(_,Q){
        int L,R;
        cin>>L>>R;
        cout<<dp[R]-dp[L]<<endl;
    }
}


Measured memory_bytes: 7424