akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := newScanner()
	var n = sc.readString()
	var sum int
	for _, v := range n {
		a, _ := strconv.Atoi(string(v))
		sum += a
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 2440
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL n; cin>>n;
  string s ="";
  while(n>0){
  	int k = n%26;
  	if(k!=0)s+=(k+'a'-1);
  	else s+=('z');
  	n/=26;
  	if(k==0) n--;
  }
  reverse(all(s));
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <utility>
#include <queue>

using namespace std;

int MAX_H = 50;
int MAX_W = 50;
int h,w;
char field[50][51];
int INF = 100000000;
int dist[50][50];
int sx=0;
int sy=0;
int gx;
int gy;

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

void bfs();
int main(){
  scanf("%d",&h);
  scanf("%d",&w);
  gx=h-1;
  gy=w-1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf(" %c",&field[i][j]);
      if(field[i][j]=='.'){
        count+=1;
      }
    }
  }
  for(int i=0;i<50;i++){
    for(int j=0;j<50;j++){
      dist[i][j]=INF;
    }
  }
  dist[0][0] = 0;
  bfs();
}

void bfs(){
  pair<int,int> p;
  p.first=sx;
  p.second=sy;

  queue< pair<int,int> > que;
  que.push(p);

  while(que.size()){
    pair<int,int> p2=que.front();
    que.pop();

    for(int i=0;i<4;i++){
      int nx = p2.first + dx[i];
      int ny = p2.second + dy[i];

      if(0<= nx && nx < h && 0<=ny && ny<w && field[nx][ny]=='.' && dist[nx][ny]==INF){
        dist[nx][ny] = dist[p2.first][p2.second] + 1;
        pair<int,int> p3;
        p3.first=nx;
        p3.second=ny;
        que.push(p3);
      }
    }
  }
  if(dist[gx][gy]==INF){
    printf("%d\n",-1);
  }
  else{
    printf("%d\n",count-dist[gx][gy]-1);
  }
}

Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (d * d >= x * x + y * y) {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int a, b;
    string s,t,u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(u==s)a--;
    if(u==t)b--;
    cout << a << ' ' << b << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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


  int n; cin >> n;
  int a[1+n];
  for(int i=1; i<=n; i++) cin >> a[i];
  sort(a+1, a+n+1);
  if( a[n/2] != a[1+n/2] ) {
    cout << a[1+n/2] - a[n/2] << nl;
  } else {
    cout << 0 << endl;
  }  

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
cur = -1
c = 0
for i in range(int(input())):
  pre,cur = cur,int(input())
  if cur == 0:
    continue
  elif cur == pre + 1:
    c += 1
  elif cur <= pre:
    c += cur
  else:
    print(-1)
    exit()
print(c)

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

		int N = sc.nextInt();
		long[] T = new long[N];
		long[] A = new long[N];
		for( int i=0; i<N; i++ ){
			T[i] = sc.nextLong();
			A[i] = sc.nextLong();
		}
		for( int i=1; i<N; i++ ){
			if( T[i]<T[i-1] || A[i]<A[i-1] ){
				long a = Math.max(T[i-1]/T[i],A[i-1]/A[i]);
				for( long j=a; j<a+2; j++ ){
					T[i] *= j;
					A[i] *= j;
					if( T[i]>=T[i-1] && A[i]>=A[i-1] ){
						break;
					}
					T[i] = T[i]/j;
					A[i] = A[i]/j;       
				}              
			}         
		}   
		System.out.println(T[N-1]+A[N-1]);
	}
}


