akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next(), t = sc.next();

        System.out.println(LCS(s.toCharArray(), t.toCharArray()));
    }

    private static String LCS(char[] s, char[] t) {
        int m = s.length, n = t.length;
        int[][] dp = new int[m + 1][n + 1];

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        String res = "";
        int i = m, j = n;
        while (i > 0 && j > 0) {
            if (s[i - 1] == t[j - 1]) {
                res += s[i - 1];
                i--;
                j--;
            } else if (dp[i][j - 1] == dp[i][j]) {
                j--;
            } else if (dp[i - 1][j] == dp[i][j]) {
                i--;
            }
        }
        return new StringBuilder(res).reverse().toString();
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

int main(){

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

    ll n;
    cin >> n;

    int m = 5;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];

    ll bottle = LINF;
    for(int i = 0; i < 5; ++i){
        if(bottle > a[i]){
            bottle = a[i];
        }
    }

    if(n > bottle)
        if(n%bottle)cout << (n/bottle)+5LL << endl;
        else cout << (n/bottle)+4LL << endl;
    else{
        cout << 5 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if a < c {
		a = c
	}
	if d < b {
		b = d
	}
	if b-a > 0 {
		fmt.Println(b - a)
		return
	}
	fmt.Println(0)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int x;
    cin >> x;
    int ans = 1;
    rep(base, 2, x + 1)
    {
        if (base * base > x)
            break;
        int exp = 2;
        int tmp = base * base;
        while (tmp <= x)
        {
            chmax(ans, tmp);
            tmp *= base;
            exp++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
const main =(standardInput) =>{
  const x = standardInput;
  var count=0;
  var diff=x;
  for(var i=11;i>0;i--){
    if(i>6){
    count+=Math.floor(diff/i)*2;
    }else{
      count+=Math.floor(diff/i);
    }
    diff=diff%i;
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
double n, a, p, k;
int i;
int main()
{
	cin>>n;
	for(i=1; i<=n; i++)
	{
		if(i%2==1)
		{
			p++;
		}
	}
	k=(p/n);
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
n, p = STDIN.gets.split(' ').map(&:to_i)

if n == 1
  puts p
  exit 0
end

start = (p ** (1.0 / n)).to_i + 1

gcd = 1
start.downto(2) do |i|
  product = p

  if (i ** n) > product
    next
  end

  if product % (i ** n) != 0
    next
  end

  product /= i ** n

  if product < 0
    next
  end

  gcd = i
  break
end

p gcd


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	string n;
	cin >> n;

	for (auto i = 0; i < 3; ++i)
	{
		if (n[i] == '1')
		{
			cout << 9;
		}
		else
		{
			cout << 1;
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    if(s == "ABC") dunk("ARC");
    else dunk("ABC");
    return 0;
}

Measured memory_bytes: 3628
# N, Kの入力受付
N, K = map(int, input().split())
# Dの入力受付
D = set(input().split())
# 0-9とDの差集合作成、リスト化してEに代入
E = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - D
# Nに1ずつ足して条件に合う最初の数字を特定する
result = False
while result == False:
    for i in str(N):
        if not i in E:
            N = N + 1
            result = False
            break
        else:
            result = True
print(N)

Measured memory_bytes: 9032
#include<bits/stdc++.h>
#define N 2005
using namespace std;
const int mod=924844033;
int n,k;
long long dp[2][N][2];
int st[N*2],f[N],fac[N];//start point
int main(){
	scanf("%d%d",&n,&k);
	int len=1;st[1]=1;
	for(int i=1;i<=k;i++){
		int d=(n-i)/k+1;
		len+=d;st[len]=1;
		len+=d;st[len]=1;
	}
	int now=0;
	dp[now][0][0]=1;
	for(int i=1;i<len;i++){
		memset(dp[now^1],0,sizeof(dp[0]));
		for(int j=0;j<min(i,n+1);j++){
			dp[now^1][j][0]+=dp[now][j][0]+dp[now][j][1];//不选
			if(st[i+1]!=1) dp[now^1][j+1][1]+=dp[now][j][0];
			dp[now^1][j][0]%=mod;
			dp[now^1][j][1]%=mod;
		}
		now^=1;
	}
	for(int i=0;i<=n;i++) f[i]=(dp[now][i][0]+dp[now][i][1])%mod;
	long long ans=0;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*1LL*i%mod;
	for(int i=0,j=1;i<=n;i++,j=-j)
		ans=(ans+f[i]*1LL*fac[n-i]*j)%mod;
	cout<<(ans+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


int main(){
    int n,d=0;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    rep(i,n){
        if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) d += 2;
        else if(a[i]==b[i] && b[i] != c[i]) d += 1;
        else if(a[i]==c[i] && a[i] != b[i]) d += 1;
        else if(c[i]==b[i] && a[i] != c[i]) d += 1;
    }
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map { it.toInt() }

    var red = 0
    var green = 0
    var blue = 0

    fun isMatch(it: Int): Int {
        var count = 0
        if (red == it) {
            count++
        }
        if (blue == it) {
            count++

        }
        if (green == it) {
            count++
        }
        return count

    }

    fun up(it: Int) {
        when {
            red == it -> red++
            blue == it -> blue++
            else -> green++
        }

    }


    var ans: Long = 1L
    an.forEach {
        ans *= isMatch(it)
        ans %= 1000000007L

        up(it)
    }
    println(ans)

}




Measured memory_bytes: 51444
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, target;
    cin >> len >> target;
    vector<int> freq(len, len + 1);
    set<int> unique;
    for(int i = 0; i < len; i++) {
        int a;
        cin >> a;
        a -= 1;
        if(freq[a] == len + 1)
            freq[a] = 1;
        else
            freq[a] += 1;
        unique.insert(a + 1);
    }
    if(unique.size() < target) {
        cout << 0;
        return 0;
    }
    sort(freq.begin(), freq.end());
    int ans = 0;
    for(int i = 0; i < unique.size() - target; i++) {
        ans += freq[i];
    }
    cout << ans;
}

Measured memory_bytes: 13456
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b){
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    cout << endl;
    return 0;
}


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

const long long int mod = 1000000007;

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;
    long long int m = 0;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
        m = max( m, in );
    }

    long long int ans = 0;

    for ( long long int i = 1; i <= m; i *= 2LL ) {
        long long int p = 0;
        for ( long long int j = 0; j < n; j++ ) {
            if ( ( v[j] & i ) == 0 ) p++;
        }
        long long int q = n - p;
//        cout << p << " " << q << endl;
        ans += ( ( ( p * q ) % mod ) * ( i % mod ) ) % mod;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<climits>
#include<fstream>
#include<queue>
#include<vector>
#include<map>

using namespace std;

char s1[100005];
char s2[100005];

int gcd(int a,int b)
{
    if(a%b)
    {
        return gcd(b,a%b);
    }
    return b;
}
int main()
{
    int n,m,i,j,a,b1,b2,flag;
    long long c;
    scanf("%d%d",&n,&m);
    scanf("%s",s1);
    scanf("%s",s2);
    a=gcd(n,m);
    c=(long long)n*m/a;
    b1=n/a;
    b2=m/a;
    for(i=0,j=0,flag=1;i<n&&j<m;j+=b2,i+=b1)
    {
        if(s1[i]!=s2[j])
        {
            flag=0;
            break;
        }
    }
    if(flag)
    {
        printf("%lld\n",c);
    }
    else
        printf("-1\n");
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int x;
	cin >> x;
	if (x >= 30) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


from collections import deque

def main():
    N=input()
    C = input()
    W = C.count('W')
    R = C.count('R')
    RR = C[:R].count('W')
    WW = C[-W:].count('R')
    print(min(R, W, WW, RR))




main()



Measured memory_bytes: 10100
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  double a,l,x;
  double s;
  while(~scanf("%lf%lf%lf",&a,&l,&x)){
    x+=l;
    s = sqrt(l*l - a*a/4.0) * a / 2.0;
    s += sqrt(x*x/4.0 - l*l/4.0) * l;
    printf("%.10f\n",s);
  }
}

Measured memory_bytes: 1084
import copy as cp 
H, W = map(int, input().split(" "))
L = [list(input()) for i in range(H)]
a = ["#" for i in range(W)]
A = [cp.copy(a) for i in range(H)]
for i in range(H):
  for j in range(W):
    if L[i][j] == "#":
      continue
    cnt = 0
    for ii in range(-1, 2):
      for jj in range(-1, 2):
        if ii == 0 and jj == 0:
          continue
        iii = i + ii
        jjj = j + jj
        if iii < 0 or iii > H -1:
          continue
        if jjj < 0 or jjj > W -1:
          continue
        if L[iii][jjj] == "#":
          cnt+=1
    A[i][j] = str(cnt)
for i in range(len(A)):
  print(''.join(A[i]))


Measured memory_bytes: 3700
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
a_set=sorted(list(set(a)))

flag=False
if sum(a)==0:
    flag=True
elif N%3==0:
    if len(a_set)==2:
        x,y=a_set
        if x==0 and a.count(x)*3==N:
            flag=True
    elif len(a_set)==3:
        x,y,z=a_set
        if x^y^z==0 and a.count(x)==a.count(y) and a.count(y)==a.count(z):
            flag=True

print('Yes' if flag else 'No')

Measured memory_bytes: 20828
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

#define N_size 100000000000

using namespace std;

int main(){
    long long X,Y,wa,rs=1;
    cin >> X >> Y;

    wa = X;

    while(wa < Y){
        wa *= 2;
        if(wa <= Y)
            rs++;
        else
        {
            break;
        }
        
        
    }
    
    cout << rs << endl;


}

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

map<ll, ll> mp;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        mp[x]++;
    }

    int cnt = 0;
    for (auto& it : mp) {
        if (it.second % 2) {
            cnt++;
        }
    }

    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);


//入力変数
long N=sc.nextInt();
long M=sc.nextInt();


//入力値変換


//出力変数
long ans=0;

//計算
if(N>=2&&M>=2){
    ans=(N-2)*(M-2);
}else if(N==1){
    ans=Math.abs(M-2);
}else if(M==1){
    ans=Math.abs(N-2);
}

//出力
System.out.println(ans);

}}

Measured memory_bytes: 21972
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = int(input())
for _ in range(M):
    s = input()
    if s in d:
        d[s] -= 1
    else:
        d[s] = -1

ans = 0
for v in d.values():
    ans = max(ans, v)

print(ans)


Measured memory_bytes: 3064
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)

Measured memory_bytes: 158452
def slove():
    import sys
    input = sys.stdin.readline
    n, l = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    s = sum(a)
    for i in range(1, n):
        if a[i] + a[i-1] >= l:
            print("Possible")
            for j in range(1, i):
                print(j)
            for j in range(n-1, i, -1):
                print(j)
            print(i)
            exit()
    print("Impossible")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, D;
  cin >> N >> D;
  int ans = 0;
  for(int i = 0; i < N; ++i)
  {
    int X, Y;
    cin >> X >> Y;
    double dist = sqrt(pow(X, 2) + pow(Y, 2));
    if(dist <= D)
    {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2;
}

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




int main(){
    int N;
    cin>>N;
    int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<x[N-1]<<endl;
            
    return 0;
    
}

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

#define NMAX 200005

using namespace std;
typedef long long ll;
typedef long double ld;
ll binPow(ll num, ll p, ll mod){
    if(p==0) return 1;
    ll aux=binPow(num,p/2,mod);
    return aux*aux%mod*((p&1)?num:1)%mod;
}
ll solve(ll x){
    ll iter=0;
    while(x>0){
        iter++;
        x%=__builtin_popcount(x);
    }
    return iter;
}
int main()
{
    ll n,cnt=0,num1=0,num2=0;
    string s;
    cin>>n>>s;
    for(ll i=0;i<n;i++)
        cnt+=(s[i]=='1');
    for(ll i=0;i<n;i++){
        if(s[i]=='1'){
            if(cnt>1)
                num1=(num1+binPow(2,n-i-1,cnt-1))%(cnt-1);
            num2=(num2+binPow(2,n-i-1,cnt+1))%(cnt+1);
        }
    }
    for(ll i=0;i<n;i++){
        if(s[i]=='0'){
            cout<<solve((num2+binPow(2,n-i-1,cnt+1))%(cnt+1))+1<<'\n';
        }
        else{
            if(cnt>1)
                cout<<solve((num1-binPow(2,n-i-1,cnt-1)+cnt-1)%(cnt-1))+1<<'\n';
            else cout<<"0\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3752
N = int(input())
d = list(map(int,input().split()))
#print(d)
sorted_d = sorted(d)
#print(sorted_d)

under_limit = sorted_d[int(N/2)-1]
upper_limit = sorted_d[int(N/2)]
#print(under_limit)
#print(upper_limit)
ans = upper_limit - under_limit
print(ans)

Measured memory_bytes: 14396
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

 main()

{
    fast
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int x=(h1*60)+m1;
    int y=(h2*60)+m2;
    y=y-k;
    int ses=0;
    if(x<=y)ses=y-x;
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3648
import java.util.*;
class Main {
    static boolean[] isDislike;
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();
	isDislike = new boolean[10];
	for(int i = 0; i<K; i++) {
	    isDislike[sc.nextInt()] = true;
	}
	for(int i = N; i<N*10+N%10; i++) {
	    if(!isDislikedNumber(i)) {
		System.out.println(i);
		return;
	    }
	}
    }
    public static boolean isDislikedNumber(int num) {
	int dig = 0;
	while(num>0) {
	    dig = num%10;
	    if(isDislike[dig]) {
		return true;
	    }
	    num/=10;
	}
	return false;
    }
}

Measured memory_bytes: 22612
# coding: utf-8


def solve(*args: str) -> str:
    S = args[0]
    n = len(S)

    strong = True
    for s in [S, S[:(n-1)//2], S[(n+3)//2-1:]]:
        strong &= s == s[::-1]

    return 'Yes' if strong else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int n,k;
  cin>>n>>k;
  int tmp=n/2;
  if(n%2==1)tmp++;
  if(tmp>=k)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
	fio();
	vi a(3);
	rep (i, 3) cin >> a[i];
	sort(all(a));
	if (a[0] == a[2]) {
		cout << "No" << endl;
		return 0;
	}	
	if (a[0] == a[1] or a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

string s, t;
int p[256], q[256];

int main(int argc, char **argv) {
	cin >> s >> t;
	memset(p, -1, sizeof(p));
	memset(q, -1, sizeof(q));
	REP(i, s.length()) {
		if (p[s[i]] != q[t[i]]) {
			cout << "No" << endl;
			return 0;
		}
		p[s[i]] = i;
		q[t[i]] = i;
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
	int N, i, ans = 0;
	scanf("%d", &N);
	string S;
	cin >> S;
	for(i = 1; i < N - 1; i++){
		if(S[i - 1] == 'A' && S[i] == 'B' && S[i + 1] == 'C'){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {

	body, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		log.Println(err)
	}
	scanner := bufio.NewScanner(strings.NewReader(string(body)))
	scanner.Split(bufio.ScanWords)
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading input:", err)
	}
	inputs := make([]string, 0)
	for scanner.Scan() {
		word := scanner.Text()
		word = strings.TrimSpace(word)
		inputs = append(inputs, word)
	}

	var nums []int
	for _, s := range inputs[1:len(inputs)] {
		i, _ := strconv.Atoi(s)
		nums = append(nums, i)
	}
	var counter int
	flag := false
	for {
		var buf_nums []int
		for _, i := range nums {
			if i%2 == 0 {
				buf_nums = append(buf_nums, i/2)
			} else {
				flag = true
				break
			}
		}
		if flag {
			break
		}
		nums = buf_nums
		counter++

	}

	fmt.Println(counter)
}


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

int main() {
    string s;
    cin >> s;

    for(int i = 0; i < s.length(); ++i) {
//        cout << s[i] << endl;
        if(i % 2 == 0) {
            if ( s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
            } else {
                cout << "No" << endl;
                return 0;
            }
        }

        if(i % 2 != 0) {
            if( s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
            } else {
                cout << "No" << endl;
                return 0;
            }

        }
    }
    cout << "Yes" << endl;
}


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

int main(void)
{
	char str[81];
	while(fgets(str,81,stdin) != NULL)
	{
		int i,j;
		int len = strlen(str);
		for(i = 0;i < 26;i++)
		{
			for(j = 0;j < len;j++)
			{
				if(str[j] >= 'a' && str[j] <= 'z')
				{
					str[j] = (str[j] - 'a' + 1) % 26 + 'a';
				}
				if(str[j] == '\n')
				{
					str[j] = '\0';
					len--;
				}
			}
			for(j = 0;j < len-2;j++)
			{
				if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'e')
				{
					puts(str);
					break;
				}
			}
			if(j != len-2)
				break;
			for(j = 0;j < len-3;j++)
			{
				if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'i' && str[j+3] == 's')
				{
					puts(str);
					break;
				}
			}
			if(j != len-3)
				break;
			for(j = 0;j < len-3;j++)
			{
				if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'a' && str[j+3] == 't')
				{
					puts(str);
					break;
				}
			}
			if(j != len-3)
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int  WHITE = 0;
const int GRAY =1;
const int BLACK =2;
const int NIL = -1;
const int MAX = 10000;

// 配列のサイズを大きく取りすぎるとエラーが出ないが、実行できなくなる.
vector<int> color(MAX,WHITE), D(MAX,INF);
typedef pair<int,int> node;
vector<node> adj[MAX];
priority_queue<node> HQ;
int n;

void dijkstra(){
    int u = 0;
    D[u] = 0;
    HQ.push(make_pair(0,0));
    while(!HQ.empty()){
        node p = HQ.top();HQ.pop();
        int p_w = p.first;int p_i = p.second;
        if(color[p_i]==BLACK)continue;
        color[p_i]=BLACK;

        for(auto elm : adj[p_i]){
            int v_w = elm.first; int v_i = elm.second;
            if(color[v_i]==BLACK)continue;
            if(D[p_i]+v_w < D[v_i]){
                D[v_i]=D[p_i]+v_w;
                HQ.push(make_pair(D[v_i]*(-1),v_i));
            }
        }
    }
}

int main(){
    cin >> n;
    rep(i,n){
        int id, m;
        cin >> id>>m;
        rep(j,m){
            int opp;cin>>opp;
            int cost; cin >> cost;
            adj[i].push_back(make_pair(cost,opp));
        }
    }
    dijkstra();
    rep(i,n){
        cout<<i << " " << D[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 8164
H,W = map(int,input().split())
S = [input() for _ in range(H)]

dx = [-1,0,1]
dy = [-1,0,1]

for j, ss in enumerate(S):
    ans = ''
    for i in range(W):
        if ss[i] == '#':
            ans += '#'
        else:
            cnt = 0
            for n in dx:
                for m in dy:
                    if n == 0 and m == 0:
                        continue
                    if i+n >= 0 and i+n < W and j+m >= 0 and j+m < H:
                        if S[j+m][i+n] == '#':
                            cnt += 1
            ans += str(cnt)
    print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
	char ch[3][3];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)
		{
			cin >> ch[i][j];
		}
	}

	cout << ch[0][0] << ch[1][1] << ch[2][2] << endl;

	return 0;
}

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

using namespace std;

const int N = (int) 1e6 + 7;

int a[N], dp[N];

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

Measured memory_bytes: 4736
public class
Main
{
  private int[ ][ ] opt_p;
  private int[ ][ ] opt_w;
  private int[ ] p;
  private int[ ] w;
  private int n;
  private int c;
  
  private void
  dp (
    )
  {
    int i, j;

    opt_p = new int[ n + 1 ][ c + 1 ];
    opt_w = new int[ n + 1 ][ c + 1 ];
    
    /* (1) 基底 */
    for ( i = 0; i <= c; ++i )
    {
      opt_p[ 0 ][ i ] = 0;
      opt_w[ 0 ][ i ] = 0;
    }
    
    /* (2) 再帰逆行 */
    for ( i = 1; i <= n; ++i )
    for ( j = 0; j <= c; ++j )
    {
      opt_p[ i ][ j ] = opt_p[ i - 1 ][ j ];
      opt_w[ i ][ j ] = opt_w[ i - 1 ][ j ];
      if ( w[ i - 1 ] <= j )
      {
        final int tmp_p = opt_p[ i - 1 ][ j - w[ i - 1 ] ] + p[ i - 1 ];
        final int tmp_w = opt_w[ i - 1 ][ j - w[ i - 1 ] ] + w[ i - 1 ];
        if ( tmp_p > opt_p[ i ][ j ]
          || ( tmp_p == opt_p[ i ][ j ] && tmp_w < opt_w[ i ][ j ] ) )
        {
          opt_p[ i ][ j ] = tmp_p;
          opt_w[ i ][ j ] = tmp_w;
        }
      }
    }
  }
  
  public void
  run (
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int no = 0;
    int i;
    
    for ( ; ; )
    {
      c = sc.nextInt ( );
      if ( c == 0 ) break ;
      n = sc.nextInt ( );
      w = new int[ n ];
      p = new int[ n ];
      for ( i = 0; i < n; ++i )
      {
        String[ ] s = sc.next ( ).split ( "," );
        p[ i ] = Integer.parseInt ( s[ 0 ] );
        w[ i ] = Integer.parseInt ( s[ 1 ] );
      }
      
      dp ( );
      System.out.println ( "Case " + ( ++no ) + ":" );
      System.out.println ( opt_p[ n ][ c ] );
      System.out.println ( opt_w[ n ][ c ] );
    }
    
    return ;
  }
  
  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( );
    
    return ;
  }
}

Measured memory_bytes: 31972
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<vii, int> cnt;
    ll ans = 0;
    vvii app(n);
    rep(i,n){
        string s;
        cin >> s;
        vii str(26);
        rep(j,10){
            str[s[j] - 'a']++;
        }
        cnt[str]++;
        app[i] = str;
    }
    rep(i,n){
        ans += (ll)cnt[app[i]] - 1;
    }
    cout << ans / 2 << ENDL;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
char t[1010][1010];
struct node{
    int x,y,lvl;
    node(int x,int y){
        this->x = x;
        this->y = y;
        this->lvl = 0; 
    }
};
int n,m;
bool ok(int i,int j){
    return (i>=0 && i < n && j >= 0 && j < m);
}
int32_t main(){
    cin >> n >> m;
    queue<node> q;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> t[i][j];
            if(t[i][j]=='#'){
                q.push(node(i,j));
            }
        }
    }
    int dx[] = {0,0,1,-1};
    int dy[] = {1,-1,0,0};
    while(!q.empty()){
        node now = q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int nx = now.x + dx[i];
            int ny = now.y + dy[i];
            if(ok(nx,ny) && t[nx][ny]!='#'){
                node nxt = node(nx,ny);
                nxt.lvl = now.lvl + 1;
                q.push(nxt);
                t[nx][ny] = '#';
            }
        }
        if(q.empty()){
            cout << now.lvl << endl;
        }
    }
} 

Measured memory_bytes: 25396
n=int(input())
a=list(map(int,input().split()))
ok=True

v=[0 for i in range(n+2)]
import time

#start=time.time()
nextv=0

nec=2**n

for i in range(n,-1,-1):

    if nec>=v[i+1]+a[i]:
        v[i]=v[i+1]+a[i]
    else:
        v[i]=nec

    nec=nec >>1



#print(time.time()-start)

for i in range(1,n+1):
    if v[i-1]-a[i-1]<0:
        ok=False
        break
    if (v[i-1]-a[i-1])*2<v[i]:
        v[i]=(v[i-1]-a[i-1])*2


if n==0:
    if a[0]!=1:ok=False
else:
    if a[0] != 0:ok = False

if v[n]!=a[n]:ok=False

ans=sum(v)
if ans==0:ok=False

if ok:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 20168
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        long N = nextLong();
        long M = nextLong();

        long MOD = 1_000_000_007L;

        if(Math.abs(N - M) > 1) {
            writer.println(0);
        } else {
            long pA = 1L;
            long pB = 1L;
            // start with N
            long A = N;
            long B = M;
            while(A > 0 && B > 0) {
                pA *= ( A  );
                pA %= MOD;
                pA *= ( B );
                pA %= MOD;
                --A;
                --B;
            }
            boolean isValidA = (B >= 0 && (A == 0));
            A = N;
            B = M;
            while(A > 0 && B > 0) {
                pB *= (A );
                pB %= MOD;
                pB *= (B);
                pB %= MOD;
                --A;
                --B;
            }
            boolean isValidB = ( A >= 0 && (B == 0));
            long ret = 0L;
            if(isValidA) ret += pA;
            if(isValidB) ret += pB;
            ret %= MOD;
            writer.println(ret);

        }
    }


    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX = 100005;
struct Node {
	int key;
	Node *parent, *left, *right;
};
Node *root, *NIL;

//????????????
void PreorderTreeWalk(Node *u) {
	if (u == NIL)
		return;
	printf(" %d", u->key);
	PreorderTreeWalk(u->left);
	PreorderTreeWalk(u->right);
}
//????????????
void InorderTreeWalk(Node *u) {
	if (u == NIL)
		return;
	InorderTreeWalk(u->left);
	printf(" %d", u->key);
	InorderTreeWalk(u->right);
}


void insert(int value) {
	Node *y = NIL, *x = root;
	Node *z = new Node();
	z->key = value;
	z->left = z->right = NIL;

	// ????????????????????????
	while (x != NIL) {
		y = x;
		// z ??? x ?°???? ??????x????????§??????
		// z ??? x ??§??? ??????x????????§??????
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	z->parent = y;

	// ????????¶????????????root
	if (y == NIL) {
		root = z;
	}else {
		// z ??? y ?°???? ?????¨y????????§
		// z ??? y ??§??? ?????¨y????????§
		if (z->key < y->key)
			y->left = z;
		else
			y->right = z;
	}
}

Node * find(Node *u, int value) {
	
	// ????????????????§?????????????
	while (u != NIL && u->key != value) {
		if (value < u->key)
			u = u->left;
		else
			u = u->right;
	}
	return u;
}

//??????????°????
Node *treeMinimum(Node * x) {
	while (x->left != NIL)
		x = x->left;
	return x;
}

Node *treeSuccessor(Node *x) {
	if (x->right != NIL)
		return treeMinimum(x->right);

	Node *y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		x = y->parent;
	}
	return y;
}

void treeDelete(Node * z) {
	Node *y, *x;  // ????????????????±????y????????????

	// ????????????????????????
	if (z->left == NIL || z->right == NIL)
		y = z;
	else
		y = treeSuccessor(z);

	// ??????y????????????x
	if (y->left != NIL)
		x = y->left;
	else
		x = y->right;

	if (x != NIL)
		x->parent = y->parent;
	
	if (y->parent == NIL)
		root = x;
	else {
		if (y == y->parent->left)
			y->parent->left = x;
		else
			y->parent->right = x;
	}


	if (y != z)
		z->key = y->key;

	delete y;
}

int main() {
	int n, value;
	Node * f;
	char s[200];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		if (s[0] == 'i') {
			scanf("%d", &value);
			insert(value);
		}
		else if (s[0] == 'f') {
			scanf("%d", &value);
			f = find(root,value);
			if (f != NIL)
				printf("yes\n");
			else
				printf("no\n");
		}
		else if (s[0] == 'd') {
			scanf("%d", &value);
			treeDelete(find(root, value));
		}
		else {
			InorderTreeWalk(root);
			printf("\n");
			PreorderTreeWalk(root);
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 21952
using System;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string cards = Console.ReadLine();
                if (cards == "-")
                {
                    break;
                }
                
                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++)
                {
                    int h = (int.Parse(Console.ReadLine()));
                    cards = cards.Substring(h) + cards.Substring(0, h);
                }
                Console.WriteLine(cards);
            }
        }
    }
}

Measured memory_bytes: 8844
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;

const int N = 1e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b,k;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<nl;return 0;
        }

    }
    cout<<"NG"<<nl;
    return 0;
}


Measured memory_bytes: 3652