akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
  int n, m, s, c, ans = 0;
  int d[3] = {10, 10, 10};
  
  scanf("%d%d", &n, &m);
  
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &s, &c);
    if (d[s-1] == 10)
      d[s-1] = c;
    else if (d[s-1] != c) {
      ans = -1;
      break;
    }
  }
  
  if (n == 1) {
    if (ans == 0) {
      if(d[0] == 10)
        d[0] = 0;
      ans = d[0];
    }
    printf("%d", ans);
    return 0;
  }
  
  if (d[0] == 0)
    ans = -1;
  
  if (ans == 0) {
    if (d[0] == 10)
      d[0] = 1;
    if (d[1] == 10)
      d[1] = 0;
    if (d[2] == 10)
      d[2] = 0;
    for (int i = 0; i < n; i++) {
      ans *= 10;
      ans += d[i];
    }
  }
  
  printf("%d", ans);
  
  return 0;
}


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

long long n, m;
vector<vector<long long>> edge;
vector<long long> ans, dp;
vector<bool> reachd;

void solve();
long long dfs(long long now);
void dfs2(long long now);

int main() {
  cin >> n >> m;
  edge.resize(n, vector<long long>());
  for(int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  solve();
  for(int i = 0; i < n; ++i) cout << ans[i] << endl;
  return 0;
}

void solve() {
  ans.resize(n);
  dp.resize(n);
  reachd.assign(n, 0);
  dfs(0);
  reachd.assign(n, 0);
  dfs2(0);
}

long long dfs(long long now) {
  reachd[now] = 1;
  long long res = 1;
  for(long long to : edge[now])
    if(!reachd[to]) (res *= dfs(to) + 1) %= m;
  return dp[now] = res;
}

void dfs2(long long now) {
  reachd[now] = 1;
  long long res = 1, esize = edge[now].size(), bf = dp[now];
  for(long long to : edge[now]) (res *= dp[to] + 1) %= m;
  ans[now] = res;
  vector<long long> pre, suf;
  pre.assign(esize, 0);
  suf.assign(esize, 0);
  for(int i = 0; i < esize; ++i) {
    long long to = edge[now][i];
    if(i != 0) {
      pre[i] = pre[i - 1];
      suf[esize - 1 - i] = suf[esize - i];
    }
    else
      pre[i] = suf[esize - 1] = 1;
    (pre[i] *= dp[to] + 1) %= m;
    (suf[esize - 1 - i] *=
     dp[edge[now][esize - 1 - i]] + 1) %= m;
  }
  for(int i = 0; i < esize; ++i) {
    long long to = edge[now][i];
    if(!reachd[to]) {
      dp[now] = 1;
      if(i != 0) (dp[now] *= pre[i - 1]) %= m;
      if(i != esize - 1) (dp[now] *= suf[i + 1]) %= m;
      dfs2(to);
    }
  }
  dp[now] = bf;
}

Measured memory_bytes: 24192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;


public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayDeque<String> stack = new ArrayDeque<String>();
		String str;

		while((str=br.readLine()) != null){

			if(str.equals("0")){
				try{
					System.out.println(stack.pop());
				}catch(NoSuchElementException e){
					e.printStackTrace();
				}
			}else if(!str.equals("0")){
				stack.push(str);
			}

		}

	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int a, b, t;
  cin >> a >> b >> t;
  int ans = 0;
  for (int i = 1; i <= t; i++){
    if (i % a == 0){
      ans += b;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, m = LI()
    print((n-1)*(m-1))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

bool comp(ii a,ii b){
    if(a.fi!=b.fi)return a.fi<b.fi;
    return a.se>b.se;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    deque<ii>v;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        v.pb(mp(a,b));
    }
    sort(all(v),comp);
    //for(auto x:v)cout<<x.fi<<" "<<x.se<<"\n";
    priority_queue<ll>q;
    ll sum=0;
    for(int i=1;i<=m;i++){
        while(v[0].fi==i){
            q.push(v[0].se);
            v.pop_front();
        }
        if(q.size()){
            sum+=q.top();
            q.pop();
        }
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  if (a<10 && b<10) {
    c=a * b;
    cout << a * b << endl;
  }
  else {
    c=-1;
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N; cin >> N;
    LL ans = 0;
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }



    for(LL i = 1; i * i <= N; i++){
        if((N-i)%i != 0) continue;
        LL tmp = (N-i)/i;
        if(N/tmp == N%tmp){
            ans += tmp;
        }
    }
    cout << ans << endl;



}

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

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

    vector<int64_t> lucas(87, 0);
     
     for (int i=0; i<=N; ++i) {
         if (i==0) lucas.at(i) = 2;
         else if (i==1) lucas.at(i) = 1;
         else lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
     }
     cout << lucas.at(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int N, K;
	std::cin >> N >> K;

	std::vector<int> v( N );
	for ( int i = 0; i < N; i++ )
	{
		std::cin >> v[i];
	}

	std::sort( v.begin(), v.end() );

	int diff = 1e9 + 1;
	for ( int i = 0; i < N - K + 1; i++ )
	{
		if ( diff > ( v[i + K - 1] - v[i] ) )
		{
			diff = v[i + K - 1] - v[i];
		}
	}

	std::cout << diff << std::endl;

	return ( 0 );
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef string::const_iterator State;
class ParseError {};

string s, t;
string Cipher(State &begin);
string String(State &begin);
string Letter(State &begin);
 
string Cipher(State &begin){
    // cout << *begin << endl;
    string ret = "";
    if(*begin == ']') return ret;
    if(begin >= s.end()) return ret;
    ret += String(begin);
    if(begin >= s.end()) return ret;    
    ret += Cipher(begin);
    return ret;
}
 
string String(State &begin){
    string ret = "";
    if(*begin == '['){
        begin++;
        ret += Cipher(begin);
        begin++;
        reverse(ret.begin(), ret.end());
    }else{
        ret += Letter(begin);
    }
    return ret;    
}

string Letter(State &begin){
    string ret = "";
    if(*begin == '+'){
        begin++;
        string tmp = Letter(begin);
        char now = 'A' + (tmp[0] - 'A' + 1) % 26;
        ret += now;
    }else if(*begin == '-'){
        begin++;
        string tmp = Letter(begin);
        char now = 'A' + (tmp[0] - 'A' + 25) % 26;
        ret += now;
    }else{
        ret += *begin;
        begin++;
    }
    return ret;
}

vector<string> vs;
void dfs(int k, string now){
    if(k == t.size()) vs.push_back(now);
    else if(t[k] != '?') dfs(k + 1, now + t[k]);
    else{
        for(int i = 0; i < 26; i++) dfs(k + 1, now + (char)('A' + i));
    }
}

int main(){
    while(1){
        cin >> t;
        if(t == ".") break;
        vs.clear();
        dfs(0, "");
        vector<string> ans; 
        for(int i = 0; i < vs.size(); i++){
            s = vs[i];
            State begin = s.begin();
            string tmp = Cipher(begin);
            ans.push_back(tmp);
        }
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    }
}


Measured memory_bytes: 8040
n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    evn = Counter(A[::2])
    odd = Counter(A[1::2])

    a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)
    b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)

    ac = (n // 2) - a[0][1]
    bc = (n // 2) - b[0][1]
    ret = ac + bc
    if a[0][0] == b[0][0]:
        bc_2 = n // 2 - (b[1][1] if len(b) != 1 else 0)
        ac_2 = n // 2 - (a[1][1] if len(a) != 1 else 0)
        ret = min(ac + bc_2, ac_2 + bc)
    return ret
print(f())

Measured memory_bytes: 18592
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>b[i];
  rep(i,0,n-1) cin>>c[i];
  int sat=b[a[0]-1];
  
  rep(i,1,n){
    sat+=b[a[i]-1];  
    if(a[i]-a[i-1]==1) sat+=c[a[i-1]-1];
  }
  cout<<sat;

      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,cnt=0; cin>>n;
	vector<ll> p(n),q(n);
	for(auto& it:p)cin>>it;
	for(auto& it:q)cin>>it;
	if(p>q)swap(p,q);
	while(p<q){
		++cnt;
		next_permutation(p.begin(), p.end());
	}
	cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int a[200005], b[200005];
int n, ans;
 
int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%d", a+i);
	for (int i = 0;i < n;i++) scanf("%d", b+i);
	for (int v = (1<<28);v;v>>=1)
	{
		for (int i = 0;i < n;i++) a[i] &= (v*2-1);  // 从28位开始，取二进制的后几位 
		for (int i = 0;i < n;i++) b[i] &= (v*2-1);
		sort(a, a+n); sort(b, b+n);
		int t = 0;
		// 考虑a[i]和b[i]剩余的最高位，设为第k位 
		for (int i = n-1, j = 0, k = 0, l = 0;i >= 0;i--)
		{
			while (j < n && a[i]+b[j] < v) j++;  	// 和的第k位为0  
			
			while (k < n && a[i]+b[k] < 2*v) k++;   // 和的第k位为1 
			
			while (l < n && a[i]+b[l] < 3*v) l++;   // 和的第k位为0，且有进位 
			t += k-j+n-l;
			t &= 1;
		}
		if (t) ans |= v;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    S = readline().rstrip()
    e_right = S.count('E')
    w_left = 0
    res = N
    
    for i in range(N):
        if S[i] == 'E':
            e_right -= 1
            res = min(res, e_right + w_left)
        else:
            res = min(res, e_right + w_left)
            w_left += 1
    
    print(res)

if __name__ == '__main__':
    main()

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e5+1;
map <int, int> dp[N];
vector <int> a[N];
int n, c[N], sub[N];
long res[N];

void dfs(int p, int u){
  for (int v : a[u]){
    if (v == p) continue;
    dfs(u, v);
    int cur = sub[v]; 
    sub[u] += sub[v];
    if (dp[v][c[u]]) cur -= dp[v][c[u]];
    res[c[u]] -= 1ll * cur * (cur + 1) / 2;
    if (dp[u].size() < dp[v].size()) swap(dp[u], dp[v]);
    for (auto x : dp[v]) dp[u][x.first] += x.second;
  }
  sub[u]++; dp[u][c[u]] = sub[u];
}

int main()
{
  fastio;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i < n; i++){
    int u, v; cin >> u >> v;
    a[u].push_back(v); a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) res[i] = 1ll * n * (n + 1) / 2;
  dfs(0, 1);
  for (int i = 1; i <= n; i++){
    int cur = n - dp[1][i];
    res[i] -= 1ll * cur * (cur + 1) / 2;
    cout << res[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 73216
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
int main(){
  mp::cpp_dec_float_100 A, B, C;
  cin >> A >> B >> C;
  if(mp::sqrt(A) + mp::sqrt(B) < mp::sqrt(C)) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;


int main() {
    double n,k,ans;cin>>n>>k;
    ans =0.0;
    for(int i=1; i<=n; i++){
        ll point =i;
        int p=0;
        while(point<k){
            point*=2;
            p++;
        }
        ans+=(1/n)*pow(0.50,p);
    }
    cout<<fixed<<setprecision(15)<<ans<<endl; 
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

int main(){
  int a,b; 
  char s[50];
  cin >> a >>b >> s;
  s[b-1] +=32;
  cout << s << endl;


  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
fn main() {
    let n: usize = read();

    let mut vec: Vec<Vec<(usize, usize)>> = vec![];

    for _ in 0..n {
        let a: usize = read();
        let mut v = vec![];
        for _ in 0..a {
            let x: usize = read();
            let y: usize = read();
            v.push((x, y));
        }
        vec.push(v);
    }

    let mut ans = vec![0];

    'top: for bit in 0..1 << n {
        let bit = (0..n).map(|k| (bit >> k) & 1 == 1).collect::<Vec<bool>>();
        for (i, &b) in bit.iter().enumerate() {
            if b {
                for &(x, y) in &vec[i] {
                    let m = if y == 0 { false } else { true };
                    if bit[x - 1] != m {
                        continue 'top;
                    }
                }
            }
        }
        ans.push(bit.iter().filter(|&&k| k).count());
    }

    println!("{}", ans.iter().max().unwrap());
}

fn bit_search(n: usize) -> Vec<Vec<bool>> {
    let mut vec = Vec::with_capacity(2usize.pow(n as u32));
    for b in 0..1 << n {
        vec.push((0..n).map(|k| (b >> k) & 1 == 1).collect());
    }
    vec
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
const int M = 1e9 + 7;

ll mul(ll a, ll b) { return (a*b)%M; }
ll mod_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b&1) r = mul(r, a);
    b >>= 1;
    a = mul(a, a);
  }
  return r;
}
struct combination {
  vector<int> fact, ifact;
  combination(int n):fact(n+1), ifact(n+1) {
    assert(n < M);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = mul(fact[i-1], i);
    ifact[n] = mod_pow(fact[n], M-2);
    for (int i = n; i >= 1; --i) ifact[i-1] = mul(ifact[i], i);
  }
  int operator()(int n, int k) {
    assert(k >= 0 && k <= n);
    return mul(fact[n], mul(ifact[k], ifact[n-k]));
  }
} C(2000005);

void solve() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = mod_pow(25, i);
    now = (now * mod_pow(26, k-i)) % M;
    now = (now * C(n-1+i, n-1)) % M;
    ans = (ans + now) % M;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}

Measured memory_bytes: 19876
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int imos(vector<int> &num){
	vector<int>cnt(num.size()+5);
	int maxv=0;
	cnt[0]=num[0];
	if(cnt[0]<0)cnt[0]=0;
	for(int i=1;i<num.size();++i){
		cnt[i]=cnt[i-1]+num[i];
		maxv=max(maxv,cnt[i]);
	}
	return maxv;
}


signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	string s;
	cin>>s;
	if(s[0]=='S')cout<<"Cloudy"<<endl;
	else if(s[0]=='C')cout<<"Rainy"<<endl;
	else cout<<"Sunny"<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        int n;
        long x;
        string[] s;
        s = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(s[0]);
        x = long.Parse(s[1]);

        F y = new F();
        long ans = y.recur(n,x);
        
        Console.WriteLine(ans);
    }
}

class F
{
    public F()
    {
    }
    public long recur(int n, long x)
    {
        long y = 0;
        if (n == 0) return 1;
        long a = (long)Math.Pow(2, n) - 1;
        long s = (long)Math.Pow(2, n + 1) - 3;
        if (x == 1) y = 0;
        else if (x < s + 2) y = recur(n - 1, x - 1);
        else if (x == s + 2) y = 1 + a;
        else if (x < s * 2 + 3) y = 1 + a + recur(n - 1, x - s - 2);
        else if (x == s * 2 + 3) y = 1 + a * 2;
        return y;
    }


}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
	int l,r,d;
    cin>>l>>r>>d;
  	int cnt=0;
  	for(int i=l;i<=r;i++){
    	if(i%d==0)
          cnt++;
    }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9+7;

int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll x,i,j;
    cin>>x;
    for(i=-1000;i<=1000;++i){
    	for(j=-1000;j<=1000;++j){
    		if(pow(i,5) - pow(j,5) == x){
    			cout<<i<<" "<<j<<"\n";
    			return 0;
    		}
    	}
    }

    
#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}

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

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

    int n;
    cin >> n;
    int result = n;
    while (result % 2 != 0 || result % n != 0) {
        result++;
    }
    cout << result;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val st = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
    val s = st.map { it[0] }.toIntArray()
    val t = st.map { it[1] }.toIntArray()

    var a=s[0].toLong()
    var b=t[0].toLong()

    for(i in 1..n-1) {
        val r = 1+Math.max((a-1)/s[i],(b-1)/t[i])
        a = s[i]*r
        b = t[i]*r
    }
    println(a+b)
}

Measured memory_bytes: 36244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=110;
char a[N][N];
int n,m,dp[N][N]; 
int main()
{//char x;cin>>x;cout<<x<<endl;
	cin>>n>>m;memset(dp,0x3f,sizeof(dp));dp[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];//dp[i][j]=1e9;
			int k;if(a[i][j]=='.')k=0;else k=1;
			if(k&&a[i][j-1]!='#')dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			else dp[i][j]=min(dp[i][j-1],dp[i][j]);
			if(k&&a[i-1][j]!='#')dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			else dp[i][j]=min(dp[i-1][j],dp[i][j]);
			//cout<<dp[i][j]<<" ";
		}	//puts("");
	}cout<<dp[n][m];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint f[201010];

modint nCr(int n, int r){
    if(n < r) return 0;
    return f[n] / (f[r] * f[n-r]);
}

int main(){
    int n, k;
    cin >> n >> k;
    f[0] = 1;
    rep(i, 200000) f[i+1] = f[i] * (i+1);
    rep1(i, k+1){
        cout << nCr(n-k+1, i)*nCr(k-1, i-1) << endl;
    }

}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,x,y=map(int,input().split())
    x-=1
    y-=1
    ans=[0]*n
    for i in range(n-1):
        for j in range(i+1,n):
            ans[min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))]+=1
    for a in ans[1:]:
        print(a)


