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

using namespace std;

const int mod = 1e9 + 7;

void add(int &x, int y) {
   x += y;
   if (x >= mod) x -= mod;
}

int mul(int x, int y) {
   return (long long) x * y % mod;
}

int main() {
   ios_base::sync_with_stdio(false);
   int n, k;
   cin >> n >> k;
   vector<int> vals;
   for (int i = 1; i * i <= n; ++i) {
      int j = n / i;
      vals.push_back(i);
      if (i < j) vals.push_back(j);
   }
   sort(vals.begin(), vals.end());
   n = vals.size();
   vector<int> f(n);
   for (int i = 0; i < n; ++i) {
      f[i] = (i == 0 ? 1 : vals[i] - vals[i - 1]);
   }
   for (int i = 0; i < k - 1; ++i) {
      vector<int> nf(n);
      int now = 0;
      for (int i = n - 1; i >= 0; --i) {
         add(now, f[n - 1 - i]);
         nf[i] = mul(now, (i == 0 ? 1 : vals[i] - vals[i - 1]));
      }
      f = nf;
   }
   int ans = 0;
   for (int i = 0; i < n; ++i) {
      add(ans, f[i]);
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 1148
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    char str[205]={0};
    scanf("%s", str);

    long max=-1;
    long i;
    for(i=1; i<strlen(str)/2; i++) {
        if(strncmp(str, str+i, i)==0) {
            max=i;
        }
    }

    printf("%ld\n", max*2);


    return 0;
}


Measured memory_bytes: 128
import sys
X, N = map(int, input().split())
P = input().split()

if N==0:
    print(X)
    sys.exit()
for i in range(101):
    ans = int(X)-i
    if str(ans) not in P:
        print(ans)
        break
    ans2 = int(X)+i
    if str(ans2) not in P:
        print(ans2)
        break


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    ll A,B;
    for(ll b = -200; b < 200; b++){
        for(ll a = b; a < 200; a++){
            if((a*a*a*a*a - b*b*b*b*b) == X){
                A = a;
                B = b;
                break;
            }
        }
    }
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 3584
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val PY = (0 until M).map { Triple(it, sc.next().toInt(), sc.next().toInt()) }
            .sortedBy { it.third }
        val seq = IntArray(N)
        val ans = LongArray(M)
        PY.forEach {
            val p = it.second - 1
            seq[p]++
            ans[it.first] = (p + 1) * 1000000L + seq[p]
        }
        ans.forEach {
            pw.printf("%012d\n", it)
        }
    }
}


Measured memory_bytes: 130212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
	int n,W;cin>>n>>W;
	vector<int> v(n),w(n);
	rep(i,n)cin>>w[i]>>v[i];

  vector<vector<ll>> dp(n+1,vector<ll>(W+1));
  rep(i,W+1)dp[0][i] = 0;

  for(int i = 1;i <= n;++i){
    rep(j,W+1){
      dp[i][j] = dp[i-1][j];
      if(j-w[i-1] >= 0)chmax(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
    }
  }
  print(dp[n][W]);
  return 0;
}

Measured memory_bytes: 83008
#include <iostream>
#include <cmath>
using namespace std;