Measured memory_bytes: 25184
#include<bits/stdc++.h>
#define  lnt long long int
#define dbl double
using namespace std;
//lnt arr1[300000],arr2[300000];
//vector<int> v;
//int mergesort(int a,int b)
//{
//    //cout<<a<<"asdfghjkl"<<b<<endl;
//    if(a==b)
//    {
//        return 0;
//    }
//    mergesort(a,(a+b)/2);
//    mergesort((a+b)/2+1,b);
//
//    //cout<<a<<"ab"<<b<<endl;
////    for(int i=a;i<=b;i++)
////    {
////
////        cout<<v[i]<<" ";
////    }
//    //cout<<endl;
//    int s1=a,s2 = (a+b)/2+1;
//    int l1 = (a+b)/2;
//    int l2 = b;
//    int arr1[l1-s1+1];
//    int k1 = l1-s1+1,k2 = l2-s2+1;
//    int arr2[l2-s2+1];
//
//    for(int i=s1;i<=l1;i++)
//    {
//        arr1[i-s1] = v[i];
//        //cout<<i<<":"<<i-s1;
//    }
//    //cout<<endl;
//    for(int i=s2;i<=l2;i++)
//    {
//        //cout<<i<<":"<<i-s2;
//        arr2[i-s2] = v[i];
//    }
//    //cout<<endl;
//    int i;
//    s1=0;s2=0;
//    for(i=a;i<=b;i++)
//    {
//        if(s1>=k1||s2>=k2)
//        {
//            break;
//        }
//        //cout<<"11111";
//        if(arr1[s1]<arr2[s2])
//        {
//            v[i]=arr1[s1];
//            s1++;
//        }
//        else
//        {
//            v[i]=arr2[s2];
//            s2++;
//        }
//        //cout<<v[i]<<" ";
//
//    }
//    for(int j=s1;j<k1;j++)
//    {
//        v[i]=arr1[j];
//        i++;
//        //cout<<v[i]<<" ";
//
//
//    }
//    for(int j=s2;j<k2;j++)
//    {
//        v[i]=arr2[j];
//        i++;
//        //cout<<v[i]<<" ";
//    }
//    //cout<<endl;
//}
int main()
{
    string s;
    cin>>s;
    int n = 15-s.length();

    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='o')
        {
            n++;
        }
    }
    if(n>=8)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }


}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, x;
  while (cin >> n >> x) {
    ll ans = 0;
    if (n!=0 || x!=0) {
      for (ll i = 1; i < n; i++) {
        for (ll j = i+1; j < n; j++) {
          if (j<x-i-j && x-i-j<=n) ans++;
        }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3112
#include<stdio.h>
#define MAX 100
#define INF 200000

int n,M[MAX][MAX];

void dijkstra(){
    int minv,u;
    int d[MAX],color[MAX];
    int i,j;
    
    for(i=0;i<n;i++){
        d[i] = INF;
        color[i] = 0;
    }
    
    d[0] = 0;
    color[0] = 1;
    while(1){
        minv = INF;
        u = -1;
        for(i=0;i<n;i++){
            if(minv>d[i] && color[i] != 2){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = 2;
        for(j=0;j<n;j++){
            if(color[j]!=2 && M[u][j] != INF){
                if(d[j] > d[u] + M[u][j]){
                    d[j] = d[u] + M[u][j];
                    color[j] = 1;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        d[i] == INF ? -1 : d[i];
        printf("%d %d\n",i,d[i]);
    }
}

int main(){
    int i,j;
    int k,c,u,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) M[i][j] = INF;
    }
    
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d %d",&v,&c);
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 2044
main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int i;
		double x[4],y[4],e;
		for(i=0;i<4;i++)	scanf("%lf%lf",x+i,y+i);
		e=(x[3]-x[2])*(y[1]-y[0])-(y[3]-y[2])*(x[1]-x[0]);
		printf(-1e-8<e&&e<1e-8?"YES\n":"NO\n");
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
const int N = 5e4+5;
const int M = 5*1e5+5;
#define pi acos(-1)
#define INF 1e18
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
	int n,m;sdd(n,m);
	printf("%s\n",m>=n?"unsafe":"safe");
	//system("pause");
	return 0;
}

Measured memory_bytes: 3652
def main():
    import numpy as np
    h,w = map(int,input().split())
    maize = []
    for i in range(h):
        s = input()
        maize.append(s)
    ans = 0
    for i in range(h):
        for j in range(w):
            que = [[i,j]]
            if maize[i][j] == '.':
                dis = [[-1 for i in range(w)] for i in range(h)]
                dis[i][j] = 0
                while len(que)>0:
                    q = que.pop(0)
                    if q[0]>0:
                        n = [q[0]-1,q[1]]
                        if maize[n[0]][n[1]]=='.':
                            if dis[n[0]][n[1]]==-1:
                                dis[n[0]][n[1]] = dis[q[0]][q[1]]+1
                                que.append(n)
                    if q[0] < h-1:
                        n = [q[0]+1,q[1]]
                        if maize[n[0]][n[1]]=='.':
                            if dis[n[0]][n[1]]==-1:
                                dis[n[0]][n[1]] = dis[q[0]][q[1]]+1
                                que.append(n)
                    if q[1] > 0:
                        n = [q[0],q[1]-1]
                        if maize[n[0]][n[1]]=='.':
                            if dis[n[0]][n[1]]==-1:
                                dis[n[0]][n[1]] = dis[q[0]][q[1]]+1
                                que.append(n)
                    if q[1] < w-1:
                        n = [q[0],q[1]+1]
                        if maize[n[0]][n[1]]=='.':
                            if dis[n[0]][n[1]]==-1:
                                dis[n[0]][n[1]] = dis[q[0]][q[1]]+1
                                que.append(n)
                dis = np.array(dis)
                if np.max(dis)>ans:
                    ans = np.max(dis)
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 12424
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

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

	vector<ll> a(10);
	ll c = 0;

	rep(i, s.size()) {
		if (s[i] == '0') { a[c] = 0; c++; }
		if (s[i] == '1') { a[c] = 1; c++; }
		if (s[i] == 'B') { c = max(0, c - 1); }
	}

	rep(i, c)cout << a[i];


	system("PAUSE");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int n;
ll a,b;
ll h[100005];

bool enough(ll x){
  ll count=0;
  for(int i=0;i<n;i++){
    if(h[i]<=x*b) continue;
    ll y=h[i]-b*x;
    if(y%(a-b)){
      count+=y/(a-b)+1;
    }else{
      count+=y/(a-b);
    }
  }
  if(count>x) return 0;
  else return 1;
}

int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++) cin>>h[i];
  sort(h,h+n);
  ll lb=0,ub=h[n-1]/b+1,mid;
  while(ub-lb>1){
    mid=(lb+ub)/2;
    if(enough(mid)){
      ub=mid;
    }else{
      lb=mid;
    }
  }
  if(enough(mid)) cout<<mid<<endl;
  else cout<<mid+1<<endl;
  return 0;
}

Measured memory_bytes: 1152
S = input()
N = len(S)

def abc(a):
    S1 = a[:(N-1)//2]
    r_S1 = S1[::-1]
    S2 = S[(N-1)//2+1:len(S)]
    return r_S1 == S2

if __name__ == '__main__':
    if abc(S) and abc(S[:(N-1)//2]) and abc(S[(N-1)//2+1:len(S)]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
x, y = map(int, input().split())
ans = 0
if x <= y:
    if x >= 0 and y >= 0:
        ans = y - x
    elif x < 0 and y < 0:
        ans = abs(x - y)
    else:
        if abs(x) <= y:
            ans = min(y - abs(x) + 1, y - x)
        else:
            ans = min(abs(x) - y + 1, y - x)
else:
    if x >= 0 and y >= 0:
        ans = min(y + x + 1, x - y + 2)
    elif x < 0 and y < 0:
        ans = abs(y - x) + 2
    else:
        if abs(x) <= abs(y):
            ans = abs(y) - x + 1
        else:
            ans = x - abs(y) + 1
print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    bool flag=false;

    for(int i=0; i<N; i++){
        cin >> D.at(i).at(0) >> D.at(i).at(1);
    }

    for(int i=0; i<N-2; i++){
        if(D.at(i).at(0) == D.at(i).at(1) && D.at(i+1).at(0) == D.at(i+1).at(1) && D.at(i+2).at(0) == D.at(i+2).at(1)){
            flag=true;
        }
    }

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

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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    
    string s,t;
    cin>>s>>t;
    int count=0;
    rep(i,0,s.size()){
        if(s[i]!=t[i])
        count++;
    }
    cout<<count<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  int prev = 0;
  for (int i = 0; i < n; i++) {
    if (prev <= h[i]) {
      ans++;
      prev = h[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int Gcd(int a, int b) {
  do {
    if (a < b) swap(a, b);
    a = a % b;
  } while (a != 0);
  return b;
}

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

  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int A1[N] = {}, A2[N] = {};
  A1[0] = A[0];
  for (int i = 1; i < N; i++) {
    A1[i] = Gcd(A1[i - 1], A[i]);
  }
  A2[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; i--) {
    A2[i] = Gcd(A2[i + 1], A[i]);
  }
  int ans = max(A1[N - 2], A2[1]);
  for (int i = 1; i < N - 1; i++) {
    ans = max(Gcd(A1[i - 1], A2[i + 1]), ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def factors(N): #約数を全て求める。ただし、順不同
    ret = 1
    middle = int( N**(1/2))
    tmp = N
    # if tmp%2 == 0:
    #     while tmp%2 == 0:
    #         tmp //= 2
    for i in range(2, middle+1):
        if tmp%i == 0:
            ret += 1
            while tmp%i == 0:
                tmp //= i
    if tmp != 1:
        ret += 1
    return ret

    
def main():
    a, b = map( int, input().split())
    d = gcd(a,b)
#    print(2, is_prime(2))
    if d == 1:
        print(1)
        return

    print(factors(d))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main(){
	int num;
	cin>>num;
	bool error=false;
	for(int x=0;x<num;x++){
		error=false;
		queue<int> A;
		vector<int> B;
		vector<int> C;
		for(int i=0;i<10;i++){
			int nn;
			cin>>nn;
			A.push(nn);
		}
		int nn=A.size();
		C.push_back(0);
		for(int i=0;i<nn;i++){
			if(i==0){
				B.push_back(A.front());
				A.pop();
				continue;
			} else if(A.front()>B.back()){
				B.push_back(A.front());
				A.pop();
			}else if(A.front()>C.back()){
				C.push_back(A.front());
				A.pop();
			}else{
				error=true;
			}
		}
		if(error==false)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

void Main()
{

	int K;
	cin >> K;

	string S;
	cin >> S;

	if (S.length() <= K) {
		cout << S;
	}
	else {
		string x = S.substr(0, K) + string("...");
		cout << x;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<pll,pll> P;
int main(){
  int dx[5]={1,-1,0,0},dy[5]={0,0,1,-1},dw[5]={-1,1,0,0},dz[5]={0,0,-1,1};
  while(1){
    int w,h;
    int ans=100;
    cin >> h >> w;
    if(w==0 && h==0){
      return 0;
    }
    int i,j,k,l,tx,ty,kx,ky,a[55][55],b[55][55][55][55];
    cin >> tx >> ty >> kx >> ky;
    for(i=0;i<=w+1;i++){
      for(j=0;j<=h+1;j++){
        a[i][j]=1;
      }
    }
    for(i=1;i<=w;i++){
      for(j=1;j<=h;j++){
        scanf("%d",&a[i][j]);
      }
    }
    for(i=1;i<=w;i++){
      for(j=1;j<=h;j++){
        for(k=1;k<=w;k++){
          for(l=1;l<=h;l++){
            b[i][j][k][l]=100;
          }
        }
      }
    }
    b[ty][tx][ky][kx]=0;
    queue<P> que;
    que.push(make_pair(pll(ty,tx),pll(ky,kx)));
    while(!que.empty()){
      P p=que.front();
      que.pop();
      if(p.first.first==p.second.first && p.first.second==p.second.second && ans>b[p.first.first][p.first.second][p.second.first][p.second.second]){
        ans=b[p.first.first][p.first.second][p.second.first][p.second.second];
      }
      if(b[p.first.first][p.first.second][p.second.first][p.second.second]>=ans){
        continue;
      }
      for(i=0;i<4;i++){
        if(a[p.first.first+dx[i]][p.first.second+dy[i]]==1 && a[p.second.first+dw[i]][p.second.second+dz[i]]==0 && b[p.first.first][p.first.second][p.second.first+dw[i]][p.second.second+dz[i]]>b[p.first.first][p.first.second][p.second.first][p.second.second]+1){
          b[p.first.first][p.first.second][p.second.first+dw[i]][p.second.second+dz[i]]=b[p.first.first][p.first.second][p.second.first][p.second.second]+1;
          que.push(make_pair(pll(p.first.first,p.first.second),pll(p.second.first+dw[i],p.second.second+dz[i])));
        }
        else if(a[p.first.first+dx[i]][p.first.second+dy[i]]==0 && a[p.second.first+dw[i]][p.second.second+dz[i]]==1 && b[p.first.first+dx[i]][p.first.second+dy[i]][p.second.first][p.second.second]>b[p.first.first][p.first.second][p.second.first][p.second.second]+1){
          b[p.first.first+dx[i]][p.first.second+dy[i]][p.second.first][p.second.second]=b[p.first.first][p.first.second][p.second.first][p.second.second]+1;
          que.push(make_pair(pll(p.first.first+dx[i],p.first.second+dy[i]),pll(p.second.first,p.second.second)));
        }
        else if(a[p.first.first+dx[i]][p.first.second+dy[i]]==0 && a[p.second.first+dw[i]][p.second.second+dz[i]]==0 && b[p.first.first+dx[i]][p.first.second+dy[i]][p.second.first+dw[i]][p.second.second+dz[i]]>b[p.first.first][p.first.second][p.second.first][p.second.second]+1){
          b[p.first.first+dx[i]][p.first.second+dy[i]][p.second.first+dw[i]][p.second.second+dz[i]]=b[p.first.first][p.first.second][p.second.first][p.second.second]+1;
          que.push(make_pair(pll(p.first.first+dx[i],p.first.second+dy[i]),pll(p.second.first+dw[i],p.second.second+dz[i])));
        }
      }
    }
    if(ans==100){
      cout << "NA" << endl;
    }
    else{
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 32996
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#define Nine (1000000000)

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

int main() {
	long long S;
	cin >> S;
	long long Y = S / Nine + 1;
	if (S % Nine == 0 || S <= Nine)Y--;		
	long long X =Nine * Y - S;
	if (S <= Nine)X = S;
	cout << "0 0 1000000000 1 " << X << " " << Y;

	return 0;
}



Measured memory_bytes: 256
# include<iostream>
 # include<iomanip>
 using namespace std;
 int main ()
 {
 	  int N;
 	  cin>>N;
	  if(N%2==0)
	  {
	  	 cout<<setprecision(10)
	  	     <<setiosflags(ios::fixed)
	  	     <<0.5<<endl;
	   } 
	   else
	   {
	   	   double sum = 1.0*((N/2)+1)/N;
	  	 cout<<setprecision(10)
	  	     <<setiosflags(ios::fixed)
	  	     <<sum<<endl;	   	   
	   }
 }

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int N, M;
vector<int> G[202020];
const int x = 101010;

bool vis[202020];

void dfs(int n) {
  vis[n] = true;
  for (auto t : G[n]) {
    if (vis[t] != true) {
      dfs(t);
    }
  }
  return;
}

signed main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int l;
      cin >> l;
      l--;
      G[l + x].push_back(i);
      G[i].push_back(l + x);
    }
  }

  dfs(0);

  for (int i = 0; i < N; i++) {
    if (vis[i] == false) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9344
import java.util.Scanner;

class Main{


	public static void main(String[] a){

		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()) {

			int n = sc.nextInt();

			int aa;
			int b;
			int c;
			int d;

			int count = 0;

			for(int i = 0; i < 10; i++) {
				aa = i;
				for(int j = 0; j < 10; j++) {
					b = j;
					for(int k = 0; k < 10; k++) {
						c = k;
						for(int l = 0; l < 10; l++) {
							d = l;
							if((aa + b + c + d) == n) {
								count++;
							}
						}
					}
				}
			}

			System.out.println(count);
		}

	}


}

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

int main(void){
    string s;
    int i, j;
    bool flug = true;
    
    cin >> s;
    
    for(i = 0; i < s.length(); i++){
        for(j = i + 1; j < s.length(); j++){
            if(s[i] == s[j]){
                flug = false;
                break;
            }
        }
        if(!flug)   break;
    }
    
    if(flug)        cout << "yes\n";
    else            cout << "no\n";
    
    return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  // rep(i,4){
  //   if(a*b*i % 2 != 0){
  //     cout << "Yes" << endl;
  //     return 0;
  //   }
  // }
  // cout  << "No" << endl;
  if (a * b % 2 == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


int shu[100];
int main() {
	string S;

	cin >> S;

	rep(i, S.size())
		shu[S[i] - 'A'] += 1;


	int a = 0, b = 0;

	rep(i, 100) {
		
		if (shu[i] != 0 && shu[i] != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
using namespace std;

int findNext(vector<int> cnt){
    int max=-1,res=0,i;
    for(i=0;i<100001;i++){
        if(max<cnt[i]){
            max=cnt[i];
            res=i;
        }
    }
    return res;
}

int nums[100001];
int N;
int getAns(int a,int b){
    int ans=0,i;
    for(i=0;i<N;i++){
        if(i%2==0&&nums[i]!=a)ans++;
        if(i%2==1&&nums[i]!=b)ans++;
    }
    return ans;
}

int main() {
    int i;
    cin>>N;
    vector<int> cnt1(100001,0);
    vector<int> cnt2(100001,0);
    for(i=0;i<N;i++){
        cin>>nums[i];
        if(i%2==0)cnt1[nums[i]]++;
        if(i%2==1)cnt2[nums[i]]++;
    }
    int max1=findNext(cnt1);
    int max2=findNext(cnt2);
    cnt1[max1]=0;
    cnt2[max2]=0;
    int max3=findNext(cnt1);
    int max4=findNext(cnt2);
    int ans=9999999;
    // cout<<max1<<" "<<max2<<" "<<max3<<" "<<max4<<endl;
    if(max1!=max2){
        ans=min(ans,getAns(max1,max2));
    }else{
        ans=min(ans,getAns(max1,max4));
        ans=min(ans,getAns(max3,max2));
    }
    cout<<ans;
    return 0;
}

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


int main() {

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    A, B = mi()
    A -= 1
    ans = 0
    for i in [A, B]:
        if i % 2 == 1:
            # 偶数個
            if (i // 2) % 2 == 1:
                i = 0
            # 奇数個
            else:
                i = 1
        else:
            if ((i-1) // 2) % 2 == 1:
                i = 0 ^ i
            else:
                i = 1 ^ i
        ans ^= i
        
    print(ans)

    return

main()


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n,t;
	V<int> v;

	cin >> n ;
	REP(i,n) {
		cin >> t;
		v.push_back(t);
	}
	sort(ALL(v));

	cout << v[n/2]-v[n/2-1] << endl;
}



Measured memory_bytes: 1020
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int W=scan.nextInt();
		int H=scan.nextInt();
		int x=scan.nextInt();
		int y=scan.nextInt();
		int r=scan.nextInt();
		String result="Yes";

		if(x-r<0 || x+r>W ||y-r<0 || y+r>H) {
			result="No";

		}
		System.out.println(result);

		scan.close();
	}

}


Measured memory_bytes: 26332
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,ans=1,cnt=1,a[200];
    cin>>n;
    rep(i,n){
        cin>>a[i];
        ans*=3;
        if(a[i]%2==0){
            cnt*=2;
        }
    }
    cout<<ans-cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
multiset<ll> ms,ms_;
int main(){
  ll n;
  cin>>n;
  vector<P> vec;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    vec.push_back(P(a,i));
  }
  sort(vec.begin(),vec.end(),greater<P>());
  ms.insert(0);
  ms.insert(0);
  ms.insert(n+1);
  ms.insert(n+1);
  ms_.insert(0);
  ms_.insert(0);
  ms_.insert(-(n+1));
  ms_.insert(-(n+1));
  ll ans=0;
  for(int i=0;i<n;i++){
    auto itr=ms.upper_bound(vec[i].second);
    ll y=*itr;
    itr++;
    ll z=*itr;

    auto itr2=ms_.upper_bound(-vec[i].second);
    ll x=*itr2;
    x*=-1;
    itr2++;
    ll w=*itr2;
    w*=-1;
    ll pos=vec[i].second;
    ans+=vec[i].first*((x-w)*(y-pos)+(z-y)*(pos-x));

    ms.insert(pos);
    ms_.insert(-pos);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11248
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1000003;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e6 + 10;

int power(int a, int b, int m = mod){if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int fact[N+10], ifact[N+10];
void pre(int N){
   fact[0] = 1;
   for (int i = 1; i <= N; ++i)
   {
      fact[i] = (i*fact[i-1])%mod;
   }
   ifact[N] = power(fact[N], -1);
   tr(fact[N-1], fact[N], ifact[N]);
   for (int i = N-1; i >= 0; --i)
   {
      ifact[i] = ((i+1)*ifact[i+1])%mod;
   }
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
   uniform_int_distribution<int> uid(l, r);
   return uid(rng);
}
//shuffle(v.begin(), v.end(), rng);

int32_t main(){_

   pre(mod-1);

   int q = 100;
   cin>>q;
   while(q--){
      int x, d, n;
      // x = rand(0, mod-1), d = rand(0, mod-1), n = rand(1, 1e9);
      cin>>x>>d>>n;

//      if (n >= mod){
  //       cout<<0<<endl;
    //     continue;
      //}

      int ans = 0;
      if (d == 0){
         ans = power(x, n);
         cout<<ans<<endl;
         continue;
      }

      int p = power(d, n);
      int t = n-1 + (x*power(d, -1))%mod;
      t = min(t, mod);

      int vals = (fact[t] * ifact[((t-n)%mod + mod)%mod]) % mod;

      p *= vals;
      p %= mod;
      cout<<p<<endl;
   }

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works


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

int main() {
  int n;
  string s;
  int ans = 0;
  cin >> n >> s;

  for(int i=0; i < n-2; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

//ここから書き始める
//実験

int main(){
	ll L , R;
	cin >> L >> R;
	ll ans = 2019;
	if(L/2019 != R/2019){
		cout<< 0 << endl;
		return 0;
	}
	else{
		L %= 2019;
		R %= 2019;
		int judge = 0;
		for(int i = L ; i < R ; i++){
			for(int j = i + 1 ; j <=R; j++){
				ll a = (i * j) % 2019;
				chmin(ans,a);
				if(ans == 0) {
//					cout<<"i: " << i<<endl;
//					cout <<"j: "<<j<<endl;
					judge = 1;
					break;
				}
			}
			if(judge) break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
  ll X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vll p(A);
  vll q(B);
  vll r(C);
  rep(i,A){
    cin>>p.at(i);
  }
  rep(i,B){
    cin>>q.at(i);
  }
  rep(i,C){
    cin>>r.at(i);
  }
  sort(all(p));
  sort(all(q));
  sort(all(r));
  reverse(all(p));
  reverse(all(q));
  reverse(all(r));
  ll i=X-1;
  ll j=Y-1;
  ll k=0;
  while(true){
    if((i==-1&&j==-1)||k==C){
      break;
    }
    if(i>-1&&j>-1){
      if(min(p.at(i),q.at(j))>=r.at(k)){
        break;
      }
      if(p.at(i)>q.at(j)){
        q.at(j)=r.at(k);
        k++;
        j--;
      }else{
        p.at(i)=r.at(k);
        k++;
        i--;
      }
    }
    else if(i==-1){
      if(q.at(j)>=r.at(k)) break;
      else{
        q.at(j)=r.at(k);
        k++;
        j--;
      }
    }else{
      if(p.at(i)>=r.at(k)) break;
      else{
        p.at(i)=r.at(k);
        k++;
        i--;
      }
    }
  }
  ll ans=0;
  rep(m,X){
    ans+=p.at(m);
  }
  rep(n,Y){
    ans+=q.at(n);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
s = list(str(input()))

ans = 0
n = len(s)
s1 = list(reversed(s))
if s != s1:
    ans = 1

s2 = s[0:(n-1)//2]
s3 = list(reversed(s2))
if s2 != s3:
    ans = 1

s4 = s[(n+2)//2:n]
s5 = list(reversed(s4))
if s4 != s5:
    ans = 1

if ans == 0:
    print('Yes')
else:
    print('No')

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

int main(){

	int n, s, t, cnt1, cnt2;
	string str1, str2, str3;

	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> str1 >> str2;

		str3 = "";
		cnt1 = str1.length() - 1;
		cnt2 = str2.length() - 1;
		if(cnt1 > 80 || cnt2 > 80){
			cout << "overflow" << endl;
			continue;
		}
		t = 0;
		while(cnt1 >= 0 || cnt2 >= 0){
			s = t;
			if(cnt1 >= 0) s += str1[cnt1] - '0';
			if(cnt2 >= 0) s += str2[cnt2] - '0';
			str3 += '0' + s % 10;
			t = (s - s % 10) / 10;
			cnt1--;
			cnt2--;
		}
		if(t != 0) str3 += '0' + t;
		
		if(str3.length() > 80){
			cout << "overflow" << endl;
			continue;
		}
		
		for(int j=str3.length() - 1; j>=0; j--){
			cout << str3[j];
		}
		cout << endl;
	}

  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin>>K;
    queue<long long>lun;
    long long mark=0;
    for(int i=1;i<10;i++){
        lun.push(i);
    }
    for(int i=0;i<K;i++){
        mark=lun.front();
        long long k=mark%10;
        if(k-1>=0){
            lun.push(mark*10+k-1);
        }
        lun.push(mark*10+k);
        if(k+1<=9){
            lun.push(mark*10+k+1);
        }
        lun.pop();
    }
    cout<<mark<<endl;
}

Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		prob(System.in, System.out);
	}

	public static void prob(InputStream in, PrintStream out) {
		Scanner sc = new Scanner(in);
		String line = sc.nextLine();
		int num = Integer.valueOf(line);
		int one = num % 10;
		if (one == 3) {
			out.println("bon");
		} else if (one == 0 || one == 1 || one == 6 || one == 8) {
			out.println("pon");
		} else {
			out.println("hon");
		}

	}
}

Measured memory_bytes: 35712
#include <stdio.h>

int binarySearch(int A[], int n, int key)
{
    int left = 0;
    int right = n;
    int mid;

    while ( left < right ) {
        mid = (left + right) / 2;
        if ( A[mid] == key ) {
            return 1;
        } else if ( key < A[mid] ) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return 0;
}

int main(void)
{
    int n;
    int q;
    int S[100000];
    int T[50000];
    int C = 0;

    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
        scanf("%d", &T[i]);
    }

    for ( int i = 0; i < q; i++ ) {
        C += binarySearch(S, n, T[i]);        
    }

    printf("%d\n", C);

    return 0;
}


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

using namespace std;

int main(){
    int t, streak = 0;
    bool ok = false;
    cin >> t;
    while(t--){
        int a, b;
        cin >> a >> b;
        if(a==b){
            streak++;
        } else {
            streak = 0;
        }
        if(streak == 3) ok = true;
    }
    cout << (ok?"Yes":"No");
}

Measured memory_bytes: 3632