if __name__=='__main__':
    main()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
  cout << a*a-b << endl;
    return 0;
}


Measured memory_bytes: 256
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
#
# if XW[0][1]==1:
# 	for i in range(1,N):
# 		if XW[i][0]<XW[0][0]:
# 			count+=int((XW[0][0]-XW[i][0])/L)+1
# else:
# 	for i in range(1,N):
# 		if XW[i][0]>XW[0][0]:
# 			count+=int((XW[i][0]-XW[0][0])/L)+1

#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)


Measured memory_bytes: 23160
#include <bits/stdc++.h>
using namespace std;
int main() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if( (b < 0 && c > 0) || (a > 0 && d < 0) ) {
    cout << max( a*d, b*c ) << endl;
  }
  else {
    cout << max( a*c, b*d ) << endl;
  }
}

Measured memory_bytes: 3620
# include <iostream>
using namespace std;
int main()
{
  int n,s=0,flag=0;
  cin>>n;
  int a=n;
  while(!flag){
    if(!(a/10)){flag++;}
    s+=a%10;
    a/=10;
  }
  if(!(n%s)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}


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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<string> > C;
    C.resize(H);
    
    for(int i=0;i<H;i++){
        C[i].resize(W);
        for(int j=0;j<W;j++){
            cin >> C[i][j];
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << C[i][j] << endl;
            cout << C[i][j] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int n,k;
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>k>>s;
	s[k-1]=tolower(s[k-1]);
	cout<<s;
	return 0;
}

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A(MAXN, 0);

void soinnsuu(){
    for(int i=2;i*i<=N;i++) {
        if(N%i==0) {
            int ct=0;
            while(N%(ll)pow(i,ct+1)==0) {
                N/=pow(i,ct+1);
                ct++;
            }
            while(N%i==0) {
                N/=i;
            }
            ans += ct;
        }
    }
    if(N!=1) {
        ans++;
    }
}

signed main(){
    cin >> N;
    soinnsuu();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4620
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int l, m, n;
		int i, ct;
		
		while ((l = input.nextInt()) != 0){
			ct = 0;
			for (i = 0; i < 12; i++){
				m = input.nextInt();
				n = input.nextInt();
				if (l > 0){
					l -= (m - n);
					ct++;
				}
			}
			if (l > 0){
				System.out.println("NA");
			}
			else {
				System.out.println(ct);
			}
		}
	}
}

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

#define ll long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int main() {
    string s;
    cin >> s;
    int N = s.size();

    int ans = 999;
    FOR(i, N - 2) {
        istringstream(s.substr(i, 3)) >> t;
        ans = min(ans, abs(753 - t));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

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

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
ll p(ll a, ll mod) {
    ll res = 1;
    FOR(i, 1, a + 1) {
        res *= modinv(i, mod);
        res %= mod;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);


    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i <= X + K - 1; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int n,tot,rt,x[N],y[N],d[N],f[N],head[N],nex[N<<1],to[N<<1];
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
    to[++tot]=u;nex[tot]=head[v];head[v]=tot;
}
priority_queue<int>q;
struct node
{
    int u,d;
    node(int u=0,int d=0):u(u),d(d){}
    bool operator<(const node&o)const
    {
        return d<o.d;
    }
};
priority_queue<node>s;
bool vis[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        add(x[i],y[i]);
        d[x[i]]++;
        d[y[i]]++;
    }
    for(int i=1;i<=n;i++)
        if(d[i]>d[rt]) rt=i;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        q.push(x);
    }
    s.push(node(rt,d[rt]));
    vis[rt]=true;
    while(!s.empty())
    {
        node now=s.top();s.pop();
        int u=now.u;
        f[u]=q.top();
        q.pop();
        for(int i=head[u];i;i=nex[i])
        {
            int v=to[i];
            if(vis[v]) continue;
            vis[v]=true;
            s.push(node(v,d[v]));
        }
    }
    int ans=0;
    for(int i=1;i<n;i++)
        ans+=min(f[x[i]],f[y[i]]);
    printf("%d\n",ans);
    for(int i=1;i<=n;i++)
        printf(i==n?"%d\n":"%d ",f[i]);
}


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

