akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

/*
Tutorials:
  * https://discuss.codechef.com/questions/83102/workchef-unofficial-editorial
  * https://stackoverflow.com/questions/22394257/how-to-count-integers-between-large-a-and-b-with-a-certain-property/22394258#22394258 (really good)
*/

int D;
string X;
const int MOD = 1e9 + 7;
struct State {
  string X;
  int sum_so_far;
  string acc;

  int dig(const int i) const {
    return X[i] - '0';
  }
};

long long count(State state, int i, int leftmost_lo, int leftmost_hi) {
  if (i == state.X.length()) {
    //cout << state.X.length()<< " " << state.sum_so_far << "  " << state.acc << "\n";
    if (state.sum_so_far == 0 && leftmost_lo <= leftmost_hi) {
      cout << state.acc << " " << state.sum_so_far << "\n";
      return 1;
    } else {
      return 0;
    }
  }
  long long ans = 0;
  for (int d = 0; d <= 9; d++) {
    int leftmost_lo_prime = d < state.dig(i) && i < leftmost_lo? i : leftmost_lo;
    int leftmost_hi_prime = d > state.dig(i) && i < leftmost_hi? i : leftmost_hi;
    state.sum_so_far = (state.sum_so_far + d) % D;
    state.acc += to_string(d);
    ans += count(state, i + 1, leftmost_lo_prime, leftmost_hi_prime);
    state.acc = state.acc.substr(0, state.acc.length() - 1);
    state.sum_so_far -= d;
  }
  return ans;
}
vector<vector<vector<long long>>>dp;
long long count(int i, int sum_so_far, bool lo) {
  if (i == X.length()) {
    return sum_so_far % D == 0;
  }
  if (dp[i][sum_so_far][lo] != -1) return dp[i][sum_so_far][lo];
  long long ans = 0;
  for (int d = 0; d <= (lo ? 9 : (X[i] - '0')); d++) {
    ans = (ans + count(i + 1, (sum_so_far + d) % D, lo || d < (X[i] - '0'))) % MOD;
  }
  return dp[i][sum_so_far][lo] = ans;
}