typedef long long ll;
int F(ll a, ll b){
  ll k =(a>b)?a:b;
  int x=0;
  while(k!=0){
    k/=10; x++;
  }
  return x;
}
int main(){
  ll n;  cin>>n;
  int ans=9999999;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0){
      ans = min(F(i,n/i),ans);
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 256
import sys, math, bisect
sys.setrecursionlimit(200010)

def input():
    return sys.stdin.readline()[:-1]

def main():
    A, B, Q = map(int,input().split())
    s = [-10**12] + sorted([int(input()) for k in range(A)]) + [10**12]
    t = [-10**12] + sorted([int(input()) for k in range(B)]) + [10**12]
    for _ in range(Q):
        q = int(input())
        s1 = s[bisect.bisect_left(s,q)]
        s2 = s[bisect.bisect_left(s,q)-1]
        t1 = t[bisect.bisect_left(t,q)]
        t2 = t[bisect.bisect_left(t,q)-1]
        d1 = max(q-s2,q-t2)
        d2 = max(s1-q,t1-q)
        d3 = 2*(q-s2)+t1-q
        d4 = 2*(q-t2)+s1-q
        d5 = 2*(s1-q)+q-t2
        d6 = 2*(t1-q)+q-s2
        print(min(d1,d2,d3,d4,d5,d6))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12780
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sum_up(x)  (x*(x+1))/2
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b

using namespace std;

void base()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/*
bool prime[100001];
void sieve(int n)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

double float_sq(double n)
{
    double x = n;
    double y = 1;
    double e = 0.000001;
    while (x - y > e)
    {
        x = (x + y) / 2;
        y = n / x;
    }
    return x;
}

int int_sq(int x)
{
    if (x == 0 || x == 1)
        return x;
    int start = 1, end = x, ans;
    while (start <= end)
    {
        int mid = (start + end) / 2;
        if (mid*mid == x)
            return mid;
        if (mid*mid < x)
        {
            start = mid + 1;
            ans = mid;
        }
        else
            end = mid-1;
    }
    return ans;
}*/

int32_t main()
{
    base();
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    multiset<int>st;
    for(int i=0;i< n;i++) {
        auto itr = st.lower_bound(v[i]);
        if (st.size() == 0) st.insert(v[i]);
        if (itr == st.begin()) st.insert(v[i]);
        else{
        itr--;
        st.erase(itr);
        st.insert(v[i]);
        }
    }
    cout<<st.size();
    return 0;
}


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


void solve(std::vector<long long> x){
    rep(i,5){
        if(x[i] == 0){
            cout << i+1 << endl;
            return;
        }
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3692
import itertools

N = int(input())
count = [0, 0, 0, 0, 0]
for _ in range(N):
    l = input()[0]
    if l == 'M':
        count[0] += 1
    elif l == 'A':
        count[1] += 1
    elif l == 'R':
        count[2] += 1
    elif l == 'C':
        count[3] += 1
    elif l == 'H':
        count[4] += 1
ans = 0
for c in itertools.combinations(count, 3):
    ans += c[0]*c[1]*c[2]

print(ans)


Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int n,m,ta=1;
signed main(){
	cin>>n>>m;
	if(abs(n-m)>=2){
		cout<<0<<endl;
		return 0;
	}
	if(abs(n-m)==1){
		for(int i=max(n,m);i>=2;i--){
			if(i==max(n,m))ta=ta*i%1000000007;
			else{
				ta=ta*i%1000000007*i%1000000007;
			}
		}
	}
	else {
		for(int i=n;i>=2;i--){
			ta=ta*i%1000000007*i%1000000007;
		}
		ta=ta*2%1000000007;
	}
	cout<<ta<<endl;
}


Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var S,T string
	fmt.Scan(&S)
	fmt.Scan(&T)
	if S[0:len(S)] == T[0:len(S)]{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1756
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N, M;
ll a[100000];
ll cnt[100000];

ll logll(ll n){
    ll ans = 0;
    while(n%2 == 0){
        ans++;
        n /= 2;
    }
    return ans;
}

template <typename T>
T gcd(T a, T b){
    if(a < b) swap(a, b);
    while(b != 0){
        T tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

template <typename T>
T lcm(T a, T b){
    return (a*b)/gcd<T>(a, b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    ll cnt_max = -1;
    ll cnt_min = 100;
    for(ll i = 0; i < N; i++){
        cin >> a[i];
        cnt[i] = logll(a[i]);
        cnt_max = max(cnt_max, cnt[i]);
        cnt_min = min(cnt_min, cnt[i]);
    }
    if(cnt_max != cnt_min){
        cout << 0 << endl;
        return 0;
    }
    for(ll i = 0; i < N; i++){
        while(a[i]%2 == 0){
            a[i] /= 2;
        }
    }
    ll pow = 1;
    for(ll i = 0; i < cnt[0]; i++) pow *= 2;
    M /= (pow/2);
    ll lc = 1;
    for(int i = 0; i < N; i++){
        lc = lcm<ll>(lc, a[i]);
        if(lc > M){
            cout << 0 << endl;
            return 0;
        }
    }
    // cout << lc << ' ' << M << endl;
    cout << (M/lc+1)/2 << endl;
}

Measured memory_bytes: 1792
from collections import deque

K = int(input())
que = deque()
runrun = []

for i in range(1,10):
    que.append(i)

def abs01(n):
    if n == 0:
        return [0,1]
    elif n == 9:
        return [8,9]
    else:
        return [n-1,n,n+1]

while True:
    n = que.popleft()
    n_simo1 = int(str(n)[-1])
    nums = abs01(n_simo1)
    for num in nums:
        que.append(n*10+num)
    runrun.append(n)
    if len(runrun) == K:
        print(runrun[-1])
        #print(runrun)
        #print(que)
        exit()


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


void solve(long long N, std::string S){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;

    int i, j;
    int ans = 0;
    int here;
    // 斜めに(i,j)=(l-k,N-1-k) for k for l
    for(int l=0; l<N; l++){
      stack<int> row;
      // k=0
      i = l;
      j = N-1;
      if(S[i] == S[j]){
	here = min(1,j-i);
      }
      else{
	here = 0;
      }
      row.push(here);
      if(here > ans) ans = here;	

      for(int k=0; l-k>0; k++){
	if(S[l-k-1] == S[N-1-k-1]) {
	  here = min(row.top()+1,j-i);
	  row.push(here);
	  if(here > ans) ans = here;
	}
	else{
	  row.push(0);
	}
      }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;

int pow10(int n){
    int res=1;
    rep(i,n) res*=10;
    return res;
}

inline int digit(int n){
    return log10(n)+1;
}

int main(){
    cin>>N;

    int res[10][10];
    rep(i,100) res[i/10][i%10]=0;
    repn(n,N){
        int bbegin=n/pow10(digit(n)-1);
        int bend=n%10;
        res[bbegin][bend]++;
    }

    int ans=0;
    repn(abegin,9){
        repn(aend,9){
            ans+=res[abegin][aend]*res[aend][abegin];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
N=int(input())
d=map(int,input().split())
d=sorted(d)

num=0
ans=0
i=0
mid=len(d)/2
while num!=len(d):
    i+=1
    while d[num]<i:
        num+=1
        if(num==len(d)):
            break
    if(num==mid):
        ans+=1
print(ans)

Measured memory_bytes: 14428
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import gcd
def main():
    a, b, c, d = map(int, input().split())
    if a == b:
        if a % c != 0 and a % d != 0:
            print(1)
            sys.exit()
        else:
            print(0)
            sys.exit()
    atob = b - a + 1
    divc = b // c - (a - 1) // c
    divd = b // d - (a - 1) // d
    cd = c * d // gcd(c, d)
    divcd = b // cd - (a - 1) // cd
    r = atob - divc - divd + divcd
    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			long n = sc.nextInt();
			if(n == 0) break;
			long count=0;			
			for(long i=1; i<=n; i++){
				long x = i;
				for(int j=11; j>0; j--) 
					while(x%Math.pow(5,j)==0){count+=j;	x /= Math.pow(5,j);}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int n;
  int vac[3][100005];
  int dp[3][100005];
  
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>vac[j][i];
    }
  }
  
  for(int i=0;i<3;i++){
    dp[i][0]=vac[i][0];
  }

  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      if(j==0)dp[j][i]=max(dp[j+1][i-1],dp[j+2][i-1])+vac[j][i];
      if(j==1)dp[j][i]=max(dp[j+1][i-1],dp[j-1][i-1])+vac[j][i];
      if(j==2)dp[j][i]=max(dp[j-1][i-1],dp[j-2][i-1])+vac[j][i];
    }
  }
  
  cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1])<<"\n";

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<ll> a(N);
  ll ans = 0;
  REP(i,N) {
    cin>>a[i];
  }
  int num = 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  num += 2;
  ans += a[0];
  for(int i = 1; i < N; i++) {
    if(num == N) break;
    if(num + 1 == N) {
      ans += a[i];
      num++;
    } else {
      ans += 2LL * a[i];
      num += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int k; cin >> k;
    ll ans = 0;
    if(k%2==0) cout << -1 << endl;
    else if(k%5==0) cout << -1 << endl;
    else{
        ll num = 7, col = 1;
        while(num%k != 0) {
            ans++;
            num %= k;
            col *= 10;
            col %= k;
            num += 7*col;
        }
        cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int ncr(int n){
    int val = n*(n-1)/2;
    return val;
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int ans = 0;
    if(n > 1)
        ans += ncr(n);
    if(m > 1)
        ans += ncr(m);
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

void count(vector<int> v,vector<int>& ans){
    sort1(v);
    int n=v.size();
  int k=1;
  int i=1;
  bool bl=true;
    while(true){
    while(bl){
        if(v[i-1]==v[i]){
        k++;    
      }else{
          bl=false;
      }
      i++;
      }
      ans.push_back(k);
      if(i>=(n-1))break;
      k=1;
      bl=true;
    }
    }




int main() {
    string s,t;
    cin >> s >>t;
    int n=s.length();
    if(s==t.erase(n)){
        cout << "Yes";
    }else{
        cout <<"No";
    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  ll N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i * i <= N; i++){
    if (N % i != 0) continue;
    ll m = N / i - 1;
    if (i < m) ans += m;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    char s[n+1],t[n+1];
    scanf("%s",s);
    scanf("%s",t);
    for(int i=0;i<n*2;i++){
        if(i%2){
            printf("%c",t[i/2]);
        }else{
            printf("%c",s[i/2]);
        }
    }
    return 0;
}


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

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

typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;

  int ret = 0;

  for(int i=0; i<n; i++){
    int h;
    cin >> h;
    if(h >= k) ret++;
  }

  cout << ret << endl;

  return 0;
}


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

int main() {
  ll a,b,mod=2019;
  cin>>a>>b;
  if(b-a>=10000){
    cout<<0<<endl;
    return 0;
  }
  ll ans=2019;
  for(ll i=a;i<min(a+2020,b);i++){
    for(ll j=i+1;j<=b;j++){
      ans=min(ans,(i*j)%mod);
      if(ans==0){
        cout<<0<<endl;
        return 0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n;
	cin>>n;
	int a,b,c;
	cin>>a>>b>>c;
	int ta=a,tb=b,tc=c;
	int t1=a,t2=b,t3=c;
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		ta=a+max(t2,t3);
		tb=b+max(t1,t3);
		tc=c+max(t1,t2);
		t1=ta;t2=tb;t3=tc;
	}
	// cout<<ta<<" "<<tb<<" "<<tc<<endl;
	cout<<max(ta,max(tb,tc));
}


Measured memory_bytes: 3644
/**
 *  author: arpunagar
 *
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define db(x) cout << (#x) << " is " << (x) << endl;
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

/*******************************************/

void solve(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;

	cout << max({a*c,b*d,a*d,b*c});
}

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int t = 1;

        while (t--)
            solve();
        return 0;
}






Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

const ll M = 1000000007;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    ll n,blue;
    cin >> n >> blue;
    ll red = n-blue;
    fac[0] = 1LL;
    ifac[0] = 1LL;
    for(ll i = 0LL; i<300000LL; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    for(ll i=1LL; i<=blue; i++){
        // 青いボールを入れる位置を決定
        ll p = comb(red+1LL,i) % M;
        // 青いボールの入れ方を決定
        ll q = comb(blue-1,i-1) % M;
        cout << (p*q)%M << endl;
    }
    return 0;
}

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

int main(){
    long n,k;
    cin >> n >> k;
    unsigned long a[n];
    unsigned long long b=1,c=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        //cout << a[i];
    }
    for(int i=0;i<k;i++){
        b += a[i];
    }
    c = b;
    //cout << b;
    int j = 0;
    for(int i=k;i<n;i++){
        c += a[i];
        c -= a[j];
        //cout << c;
        if(c>b){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        b = c;
        j++;
    }
}

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

using namespace std;

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

  // delete row
  for (int i = 0; i < a.size();) {
    if (a[i].find('#') == string::npos) {
      a.erase(a.begin() + i, a.begin() + i + 1);
      continue;
    }

    ++i;
  }

  // delete column
  for (int w_i = 0; w_i < W;) {
    string tmp;
    for (int h_i = 0; h_i < a.size(); ++h_i) {
      tmp.push_back(a[h_i][w_i]);
    }

    if (tmp.find('#') == string::npos) {
      for (int k = 0; k < a.size(); ++k) {
        a[k].erase(w_i, 1);
      }
      W--;
      continue;
    }

    ++w_i;
  }

  for (int i = 0; i < a.size(); ++i) {
    cout << a[i] << endl;
  }

}

Measured memory_bytes: 256
import itertools

N=int(input())
P=int("".join(list(input().split())))
Q=int("".join(list(input().split())))
L=list(itertools.permutations(map(str, range(1,N+1)),N))
for i in range(len(L)):
  L[i]=int("".join(L[i]))
sorted(L)
print(abs(L.index(P)-L.index(Q)))


Measured memory_bytes: 14212
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000


int main() {
	set<int>s;
	map<int, long long>mp;
	int a[2000];
	int b[2000];
	int n, m, x;
	long long y,ans;
	while (true) {
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0)return 0;
		a[0] = 0;
		f(i, n) {
			scanf("%d", &x);
			a[i + 1] = a[i] + x;
		}
		b[0] = 0;
		f(i, m) {
			scanf("%d", &x);
			b[i + 1] = b[i] + x;
		}
		s.clear();
		mp.clear();
		f(i, n) {
			for (int j = i + 1; j <= n; j++) {
				x = a[j] - a[i];
				if (s.count(x) == 1) {
					y = mp[x];
					mp[x] = y + 1;
				}
				else {
					s.insert(x);
					mp[x] = 1;
				}
			}
		}
		ans = 0;
		f(i, m) {
			for (int j = i + 1; j <= m; j++) {
				x = b[j] - b[i];
				if (s.count(x) == 1)ans += mp[x];
			}
		}
		printf("%lld\n", ans);

	}




	return 0;
}


Measured memory_bytes: 34064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

int const MAX = 2000000;
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;
}

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

    COMinit();
    int n, k; std::cin >> n >> k;
    std::cout << COM(k, n) << std::endl;
    
    return 0;
}


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

int main(void){
    // Your code here!
   vector <char> s;
   string p;
   cin >> p;
   for(char d:p) s.push_back(d);
   
   int q;
   int flag = 0;
   cin >> q;
   
   rep(i,q){
      int d;
      cin >> d;
      if(d==1){
         flag = (flag+1)%2;
         continue;
      }
      char e;
      cin >> d >> e;
      if((d+flag)==2){
         s.push_back(e);
      }
      else{
           s.insert(s.begin(),e);
      }
   }
   if(flag==1)  reverse(s.begin(),s.end());

   for(char h:s) cout << h ;
   cout << endl;
}


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

using namespace std;

const int N = 2;

int n, k;

set<int> get(vector<int> a) {
    set<int> res;
    for (int i = 0; i < (1 << n); i++) {
        int cur = 0;
        int has = 0;
        for (int j = 0; j < a.size(); j++) {
            if (a[j] == i) {
                if (!has) {
                    has = 1;
                    cur ^= a[j];
                } else {
                    cur ^= a[j];
                    has = 0;
                }
            } else if (has) {
                cur ^= a[j];
            }
        }
        res.insert(cur);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    if (n <= 2) {
        vector<int> a;
        for (int i = 0; i < (1 << n); i++) {
            a.push_back(i);
            a.push_back(i);
        }
        int f = 0;
        while (1) {
            set<int> val = get(a);
            if (val.size() == 1 && *val.begin() == k) {
                for (int u : a) cout << u << ' ';
                    cout << endl;
                f = 1;
                break;
            }
            if (!next_permutation(a.begin(), a.end())) break;
        }
        if (!f) {
            cout << -1 << endl;
        }
        return 0;
    }
    if (k >= (1 << n)) {
        cout << -1 << endl;
        return 0;
    }
    if (k == 0) {
        for (int i = 0; i < (1 << n); i++) {
            cout << i << ' ' << i << ' ';
        }
        cout << endl;
        return 0;
    }
    cout << 0 << ' ' << k << ' ' << 0 << ' ';
    for (int i = 1; i < (1 << n); i++) {
        if (i != k) {
            cout << i << ' ';
        }
    }
    cout << k << ' ';
    for (int i = (1 << n) - 1; i > 0; i--) {
        if (i != k) {
            cout << i << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
int a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,m,h,p[101],df[51];
string t,x,q,s;
double w;
vector<ll>dv[101],v,z;
vector<string>u;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(dv[x][i]==0){
            dfs(dv[x][i]);
            df[dv[x][i]]=1;
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>s>>t;
    e=10000;
    for(i=0;i<=s.size()-t.size();i++){
        d=0;
        for(j=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                d++;
            }
        }
        e=min(e,d);
    }
    cout<<e;
}

Measured memory_bytes: 3640
import java.util.*;
class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[][] arrays = new String[N][3];
        for(int i=0;i<N;i++){
            arrays[i][0] = sc.next();
            arrays[i][1] = sc.next();
            arrays[i][2] = String.valueOf(i+1);
        }
        sc.close();
        Arrays.sort(arrays, (a,b)->Integer.compare(Integer.parseInt(b[1]), Integer.parseInt(a[1])));
        Arrays.sort(arrays, (a,b)->a[0].compareTo(b[0]));
        for(int i=0;i<N;i++){
            System.out.println(arrays[i][2]);
        }

    }
}

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

ll solve(vector<ll> &arr, int ind, int k, vector<ll> &memo ) {
	if( ind >= arr.size() )
		return INT_MAX;
	if( ind == arr.size()-1 )
		return 0;

	if( memo[ind] != -1 ) 
		return memo[ind];

	ll cost = INT_MAX;
	for( int i=ind+1; i<=ind+k && i<arr.size(); i++ ) {
		cost = min(cost, abs(arr[ind]-arr[i]) + solve(arr, i, k, memo) );
	}

	return memo[ind] = cost;
}

int main() {

  	int n,k;
  	cin>>n>>k;
  	vector<ll> arr(n, 0);
  	vector<ll> memo(n, -1);
  	for( int i=0;i<n;i++ ) cin>>arr[i];

  	cout<<solve(arr, 0, k, memo);

  	return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;
// #include "prettyprint.hpp"

typedef long long ll;

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

    if (e - a <= k)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::max($x, max!($($y),+)));
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::min($x, min!($($y),+)));
}

// solution 
use std::cmp;
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet};
fn main() {
    input! {
        H: usize,
        W: usize,
        D: usize,
        A: [[usize1;W];H],
        Q: usize,
        lr: [(usize1, usize1); Q],
    }

    let mut ind_flat: Vec<(usize, usize)> = (0..H*W).map(|i| (i/W, i%W)).collect();
    ind_flat.sort_by_key(|ind| A[ind.0][ind.1]);
    let mut sum_cost = vec![0; H*W]; 

    for score in D..H*W {
        sum_cost[score] = sum_cost[score - D] +
            cmp_cost(ind_flat[score-D], ind_flat[score]);
    }

    for &(l, r) in lr.iter() {
        println!("{}", sum_cost[r] - sum_cost[l]);
    }
}

fn cmp_cost(prev: (usize, usize), next: (usize, usize)) -> usize {
    cmp::max(prev.0, next.0) - cmp::min(prev.0, next.0) + 
        cmp::max(prev.1, next.1) - cmp::min(prev.1, next.1)
}


Measured memory_bytes: 11388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

void dfs(vector<P>* a, int root, vector<int>& color){
  for(P x : a[root]){
    if(color[x.first] == -1){
      if(x.second % 2){
        color[x.first] = color[root] ? 0 : 1;
      }
      else{
        color[x.first] = color[root];
      }
      dfs(a, x.first, color);
    }
  }
}

int main(){
  int N,u,v,w;
  cin >> N;
  vector<P> a[N];
  vector<int> color(N,-1);
  REP(i, N-1){
    cin >> u >> v >> w;
    a[u-1].push_back(make_pair(v-1,w));
    a[v-1].push_back(make_pair(u-1,w));
  }
  color[0] = 0;
  dfs(a,0,color);
  for(int c : color){
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18;
const ll INF=1LL<<50;

int main(){
    
    int N,Q;cin>>N>>Q;
    vector<ll> A(N),X(Q),rsum(N),oddsum(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<Q;i++){
        cin>>X[i];
    }
    
    for(int i=N-1;i>=0;i--){
        if(i==N-1) rsum[i]=A[i];
        else rsum[i]=rsum[i+1]+A[i];
    }
    
    if(N%2==1){
        for(int i=0;i<N;i++){
            if(i==0) oddsum[i]=A[i];
            else if(i%2==0) oddsum[i]=oddsum[i-2]+A[i];
            else oddsum[i]=oddsum[i-1];
        }
    }else{
        for(int i=1;i<N;i++){
            if(i==1) oddsum[i]=A[i];
            else if(i%2==1) oddsum[i]=oddsum[i-2]+A[i];
            else oddsum[i]=oddsum[i-1];
        }
    }
    
    for(int q=0;q<Q;q++){
        ll left=0,right=INF;
        while(right-left>1){
            ll mid=(left+right)/2;
            auto leftit=lower_bound(all(A),X[q]-mid),rightit=lower_bound(all(A),X[q]+mid);
            if(distance(leftit,rightit)>distance(rightit,A.end())) right=mid;
            else left=mid;
        }
        auto leftit=lower_bound(all(A),X[q]-left),rightit=lower_bound(all(A),X[q]+left);
        int a=distance(A.begin(),leftit),b=distance(leftit,rightit),c=distance(rightit,A.end());
        //cout<<left<<" "<<a<<" "<<b<<" "<<c<<endl;
        if(N%2==0){
            if(a==0) cout<<rsum[N-c]<<endl;
            else if(b==c) cout<<oddsum[a-1]+rsum[N-c]<<endl;
            else if(b+1==c) cout<<oddsum[N-1-b-c]+rsum[N-c]<<endl;
            else cout<<oddsum[a-1]+rsum[N-(b+c)/2]<<endl;
        }else{
            if(a==0) cout<<rsum[N/2]<<endl;
            else if(a==N) cout<<oddsum[a-1]<<endl;
            else if((b+c)%2) cout<<oddsum[a-2]+rsum[N-c]<<endl;
            else cout<<oddsum[a-1]+rsum[N-(b+c)/2]<<endl;
        }
    }
    
}


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, k);
    For(i, a+1) For(j, b+1){
        if(i*j + (a-i)*(b-j) == k){
            Cout("Yes"); return 0;
        }
    }
    Cout("No");
}





Measured memory_bytes: 256
#coding: utf-8
i = 0
AC = 0
WA = 0
TLE = 0
RE = 0
num = int(input())
#print(num)
while i <num:
  line = input()
  #print(line)
  if line == "AC":
    AC += 1
  if line == "WA":
    WA += 1
  if line == "TLE":
    TLE += 1
  if line == "RE":
    RE += 1
  i += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 9220
// Problem : A - Next Alphabet
// Contest : AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
char c;
cin>>c;
c=c+1;
cout<<c;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, W, H, L, R, C;
string S, T;

int main() {
    int q;
    cin >> S >> T >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    int s = (int)S.size();
    int t = (int)T.size();
    vector<ll> sa(s + 1), sb(s + 1);
    vector<ll> ta(t + 1), tb(t + 1);

    for (int i = 0; i < s; i++) {
        if (S[i] == 'A') {
            sa[i + 1] = 1;
        } else {
            sb[i + 1] = 1;
        }
    }
    for (int i = 0; i < t; i++) {
        if (T[i] == 'A') {
            ta[i + 1] = 1;
        } else {
            tb[i + 1] = 1;
        }
    }
    for (int i = 0; i < s; i++) {
        sa[i + 1] += sa[i];
        sb[i + 1] += sb[i];
    }
    for (int i = 0; i < t; i++) {
        ta[i + 1] += ta[i];
        tb[i + 1] += tb[i];
    }

    vector<bool> ans(q);
    for (int i = 0; i < q; i++) {
        ll snum = (sa[b[i]] - sa[a[i] - 1]) + (sb[b[i]] - sb[a[i] - 1]) * 2;
        ll tnum = (ta[d[i]] - ta[c[i] - 1]) + (tb[d[i]] - tb[c[i] - 1]) * 2;
        //cout << snum << " " << tnum << endl;
        if (snum % 3 == tnum % 3) {
            ans[i] = true;
        } else {
            ans[i] = false;
        }
    }
    for (int i = 0; i < q; i++) {
        if (ans[i]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5632
#!/usr/bin/env python3
import sys
h, w = map(int, input().split())
s = [[c for c in l.strip()] for l in sys.stdin]



for i in range(h):
    line = ""
    for j in range(w):
        
        cnt = 0

        if s[i][j] == "#":
            line += "#"
        else:
            #上の行3マス
            if i != 0:
                if j != 0:
                    if s[i - 1][j - 1] == "#":
                        cnt += 1
                if s[i - 1][j] == "#":
                    cnt += 1
                if j != w - 1:
                    if s[i - 1][j + 1] == "#":
                        cnt += 1

            #同じ行2マス
            if j != 0:
                if s[i][j - 1] == "#":
                    cnt += 1
            if j != w - 1:
                if s[i][j + 1] == "#":
                    cnt += 1

            #下の行3マス
            if i != h - 1:
                if j != 0:
                    if s[i + 1][j - 1] == "#":
                        cnt += 1
                if s[i + 1][j] == "#":
                    cnt += 1
                if j != w - 1:
                    if s[i + 1][j + 1] == "#":
                        cnt += 1
            line += str(cnt)
    print(line)

Measured memory_bytes: 9140