int main(){
  string s;
  cin>>s;
  int ans=4;
  if(s[0]=='-')ans-=2;
  if(s[1]=='-')ans-=2;
  if(s[2]=='-')ans-=2;
  if(s[3]=='-')ans-=2;
  cout<<ans<<endl;
}


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

int main(){

    int a;
    cin>>a;
    string ans;
    a%=10;
    if(a==2||a==4||a==5||a==7||a==9) ans="hon";
    else if(a==3) ans="bon";
    else ans="pon";
    cout<<ans<<endl;


    return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c;
    std::string s, t, u;

    cin >> a >> s >> b;
    if(s=="+") P(a+b);
    else P(a-b);

    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
 int N,D;
 cin>>N>>D;
 int X[N][D];
 for(int i=0;i<N;i++){
     for(int j=0;j<D;j++){
         cin>>X[i][j];
     }
 } 
 int count=0;
 for(int i=0;i<N;i++){
    for(int k=i+1;k<N;k++){
      int sum=0;
     for(int j=0;j<D;j++){
      int T=X[i][j]-X[k][j];
      sum+=T*T;
     }
     int q=sqrt(sum);
     if(q*q==sum){count++;}
 }
 }
 cout<<count<<endl;
 return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};

int main() {
	ll N, Q;
	string S;
	cin >> N >> Q>>S;
	vector<ll>l(Q), r(Q);
	rep(i, 0, Q) {

		cin >> l[i] >> r[i];
	}
	vector<ll>key;
	key.push_back(0);
	rep(i, 1, N) {
		if (S[i] == 'C' && S[i - 1] == 'A') {
			key.push_back(key[i - 1] + 1);
		}else{
			key.push_back(key[i - 1]);
		}

	}
	rep(i, 0, Q) {
		
			cout << key[r[i] - 1] - key[l[i] - 1] << endl;
		
	}

}

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