int main() {
  //D = 4;
  //State state = { "30", 0, "" };
  cin >> X >> D;
  int n = X.length();
  dp.clear();
  dp.resize(n, vector<vector<long long>>(D, vector<long long>(2, -1)));
  
  int ans = count(0, 0, false) - 1;
  if (ans < 0) ans = MOD - 1;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 56192
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ans=0
pre=-100
for val in a:
    ans+=b[val-1]
    if pre+1 == val:
        ans+=c[pre-1]
    pre=val
print(ans)

Measured memory_bytes: 3064
<?php
    fscanf(STDIN, "%d %d", $a, $b);
    fscanf(STDIN, "%s", $s);
    for($i = 0; $i < $a + $b + 1; $i++){
        if(($i == $a && $s[$i] != '-') || ($i != $a && $s[$i] == '-')){
            echo "No\n";
            exit;
        }
    }
    echo "Yes\n";
?>


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll t,n,a,b,c,i,j;
    vector<ll>v;
    map<ll,ll>mp;
    stack<ll>st;
    deque<ll>dq;
    queue<ll>q;
    set<ll>s;
    string str,str1;
    cin>>str>>str1;
    int blb = 0;
    for(i = 0;i < str.size();i++)
    {
        if(str[i]!=str1[i])
        {
            blb = 1;
            break;
        }
    }
    if(blb==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    bool flag = true;
    for(int i = 0;i < s.size();i++){
        if((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')){
            flag = false;
        }
    }
    
    cout << ((flag) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
fn main(){
  let mut dp: Vec<Vec<usize>> = vec![vec![0;1001]; 10];
  dp[0][0] = 1;

  for i in 0 .. 101 {
    let mut ndp: Vec<Vec<usize>> = vec![vec![0;1001]; 10];
    ndp[0][0] = 1;
    for j in 1 .. 10 {
      for k in 0 .. 1001 {
        if k >= i {
          ndp[j][k] = dp[j][k] + dp[j-1][k-i];
        } else {
          ndp[j][k] = dp[j][k];
        }
      }
    }
    dp = ndp;
  }

  loop {
    let ns: Vec<usize> = read_vec();
    let n = ns[0];
    let s = ns[1];

    if n == 0 && s == 0 { break; }

    println!("{}", dp[n][s]);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5040
n, k = map(int, input().split())

x = [0 for _ in range(0, 100001)]

for i in range(n):
   a, b = map(int, input().split())
   x[a] += b

l = 0
for i in range(1, 100001):
   if (l < k and (l + x[i]) >= k ):
      print(i)
      exit()

   l += x[i]


Measured memory_bytes: 5916
M = 10**9+7
N=int(input())
S=input().strip()
T=input().strip()
for i in range(N):
    if i == 0:
        if S[i] == T[i]:
            r = 3
            tmp = 1
        else:
            r = 6
            tmp = 0
        continue
    if S[i] == S[i-1]:
        tmp = 0
        continue
    if tmp:
        r = r*2%M
    elif S[i] != T[i]:
        r = r*3%M
    tmp=1
print(r)


Measured memory_bytes: 38384
# coding: utf-8
N = int(input())

if N == 1:
    print(1)
elif N<=3:
    print(2)
elif 4<=N<=7:
    print(4)
elif 8<=N<=15:
    print(8)
elif 16<=N<=31:
    print(16)
elif 32 <=N<=63:
    print(32)
else:
    print(64)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;

namespace MinPro2019D
{
    public class Program
    {
        void Solve(SimpleScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var L = ss.NextLong();
            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = ss.NextLong();
                var x = A == 0 ? 2 : A & 1;

                dp[0] += A;
                dp[1] += x;
                dp[2] += (x & 1) ^ 1;
                dp[3] += x;
                dp[4] += A;

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t], dp[t - 1]);
                }
            }

            sw.WriteLine(dp[4]);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new SimpleScanner(Console.OpenStandardInput());
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    public class SimpleScanner
    {
        const int DefaultCapacity = 256;

        readonly Stream stream;
        readonly int capacity;
        readonly byte[] buffer;
        readonly List<char> chars;

        int index;
        int length;

        public SimpleScanner(Stream stream, int capacity = DefaultCapacity)
        {
            this.stream = stream;
            this.capacity = capacity;
            this.buffer = new byte[capacity];
            this.chars = new List<char>();

            Reload();
        }

        void Reload()
        {
            index = 0;
            length = stream.Read(buffer, 0, capacity);
        }

        byte Peek()
        {
            return buffer[index];
        }

        byte Read()
        {
            var ret = Peek();
            if (++index >= length) Reload();
            return ret;
        }

        bool CanInput()
        {
            return 33 <= Peek() && Peek() <= 126;
        }

        bool IsNumber()
        {
            return 48 <= Peek() && Peek() <= 57;
        }

        public string Next()
        {
            chars.Clear();
            while (!CanInput()) Read();
            while (CanInput()) chars.Add((char)Read());
            return new string(chars.ToArray());
        }

        public int NextInt()
        {
            return (int)NextLong();
        }

        public long NextLong()
        {
            var ret = 0L;
            var isNegative = false;

            while (!IsNumber()) isNegative = Read() == 45;
            while (IsNumber()) ret = ret * 10 + Read() - 48;
            return isNegative ? -ret : ret;
        }

        public double NextDouble()
        {
            var integerPart = NextLong();
            if (Peek() == 46) Read();

            double decimalPart = 0.0, place = 1.0;
            while (IsNumber()) decimalPart += (Read() - 48) * (place /= 10.0);
            return integerPart + (integerPart < 0 ? -decimalPart : decimalPart);
        }
    }
}


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

int main() {
    int n;
    cin>>n;
    int result=0;
    for(int i=0;i<30;i++){
        for(int j=0;j<30;j++){
            if(i*7+j*4==n) result=1;

        }
    }
    if(result) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)
#2枚のピザのほうが安いとき
for i in reversed(range(max(X,Y)+1)):#全部ABピザにしちゃう場合から
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
    else:
        break
print(ans)


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

int main(){
	double r;
	cin >> r;
	double ans = 2*M_PI*r;
	printf("%.10f",ans);
    return 0;
}



Measured memory_bytes: 3788
class Dice:

    def __init__(self, faces=(1, 2, 3, 4, 5, 6)):
        self.faces = faces
        self.current = {
            'top': faces[0],
            'south': faces[1],
            'east': faces[2],
            'west': faces[3],
            'north': faces[4],
            'bottom': faces[5],
        }

    def roll_north(self):
        new = dict()
        new['top'] = self.current['south']
        new['south'] = self.current['bottom']
        new['east'] = self.current['east']
        new['west'] = self.current['west']
        new['north'] = self.current['top']
        new['bottom'] = self.current['north']

        self.current = new

    def roll_south(self):
        new = dict()
        new['top'] = self.current['north']
        new['south'] = self.current['top']
        new['east'] = self.current['east']
        new['west'] = self.current['west']
        new['north'] = self.current['bottom']
        new['bottom'] = self.current['south']

        self.current = new

    def roll_east(self):
        new = dict()
        new['top'] = self.current['west']
        new['south'] = self.current['south']
        new['east'] = self.current['top']
        new['west'] = self.current['bottom']
        new['north'] = self.current['north']
        new['bottom'] = self.current['east']

        self.current = new

    def roll_west(self):
        new = dict()
        new['top'] = self.current['east']
        new['south'] = self.current['south']
        new['east'] = self.current['bottom']
        new['west'] = self.current['top']
        new['north'] = self.current['north']
        new['bottom'] = self.current['west']

        self.current = new

faces = input().split(' ')
for i, n in enumerate(faces):
    faces[i] = int(n)
rolls = [roll for roll in input()]

dice = Dice(faces=faces)
for roll in rolls:

    if roll == 'N':
        dice.roll_north()

    if roll == 'S':
        dice.roll_south()

    if roll == 'E':
        dice.roll_east()

    if roll == 'W':
        dice.roll_west()

print(dice.current['top'])


Measured memory_bytes: 5616
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e10;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[3002], suff[3002][3002];

int main()
{
    fast_io;
    ll n, s, i, j, x, ans = 0;
    cin >> n >> s;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (j = n; j >= 1; j--)
    {
        suff[j + 1][0]++, suff[j + 1][0] %= mod2;
        for (i = 0; i <= s; i++)
        {
            x = suff[j + 1][i];
            if (i >= a[j]) x += suff[j + 1][i - a[j]], x %= mod2;
            suff[j][i] += x, suff[j][i] %= mod2;
        }
        ans += suff[j][s], ans %= mod2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int f[101][101];
int p[10001];
int n;
int doit(int i,int j){
	 if (f[i][j]!=0x1f1f1f1f)
	    return f[i][j];
	 for (int k=i; k<j; k++)
	 	 f[i][j]=min(f[i][j],doit(i,k)+doit(k+1,j)+p[i-1]*p[k]*p[j]);
	 return f[i][j];
}
    
int main(){
	cin>>n;
	for (int i=1; i<=n; i++)
	    cin>>p[i-1]>>p[i];
	memset(f,0x1f1f1f1f,sizeof(f));
	for (int i=1; i<=n; i++)
	    f[i][i]=0;
	doit(1,n);
    cout<<f[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 3140
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int r;
    cin>>r;
    print(3*r*r)
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n;
char s[20];
void dfs(int x,int lim){
	if(x==n){printf("%s\n",s);return;}
	for(int i=0;i<=lim;i++)s[x]=i+'a',dfs(x+1,max(lim,i+1));
}
int main(){
	scanf("%d",&n),s[n]='\0';
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 1536
ab = input().split(" ")

a = int(ab[0])
b = int(ab[1])

aa = 0
bb = 0

for i in range(b):
    aa = aa + a * 10**i

for i in range(a):
    bb = bb + b * 10**i

if aa > bb:
    print(aa)
else:
    print(bb)

Measured memory_bytes: 3060
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int food[35], ans;
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		int c, k[35];
		cin >> c;
		for (int j = 0; j < c; ++j) {
			cin >> k[j];
			--k[j];
			++food[k[j]];
		}
	}
	for (int i = 0; i <= 30; ++i) {
		if (food[i] == a) { ++ans; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x[3000],y[3000],i,ix;
    i=ix=0;
    while(1){
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0&&y[i]==0){
            ix=i;
            break;
        }
        i++;
    }
    for(i=0;i<ix;i++){
        if(x[i]>y[i]){
            printf("%d %d\n",y[i],x[i]);
        }else{
            printf("%d %d\n",x[i],y[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 1764
var
 a,b,c,d,n,k:longint;
begin
 readln(a,b,c,d);
 readln(n);
 k:=a*4;
 if k>b*2 then k:=b*2;
 if k>c then k:=c;
 if k*2<d then
 writeln(n*k)
  else
   writeln((n mod 2)*k+(n div 2)*d);
end.

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

using ll = long long;
using namespace std;

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> sumA(n + 1, 0), sumB(m + 1, 0);
	for(int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		sumA[i + 1] = sumA[i] + a;
	}
	for(int i = 0; i < m; ++i) {
		ll b;
		cin >> b;
		sumB[i + 1] = sumB[i] + b;
	}
	ll ans = 0LL, j = m;
	for(int i = 0; i <= n; ++i) {
		if( sumA[i] > k ) continue;
		while( sumA[i] + sumB[j] > k ) {
			j--;
		}
		ans = max(ans, (ll)(i) + j);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6424
S = str(input())
ans_h = 0
ans_i = 0
count_h = 0
count_i = 0

for i in range(0,len(S),2):
    if S[i] != 'h':
        ans_h += 1
    else:
        count_h += 1

for j in range(1,len(S),2):
    if S[j] != 'i':
        ans_i += 1
    else:
        count_i += 1

if ans_h == 0 and ans_i == 0 and count_h == count_i:
    print('Yes')
else:print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

//素因数分解
vector<pair<int64, int>> factorize(int64 n) {
	vector<pair<int64, int>> p;
	//√nまで回すループ
	//nの素数は高々√nまでの性質を利用する
	for (int64 i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		p.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			p.back().second++;
		}
	}
	if (n != 1) p.emplace_back(n, 1);
	return p;
}

void solve() {
		int64 a, b; cin >> a >> b;
		//最大公約数を求める
		int64 n = gcd(a, b);
		//最大公約数の中で互いの素な約数を列挙する
		//互いに素な約数は素因数分解で列挙する
		auto f = factorize(n);
		//1を含むためサイズに+1したものが求める答え
		int ans = f.size() + 1;
		cout << ans << endl;
    return;
}

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



Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

flag = 0
T = 1

while flag == 0:
    if T == 1:
        C = C - B
        T = 0
        if C <= 0:
            flag = 1
    else:
        A = A - D
        T = 1
        if A <= 0:
            flag = 2

if T == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9180
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(dead_code)]
pub fn prime(n: u64) -> Vec<bool> {
    let mut prime: Vec<bool> = vec![true; (n + 1) as usize];
    prime[0] = false;
    if n >= 1 {
        prime[1] = false;
    }
    let mut i = 2_usize;
    while i * i <= n as usize {
        if prime[i] {
            let mut j = i + i;
            while j <= n as usize {
                prime[j] = false;
                j += i;
            }
        }
        i += 1;
    }
    prime
}
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        x: usize,
    }
    let p = prime(1000_000);
    let mut x = x;
    while !p[x] {
        x += 1;
    }
    println!("{}", x);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
        string s;
        cin >> s;
        int n = s.size();
        set<string> st;
        for(int i=1;i<=n-1;i++){
            string t1 = s.substr(0, i);
            string t2 = s.substr(i, n - i);
            string t3 = t1;
            string t4 = t2;
            reverse(ALL(t3));
            reverse(ALL(t4));
            st.insert(t1 + t2);
            st.insert(t1 + t4);
            st.insert(t3 + t2);
            st.insert(t3 + t4);
            st.insert(t2 + t1);
            st.insert(t2 + t3);
            st.insert(t4 + t1);
            st.insert(t4 + t3);
        }
        cout << st.size() << endl;
    }
}


Measured memory_bytes: 3160
from collections import deque
n = int(input())
a_list = []
for i in range(n):
    a_list.append(deque([int(aa) - 1 for aa in input().split()]))
day = 0
battle = 0
for _ in range(n * (n - 1) // 2):
    if battle == n * (n - 1) // 2:
        break
    day += 1
    battle_today = 0
    tomorrow = set([])
    if (day == 1):
        player = set([i for i in range(n)])
    for i in player:
        if len(a_list[i]) == 0:
            continue
        j = a_list[i][0]
        if (i == a_list[j][0]) & (j not in tomorrow) & (len(a_list[j]) > 0) & (i not in tomorrow):
            tomorrow.add(i)
            tomorrow.add(a_list[i][0])
            battle += 1
            battle_today += 1
            a_list[i].popleft()
            a_list[j].popleft()
    player = tomorrow
    if battle_today == 0:
        day = -1
        break
print(day)

Measured memory_bytes: 38004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a, b, c;
  string ans="NO";
    cin >> a >> b >> c;
    int mod = a%b, tmp=a;
    do{
      if(tmp%b==c){
        ans = "YES";
        break;
      }
      tmp += a;
    }while(mod != tmp%b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int gcd(int a, int b) {
  if(!(a%b)) return b;
  return gcd(b, a%b);
}

int main() {
  int X;
  cin >> X;
  int ans=360/gcd(X,360);
  cout << ans << endl;
}

Measured memory_bytes: 3592
n = int(input())

length = list(map(int,input().split()))

length = sorted(length)
length.append(0)

temp = length[0]
c = 1

unique_n = []
square = []

for i in range(n):
    if temp == length[i+1]:
        c += 1
    
    else:
        if c >= 2 :
            unique_n.append(length[i-1])
        
        if c >= 4:
            square.append(length[i-1])
            
        
        c = 1
        temp = length[i+1]

if len(unique_n) <= 1:
    print(0)

else:
    if len(square) >= 1:
        print(max(unique_n[-1]*unique_n[-2],(square[-1])**2))
    
    else:
        print(unique_n[-1]*unique_n[-2])


        
        
    

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N, 1e9);
    dp[0] = 0;
    FOR(i, 1, N){
        if(i < K){
            for(int j = i-1; 0 <= j; j--){ 
                dp[i] = min(dp[j]+abs(h[i] - h[j]), dp[i]);
            }
        }else{
            for(int j = i-1; i-K <= j; j--){ 
                dp[i] = min(dp[j]+abs(h[i] - h[j]), dp[i]);
            }
        }
    }
    
    cout << dp[N-1] << endl;

    return 0;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int a, b, sum;
  int res = 0;

  while(scanf("%d %d",&a,&b) != EOF){
    res = 0;
    sum = a + b;
    while(sum){
      sum /= 10;
      res++;
    }
    printf("%d\n",res);
  }

  return 0;
}

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

int main() {
    int n,cnta=0,cntb=0;
    cin>>n;
    vector<int> a(n),b(n),an(n),bn(n);
    bool ok = true;
    for(int i=0; i<n; i++) {
        an[i] = i+1;
        bn[i] = i+1;
    }
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    for(int i=0; ; i++) {
        ok = true;
        for(int j=0; j<n; j++) {
            if(an[j] != a[j]) ok = false;
        }
        cnta++;
        if(ok) break;
        next_permutation(an.begin(),an.end());
    }
    for(int i=0; ; i++) {
        ok = true;
        for(int j=0; j<n; j++) {
            if(bn[j] != b[j]) ok =false;
        }
        cntb++;
        if(ok) break;
        next_permutation(bn.begin(),bn.end());
    }
    cout<<abs(cnta-cntb)<<endl;
}

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

int flag=0;

int check(int red, int green, int blue, int count, int limit)
{
    if(red < green && green < blue){
        flag = 1;
        return flag;
    }

    if(count<=limit && flag==0)
        check(red*2, green, blue, count+1, limit);
    if(count<=limit && flag==0)
        check(red, green*2, blue, count+1, limit);
    if(count<=limit && flag==0)
        check(red, green, blue*2, count+1, limit);

    return flag;
}

int main(void){
    int count=0;
    int red, green, blue;
    int limit;
    cin >> red >> green >> blue;
    cin >> limit;
    flag = check(red, green, blue, count+1, limit);
    if(flag == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
object Main {
def main(args: Array[String]): Unit = {
    val in = readLine.split(" ").map(_.toInt)
    val a = in(0)
    val b = in(1)
    val c = in(2)
    val d = in(3)

    val lw = a + b
    val rw = c + d
    if (lw > rw){
      print("Left")
    } else if(lw == rw){
      print("Balanced")
    } else{
      print("Right")
    }
  }
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
         
using namespace std;
         
const long long INF = 1e17;
         
struct SE {
  int n, op;
  vector<long long> v;
          
  void Init(int _n, int _op) {
    n = _n;
    op = _op;
    v.resize(n * 4 + 1, INF);
  }
          
  void Set(int t, int l, int r, int x, long long _v) {
    if (l == r) {
      v[t] = _v + l * op;
      return;
    }
    int md = (l + r) >> 1;
    if (x <= md) Set(t << 1, l, md, x, _v);
    else Set(t << 1 | 1, md + 1, r, x, _v);
    v[t] = min(v[t << 1], v[t << 1 | 1]);
  }
         
  long long Query(int t, int l, int r, int L, int R) {
    if (L <= l && r <= R) return v[t];
    int md = (l + r) >> 1;
    long long re = INF;
    if (L <= md) re = min(re, Query(t << 1, l, md, L, R));
    if (R > md) re = min(re, Query(t << 1 | 1, md + 1, r, L, R));
    return re;
  }
} lt, rt;
         
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
          
  int n, nq, a, b;
  long long tag = 0;
  cin >> n >> nq >> a >> b;
  vector<int> x(nq);
  vector<long long> dp(n + 1, INF);
  cin >> x[0];
         
  lt.Init(n, -1);
  rt.Init(n, 1);
  lt.Set(1, 1, n, a, abs(x[0] - b));
  lt.Set(1, 1, n, b, abs(x[0] - a));
  rt.Set(1, 1, n, a, abs(x[0] - b));
  rt.Set(1, 1, n, b, abs(x[0] - a));
  dp[a] = min(dp[a], (long long)abs(x[0] - b));
  dp[b] = min(dp[b], (long long)abs(x[0] - a));
          
  for (int i = 1; i < nq; ++i) {
    cin >> x[i];
    long long lck = lt.Query(1, 1, n, 1, x[i]) + x[i] + tag;
    long long rck = rt.Query(1, 1, n, x[i], n) - x[i] + tag;
    tag += abs(x[i] - x[i - 1]);
    if (dp[x[i - 1]] + tag > min(lck, rck)) {
      dp[x[i - 1]] = min(lck, rck) - tag;
      lt.Set(1, 1, n, x[i - 1], dp[x[i - 1]]);
      rt.Set(1, 1, n, x[i - 1], dp[x[i - 1]]);
    }
  }
         
  long long ans = INF;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, dp[i]);
  }
  cout << ans + tag << endl;
          
  return 0;
}


Measured memory_bytes: 15104
n = int(input())
m = {}
for i in range(n):
    s = input()
    if s in m:
        m[s] += 1
    else:
        m[s] = 1

maxim = max(m.values())
mySet = set(key for key, value in m.items() if value == maxim)
for i in sorted(mySet):
    print(i)

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

int main() {
  int A,B;
  cin >> A >> B;
  int ans = A - B * 2;
  if (ans < 0) {
    cout << 0;
  } else {
    cout << ans;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template <typename T>
using V = vector<T>;

int main() {
	for (int m, n; m = in, n = in;) {
		V<int> b(m), r(n);
		V<V<int>> g(m + n);
		for (int &i: b)
			i = in;
		for (int &i: r)
			i = in;
		for (int i: range(m))
			for (int j: range(n))
				if (__gcd(b[i], r[j]) > 1) {
					g[i].push_back(j + m);
					g[j + m].push_back(i);
				}

		V<int> match(g.size(), -1);
		int res = {};
		for (int i: range(g.size()))
			if (match[i] < 0) {
				V<bool> used(g.size());
				function<bool(int)> dfs = [&] (int v) {
					used[v] = true;
					for (int u: g[v]) {
						int w = match[u];
						if (w < 0 || (!used[w] && dfs(w))) {
							match[v] = u;
							match[u] = v;
							return true;
						}
					}
					return false;
				};
				if (dfs(i))
					res++;
			}
		outl(res);
	}
}


Measured memory_bytes: 3904
#include <stdio.h>

int main(void)
{
        int a='A'-'a';
        char s1[11],s2[11],s3[11];
        scanf("%s%s%s",s1,s2,s3);
        printf("%c%c%c\n",s1[0]+a,s2[0]+a,s3[0]+a);
        return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

const int N = 3;

double dist(pair<double,double>& a,pair<double,double>& b)
{
	return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

double f(double m,double r,double mx)
{
	return mx * m / r + 2 * m;
}

int main()
{
	vector< pair<double,double> > P(N);
	FOR(i,0,N){
		scanf("%lf%lf",&P [i].first,&P [i].second);
	}
	double a = dist(P [0],P [1]),b = dist(P [1],P [2]),c = dist(P [2],P [0]);
	double s = sqrt((a + b + c) * (b + c - a) * (a + c - b) * (a + b - c)) / 4.0;
	double r = s / (a + b + c) * 2;

	double lo = 0.0,hi = r,mid;
	FOR(i,0,100){
		mid = (lo + hi) / 2.0;
		if(f(mid,r,max({a,b,c})) <= max({a,b,c})){
			lo = mid;
		}
		else{
			hi = mid;
		}
	}

	printf("%.10f\n",(lo + hi) / 2.0);

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().strip().split())
py = []
pyd = {}

for _ in range(m):
  p, y = map(int, input().strip().split())
  py.append((p, y))
  if p in pyd:
    pyd[p].append(y)
  else:
    pyd[p] = [y]

num = {}
for p, yl in pyd.items():
  for i, y in enumerate(sorted(yl)):
    num[(p,y)] = "%06d%06d" % (p, i+1)

for _py in py:
  print(num[_py])


Measured memory_bytes: 55360
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    double  = 0
    for i in range(101):
        if A <= i <= B and C <= i <= D: double += 1
    print(double - 1 if double > 1 else 0)

    return  0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
a = ['1x1=1','1x2=2','1x3=3','1x4=4','1x5=5','1x6=6','1x7=7','1x8=8','1x9=9','2x1=2','2x2=4','2x3=6','2x4=8','2x5=10','2x6=12','2x7=14','2x8=16','2x9=18','3x1=3','3x2=6','3x3=9','3x4=12','3x5=15','3x6=18','3x7=21','3x8=24','3x9=27','4x1=4','4x2=8','4x3=12','4x4=16','4x5=20','4x6=24','4x7=28','4x8=32','4x9=36','5x1=5','5x2=10','5x3=15','5x4=20','5x5=25','5x6=30','5x7=35','5x8=40','5x9=45','6x1=6','6x2=12','6x3=18','6x4=24','6x5=30','6x6=36','6x7=42','6x8=48','6x9=54','7x1=7','7x2=14','7x3=21','7x4=28','7x5=35','7x6=42','7x7=49','7x8=56','7x9=63','8x1=8','8x2=16','8x3=24','8x4=32','8x5=40','8x6=48','8x7=56','8x8=64','8x9=72','9x1=9','9x2=18','9x3=27','9x4=36','9x5=45','9x6=54','9x7=63','9x8=72','9x9=81']

n = 0

for i in range(81):
	print(a[n])
	n += 1

Measured memory_bytes: 7464
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char s[20];
int main(){
    scanf("%s",s);
    if(strlen(s) < 4)   printf("No\n");
    else if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
        printf("Yes\n");
    }
    else    printf("No\n");
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 2000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
 
using namespace std;
 
int main(){
    IOS;
  
  	int a, b; cin>>a>>b;
  	if(b%a==0) cout<<(a+b)<<endl;
  	else cout<<(b-a)<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int  a, b ,c;
    char X,Y;
    string S1,S2;
    cin >> a >> b >> c ;
    if(abs(a - b) > abs(a - c))cout << 'B' << endl;
    else cout << 'A' << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, l, q, r;
string s, t, d, c;

ll par[N], sz[N];
ll comp;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> q;
	cin >> s;
	vll pre(n);
	for(ll i=1;i<n;i++) {
		if(s[i]=='C' && s[i-1] == 'A') pre[i] = 1;
	}
	for(ll i=1;i<=n;i++) pre[i]+=pre[i-1];

	while(q--) {
		cin>>l>>r;
		l--;r--;
		//cout<<l<<" "<<r<<" "<<pre[l]<<" "<<pre[r];newl;
		cout<<pre[r] - pre[l];
		//else cout<<pre[r];
		newl;
	}
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4236
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    char b;
	char ans;
	
	cin >> b;
	
	if(b=='A'){ans='T';}
	else if(b=='C'){ans='G';}
	else if(b=='G'){ans='C';}
	else if(b=='T'){ans='A';}

    cout << ans << endl;
}

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

int main(){
    int W,H,x,y; cin>>W>>H>>x>>y;
    if((double)W/2==x && (double)H/2==y){
        cout<<(double)W*H/2<<" "<<1<<endl;
    }
    else{
        cout<<(double)W*H/2<<" "<<0<<endl;

    }

}

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

 int main() {
   int A,B;
   cin >> A >> B;
   
   int a = A + B;
   int b = A - B;
   int c = A * B;
   int ans = max(max(a,b),c);
   cout << ans << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll INF = (ll)1e18;
ll MOD;

ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 2000100;
ll n, x, m;
map <ll, ll> mapchik;
ll p[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    
    cin >> n >> x >> m;
    MOD = m;
    mapchik[x] = 1;
    p[1] = x;
    ll i = 2, ans = 0;
    while (i <= n) {
        x = mul(x, x);
        p[i] = p[i - 1] + x;
        if (mapchik.count(x))
            break;
        else
            mapchik[x] = i;
        ++i;
    }
    if (i == n) {
        cout << p[n] << endl;
        return 0;
    }
    ll len = i - mapchik[x], sum = p[i - 1] - p[mapchik[x] - 1];
    ll l = i - 1 + (n - (i - 1)) / len * len;
    ans = p[i - 1] + (n - (i - 1)) / len * sum;
    while (l < n) {
        ans += x;
        x = mul(x, x);
        ++l;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 7116
#include<stdio.h>
#include<math.h>
#include<string.h>
void rotation(int Dice1[],int Dice2[])
{
  int i,tmp,flag=0,count,loop=1;
  while(1)
  {
    for(i=0;i<4;i++)
    {
      if((Dice1[0]==Dice2[0])&&(Dice1[5]==Dice2[5])) {flag++; break;}
      tmp=Dice1[0];
      Dice1[0]=Dice1[1];
      Dice1[1]=Dice1[5];
      Dice1[5]=Dice1[4];
      Dice1[4]=tmp;
    }
    if(flag==1) break;
    for(i=0;i<4;i++)
    {
      if((Dice1[0]==Dice2[0])&&(Dice1[5]==Dice2[5])) {flag++;break;}
      tmp=Dice1[0];
      Dice1[0]=Dice1[3];
      Dice1[3]=Dice1[5];
      Dice1[5]=Dice1[2];
      Dice1[2]=tmp;
    }
    if(flag==1) break;
    break;
  }
//上面と下面合わせ終了
//  printf("%d\n",flag);

  while(1)
  {
    count=0;
    for(i=1;i<=4;i++)
    {
      if(Dice1[i]==Dice2[i]) count++;
      if(count==4) {flag++; break;}
    }
    tmp=Dice1[1];
    Dice1[1]=Dice1[3];
    Dice1[3]=Dice1[4];
    Dice1[4]=Dice1[2];
    Dice1[2]=tmp;
    if(loop==4) break;
    loop++;
  }
  //側面合わせ終了
  // printf("%d\n",flag);
  if(flag>=2) printf("Yes\n");
  else printf("No\n");
}
int main(void)
{
  int i,j,Dice1[6],Dice2[6],q,a,b;
  for(i=0;i<6;i++)
  {
    scanf("%d",&Dice1[i]);
  }

  for(i=0;i<6;i++)
  {
    scanf("%d",&Dice2[i]);
  }
  rotation(Dice1,Dice2);

  return 0;
}



Measured memory_bytes: 2100
'use strict';

const main = (input) => {
    const t = input.split(' ');
    const A = parseInt(t[0], 10);
    const B = parseInt(t[1], 10);
    console.log (((A % 2) == 0 || (B % 2) == 0) ? 'No' : 'Yes');
};

const isTest = false;

if (isTest) {
    main('3 1');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

Measured memory_bytes: 21064
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))

# それぞれの道の端点をgに記録
g = [[] for _ in range(N + 1)]
for _ in range(M):
    A, B = map(int, input().split())
    g[A].append(B)
    g[B].append(A)

ans = 0

for i in range(1, N + 1):

    # i番目の展望台について繋がっている展望台全てと順番に高さ比較
    # 一つでも勝てないものがあったらその展望台について考えるのは終わり、次に行く

    # 良いか悪いか
    tf = True

    for j in g[i]:
        if H[j] >= H[i]:
            tf = False
            break

    # 全てに勝ったらそれは「良い展望台」
    if tf == True:
        ans += 1

print(ans)


Measured memory_bytes: 29432