using namespace std;

string T;

int main(void) {

	cin >> T;

	int N = T.size();

	string ans = "";

	for (int i = 0; i < N; i++) {
		if (T[i] == '?') { ans += 'D'; }
		else { ans += T[i]; }
	}

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

Measured memory_bytes: 3456
n, k = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)

arr = []
(n - k + 1).times do |i|
  arr.push(x[i].abs + (x[i + k - 1] - x[i]).abs)
  arr.push(x[i + k - 1].abs + (x[i + k - 1] - x[i]).abs)
end
p arr.min


Measured memory_bytes: 10372
from fractions import gcd
def main():
    n, m = map(int, raw_input().split())
    s = raw_input().strip()
    t = raw_input().strip()
    g = gcd(n, m)
    l = n * m / g
    a = l / n
    b = l / m
    d = {}
    for i, x in enumerate(s):
        d[i*a] = x
    for i, x in enumerate(t):
        if i * b in d and d[i*b] != x:
            print -1
            return
    print l
main()


Measured memory_bytes: 15328
<?php

fscanf(STDIN,"%d %d",$n,$m);
$ans = array_fill(0,$n,0);

for ($i=0; $i < $m; $i++) {
    fscanf(STDIN,"%d %d",$a,$b);
    $ans[$a-1]++;
    $ans[$b-1]++;
}

for ($i=0; $i < $n; $i++) {
    echo $ans[$i].PHP_EOL;
}


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
string s;

int main(){
	fast_io();
	cin >> s;
	int n = s.length();
	fu(i,'a','z'){
		cu(j,0,n-2){
			int cnt = 0;
			cu(l,0,3){
				cnt += s[j + l] == i;
			}
			if(cnt >= 2){
				cout << j + 1 << ' ' << j + 3 << endl;
				return 0;
			}
		}
		cu(j,0,n-1){
			if(s[j] == s[j+1]){
				cout << j + 1 << ' ' << j + 2 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef complex<long double> cd;

const int maxn = 5e5 + 5;
const ll inf = 1e18;

pll dp1[maxn], dp2[maxn];
ll cost[maxn], x[maxn];
int near[maxn], c[maxn], par[maxn], root[maxn];
vector<pair<int, int> > t[maxn];
ll answer = 0;

int get_par(int v){
	return par[v] < 0 ? v : par[v] = get_par(par[v]);
}

void merge(int v, int u, ll w){
	if ((v = get_par(v)) == (u = get_par(u)))
		return;
	answer += w;
	if (par[v] > par[u])
		swap(v, u);
	par[v] += par[u];
	par[u] = v;
}

pll rev(pll a){
	return make_pair(a.second, a.first);
}

pair<pll, pll> mergepairs(pll a, pll b, pll c, pll d){
	vector<pair<ll,ll> > v = {rev(a), rev(b), rev(c), rev(d)};
	sort(v.begin(), v.end());
	for (int i = 1; i < 3; i++)
		if (v[i].second != v[0].second)
			return make_pair(rev(v[0]), rev(v[i]));
	return make_pair(rev(v[0]), rev(v[3]));
}

void dfsdw(int v, int p = -1){
	if (dp1[v].first != c[v]){
		if (cost[c[v]] > dp1[v].second + x[v]){
			cost[c[v]] = dp1[v].second + x[v];
			near[c[v]] = dp1[v].first;
		}
	}
	else{
		if (cost[c[v]] > dp2[v].second + x[v]){
			cost[c[v]] = dp2[v].second + x[v];
			near[c[v]] = dp2[v].first;
		}
	}
	for (auto edge : t[v]){
		int u = edge.first, w = edge.second;
		if (u == p)
			continue;
		pll fi = make_pair(dp1[v].first, dp1[v].second + w);
		pll se = make_pair(dp2[v].first, dp2[v].second + w);
		auto tmp = mergepairs(dp1[u], dp2[u], fi, se);
		dp1[u] = tmp.first;
		dp2[u] = tmp.second;
		dfsdw(u, v);
	}
}

void dfs(int v, int p = -1){	
	dp1[v] = {c[v], x[v]};
	dp2[v] = {0, inf};
	for (auto edge : t[v]){
		int u = edge.first, w = edge.second;
		if (u == p)
			continue;
		dfs(u, v);
		pll fi = make_pair(dp1[u].first, dp1[u].second + w);
		pll se = make_pair(dp2[u].first, dp2[u].second + w);
		auto tmp = mergepairs(dp1[v], dp2[v], fi, se);
		dp1[v] = tmp.first;
		dp2[v] = tmp.second;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> x[i];
	for (int i = 0; i < n - 1; i++){
		int v, u, w;
		cin >> v >> u >> w;
		t[v].push_back({u, w});
		t[u].push_back({v, w});
	}
	for (int i = 1; i <= n; i++)
		c[i] = root[i] = i;
	memset(par, -1, sizeof par);
	int	col = n;
	while (col > 1){
		memset(near, 0, sizeof near);
		memset(cost, 63, sizeof cost);
		dfs(1);
		dfsdw(1);
		for (int i = 1; i <= col; i++)
			merge(root[i], root[near[i]], cost[i]);
		col = 0;
		for (int i = 1; i <= n; i++)
			if (par[i] < 0)
				c[i] = ++ col, root[col] = i;
		for (int i = 1; i <= n; i++)
			if (par[i] > 0)
				c[i] = c[get_par(i)];
	}
	cout << answer << endl;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int priority;
    double value;
}data;

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    char C[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    scanf("%d",&N);

    char S[10001];
    scanf("%s",S);

    int L = strlen(S);

    //A[0]~A[N-1]に格納する
    for(int i=0;i<L;i++){
        int ind = S[i]-'A';
        //printf("%d\n",ind);
        ind = (ind+N)%26;
        printf("%c",C[ind]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, k;  cin >> n >> k;
    string s;   cin >> s;
    int x = 0, y = 0;
    if (s[0] == 'L')
        y++;
    if (s[n-1] == 'R')
        y++;

    for (int i = 0; i < n-1; i++) {
        if (s[i] == 'R' && s[i+1] == 'L')
            x++;
    }

    int ans;

    if (k <= x)
        ans = n - (2*(x-k) + y);
    else if (k == x + 1)
        ans = n - 1;
    
    cout << ans << endl;

    return 0;

    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using p = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止

int main(void){
    string s,t;
    cin >> s >> t;
    int count = 0;
    rep(i,s.size()){
        if(s[i] != t[i]){
            count++;
        }
    }
    cout << count << endl;
}

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

pair<int, int> x[55];
int main() {
	int n, m;
	cin >> n;
	m = n;
	for (int i = 0; i < n; i++)
		cin >> x[i].first >> x[i].second;
	sort(x, x + n);
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int p = x[j].first - x[i].first, q = x[j].second - x[i].second;
			int v[55] = {}, c = 0;
			for (int k = 0; k < n; k++) {
				if (!v[k]) c++;
				int d = find(x, x + n, make_pair(x[k].first + p, x[k].second + q)) - x;
				if (d < n) v[d] = 1;
			}
			m = min(m, c);
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256