akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int K,A,B;
    cin >> K;
    cin >> A >> B;

    repc(i, A, B + 1){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){
    int n; cin >> n ;
    
    int ans = 0;
    rep(i,n){
        int x,y ;  cin >> x >> y;
        
        ans += y-x+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int a, b;
	scanf("%d %d",&a, &b);
	if (a < b){
		printf("a < b\n");
	}

	if (a > b){
		printf("a > b\n");
	}

 	if (a == b){
		printf("a == b\n");
	}	
	return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>

char t[21][21]={0};
int  h,w;

void at(int i,int j);
int main(){
  int i,j,a,b,cnt=0;
  scanf("%d %d",&w,&h);
  
  while(w!=0 || h!=0){
    
    for(i=0;i<h;i++){
      scanf("%s",t[i]);
    }
    
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(t[i][j]=='@'){
	  t[i][j]='.';
	  a=i; b=j;
	}
      }
    }
    
    at(a,b);
    
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(t[i][j]=='@') cnt++;
      }
    }
    
    printf("%d\n",cnt);
    cnt=0;
    scanf("%d %d",&w,&h);
  }
  return 0;
}

void at(int i,int j){

  if(t[i][j]=='#') return;
  if(t[i][j]=='@') return;
  if(i==h || j==w || i==-1 || j==-1) return;


  t[i][j]='@';
  at(i+1,j);
  at(i-1,j);
  at(i,j+1);
  at(i,j-1);
  
  return;
}

Measured memory_bytes: 612
L, R = map(int, input().split())
min_s = 2019
if (R - L) > 2019:
    min_s = 0
for i in range(L, R):
    for j in range(i + 1, R+1):
        ij = i * j
        m = ij % 2019
        if min_s > m:
            min_s = m
        if min_s == 0:
            break
    if min_s == 0:
        break
print("{}".format(min_s))


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
using namespace std;
int a[25];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	int cnt = 0;
	for (int i = 1; i < n - 1; i++) {
		if (a[i - 1] < a[i] && a[i + 1] > a[i])
			cnt++;
		else if (a[i - 1] > a[i] && a[i + 1] < a[i])
			cnt++;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 128
N, Q = map(int, input().split())
S = input()
cnt = [0]
for i in range(2, len(S) + 1):
    if S[i - 2:i] == 'AC':
        v = cnt[-1] + 1
    else:
        v = cnt[-1]
    cnt.append(v)

# print('cnt', cnt)
for _ in range(Q):
    l, r = map(int, input().split())
    ans = cnt[r - 1] - cnt[l - 1]
    print(ans)


Measured memory_bytes: 6100
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
int n, m;
int dp[301][301][301];	//{S}から出る→冒険する(T)→{S}へ戻る. dp[移動回数][|S|][|T|].

signed main() {
	int i, j, k;
	
	cin >> n >> m;
	
	dp[0][1][0] = 1;
	rep(i, m) {
		rep(j, n + 1) {
			//k = 0. S->S. S->new
			(dp[i + 1][j][0] += j * dp[i][j][0]) %= mod;
			(dp[i + 1][j][1] += (n - j) * dp[i][j][0]) %= mod;
			//else
			for (k = 1; k <= n; k++) {
				if (dp[i][j][k] == 0) continue;
				//T->S, T->T, T->new
				(dp[i + 1][j + k][0] += j * dp[i][j][k]) %= mod;
				(dp[i + 1][j][k] += k * dp[i][j][k]) %= mod;
				(dp[i + 1][j][k + 1] += (n - j - k) * dp[i][j][k]) %= mod;
			}
		}
	}
	
	cout << dp[m][n][0] << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
	int n;
	ll a, b;
	cin >> n >> a >> b;
	vec<ll> x(n);
	rep(i, n) cin >> x[i];

	ll ans = 0;
	rep(i, n - 1) {
		ans += min(a * (x[i + 1] - x[i]), b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;
ll A[5];
ll mi = std::numeric_limits<ll>::max()>>2;

int main()
{
  scanf( "%lld", &N );
  rep( i, 5 )
  {
    scanf( "%lld", A+i );
    
    if( mi > A[i] )
    {
      mi = A[i];
    }
  }

  printf( "%lld\n", 4+(N+mi-1)/mi );

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>
#include <bitset>
#include <sstream>

using namespace std;

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b

int N;

long long int nmax = 1e18;

int main() {

    cin >> N;

    vector<long long int>A;
    long long int sum = 1;

    A.resize(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        double k1 = log(sum) / log(10);
        double k2 = log(A[i]) / log(10);
        double k3 = k1 + k2;
        if (k3  > 18) {
            cout << -1 << endl;
            return 0;
        }

        sum *= A[i];
        if (sum > nmax){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4112
while True:
    n = int(input())
    if n == 0:
        break
    else:
        x = list(map(int, input().split()))
        m = sum(x)/len(x)
        l = []
        for i in x:
            l.append((i - m)**2/len(x))
        print(sum(l)**(1/2))



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

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

    string s, p;
    cin >> s >> p;

    string tmp = s + s;
    if (tmp.find(p) == std::string::npos) {
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var minus = 1L;
            for (var i = 0; i < n; i++) {
               if (a[i] % 2 == 0) minus *= 2;
            }
            
            Console.WriteLine(Math.Pow(3, n)-minus);
        }
    }
}


Measured memory_bytes: 13268
from itertools import accumulate

N, K = map(int, input().split())

S = input()
n = list(map(int, str(S)))
count = 1
mas = []
for i in range(N-1):
    if n[i] == n[i + 1]:
        count += 1
        if i == N-2:
            mas.append(count)
    else:
        mas.append(count)
        count = 1
        if i == N-2:
            mas.append(1)
        

mas2 = []
if n[0] == 0:
    mas.insert(0, 0)
    
if n[N-1] == 0:
    mas.append(0)
    
l=len(mas)
mas2=[0] + list(accumulate(mas))
#for i in range(1, 1+len(mas)):
#    mas2.append(sum(mas[:i]))
    
if K >= (l-1)/2:
    print(N)
else:
    mas3 = []
    k = int(((l-1)/2)-K+1)
    for i in range(k):
        mas3.append(mas2[K*2 + 2*i+1]-mas2[0 + 2*i])
    print(max(mas3))
        

Measured memory_bytes: 10160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<pair<int,int>> AB(N);
  rep(i,N) cin >> AB[i].first >> AB[i].second;
  sort(rall(AB));
  cout << AB[0].first+AB[0].second << endl;
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
ans = 0
for i in range(n):
    x = h[i]
    for j in range(i):
        if x < h[j]:
            break
    else:
        ans += 1
print(ans) 

Measured memory_bytes: 65556
#include <stdio.h>

int main() {
  int a[4];
  scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]);
  bool b = false;
  bool c = false;
  bool d = false;
  bool e = false;
  for (int i = 0; i < 4; i++) {
    if (!b && a[i] == 1) {
      b = true;
    } else if (a[i] == 9) {
      c = true;
    } else if (a[i] == 7) {
      d = true;
    } else if (a[i] == 4) {
      e = true;
    }
  }
  if (b && c && d && e) {
    printf("YES");
  } else {
    printf("NO");
  }
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

vi v[2][N];
int l[2][N];
const int X = 0;
const int Y = 1;

int main() {
	int n;
	cin >> n;
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		v[X][x].push_back(y);
		v[Y][y].push_back(x);
	}

	rep(i, N) {
		l[X][i] = 0;
		l[Y][i] = 0;
	}

	int label = 1;
	queue<pii> que;
	for(int x = 1; x <= MAX; x++) {
		if(v[X][x].size() == 0 || l[X][x] != 0) {
			continue;
		}
		l[X][x] = label;
		que.push(pii(x, X));
		while(!que.empty()) {
			pii p = que.front();
			que.pop();
			for(auto i : v[p.second][p.first]) {
				if(l[1 - p.second][i] == 0) {
					l[1 - p.second][i] = label;
					que.push(pii(i, 1 - p.second));
				}
			}
		}
		label++;
	}
	
	map<int, ll> count_x, count_y;
	for(int i = 0; i < label; i++) {
		count_x[i] = 0;
		count_y[i] = 0;
	}
	for(int i = 1; i <= MAX; i++) {
		count_x[l[X][i]]++;
		count_y[l[Y][i]]++;
	}
	ll count_p = 0;
	for(int i = 1; i < label; i++) {
		count_p += count_x[i] * count_y[i];
	}
	cout << count_p - n << endl;
}


Measured memory_bytes: 8832
class Dice:
    #f[]はUSEWNDの順，添字はU:0,S:1,E:2,W:3,N:4,D:5
    def __init__(self,l):
        self.f=l
        
    def __str__(self):
        l=self.f
        s=f'[U:{l[0]},S:{l[1]},E:{l[2]},W:{l[3]},N:{l[4]},D:{l[5]}]'
        return(s)
       
    def roll(self,c):
        if c=='N':
            ni=[1,5,2,3,0,4]
        elif c=='S':
            ni=[4,0,2,3,5,1]
        elif c=='E':
            ni=[3,1,0,5,4,2]
        elif c=='W':
            ni=[2,1,5,0,4,3]
        self.f=[self.f[j] for j in ni]
    
    def rotate(self,r):
        if r==+1: #Uから見て反時計(西)回り
            ni=[0,3,1,4,2,5]
        elif r==-1: #Uから見て時計(東)周り
            ni=[0,2,4,1,3,5]
        self.f=[self.f[j] for j in ni]

    def patterns(self):
        fs=[]
        for i in range(6):
            if i%2==0:
                self.roll('N')
            else:
                self.roll('E')
            for j in range(4):
                self.rotate(+1)
                fs.append(self.f)
        return fs
        
    def lookEast(self,l):
        for f in self.patterns():
            if f[0]==l[0] and f[1]==l[1]:
                return f[2]
    
    def equals(self,d):
        for f in self.patterns():
            if f==d.f:
                return True
        return False

n=int(input())
d0=Dice(list(map(int,input().split())))
flag = True #全て異なる
for i in range(n-1):
    if d0.equals(Dice(list(map(int,input().split())))):flag=False;break
print('Yes' if flag else 'No')


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin
namespace IO{
	
cs int RLEN=1<<20|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=0;
	while(!isdigit(ch))f=(ch=='-'),ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
cs int N=2000005;
pii stk[N],tmp[N];
int n,m,k,top;
int s[N],t[N],os[N],ot[N];
char str[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read(),m=read(),k=read();
	readstring(str);
	reverse(str+1,str+n+1);
	for(int i=1;i<=n;i++)s[i]=str[i]-'0';
	readstring(str);
	reverse(str+1,str+m+1);
	for(int i=1;i<=m;i++)t[i]=str[i]-'0';
	for(int i=max(n,m);i;i--){
		if(s[i]==1&&t[i]==1){
			int sta=3,cnt=0,lk=k,p=i;
			while(top){
				if(sta==3){
					if(lk>=stk[top].fi-p){
						lk-=stk[top].fi-p,p=stk[top].fi;
						tmp[++cnt]=stk[top],tmp[cnt].se^=sta;
						sta&=stk[top].se,top--;
					}
					else break;
				}
				else if(sta){
					if(stk[top].fi==p+1){
						p++;
						if(sta!=stk[top].se)sta^=stk[top].se;
						top--;
					}
					else break;
				}
				else break;
			}
			if(sta!=0&&sta!=3){
				p++,tmp[++cnt]=pii(p,sta);
			}
			if(sta==3)p+=lk,os[p]=ot[p]=1;
			for(int i=cnt;i;i--)stk[++top]=tmp[i];
		}
		else{
			if(s[i]+t[i]==1)
			stk[++top]=pii(i,(s[i]<<1)+t[i]);
		}
	}
	for(int i=1;i<=top;i++)
	os[stk[i].fi]=stk[i].se>>1,ot[stk[i].fi]=stk[i].se&1;
	int ln=n+k,lm=m+k;
//	cout<<ln<<" "<<lm<<'\n';
	while(!os[ln])ln--;while(!ot[lm])lm--;
//	cout<<ln<<" "<<lm<<'\n';exit(0);
	for(int i=ln;i;i--)putchar(os[i]+'0');puts("");
	for(int i=lm;i;i--)putchar(ot[i]+'0');puts("");
	return 0;
}

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

int main(void){

   string s;
   cin >> s;
   int n = s.size();

   //[+北,-南][+東,-西]
   int ns = 0;
   int ew = 0;
   bool u, d, l, r;
   u = d = l = r = false;

   for(int i=0;i<n;i++){
      switch(s.at(i)){
         case 'N':
            ns++;
            u = true;
            break;
         case 'S':
            ns--;
            d = true;
            break;
         case 'E':
            ew++;
            r = true;
            break;
         case 'W':
            ew--;
            l = true;
            break;
         }
   }
   if(ns == 0 && ew == 0){
      cout << "Yes" << endl;
      return 0;
   }
   if(u && d && r && l)
      cout << "Yes" << endl;
   else if ((u && d && ew == 0) || (ns == 0 && r && l))
      cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
def gb(s):
	bal,m = 0,0
	for l in s: 
		bal += 1 if l == '(' else -1
		m = min(m, bal)
	return (bal,m)
-1 -1 -1 -3 -5 -11 -23 

-23 -11 -5 -3 -1 -1 -1

rs = [gb(raw_input()) for _ in range(n)]
rs.sort(key = lambda x: (0, -x[1]) if x[0]>=0 else (1,x[1] - x[0], x[0]))

def f(rs):
	s = 0
	for aa,bb in rs:
		if s + bb < 0: return False
		s += aa
	return s == 0

print 'Yes' if f(rs) else 'No'

Measured memory_bytes: 195552
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,oo=0x3f3f3f3f,mod=1e9+7;

int memo[N][N],h,w;
char maze[N][N];

bool valid(int x, int y){
    return(x<h&&y<w&&maze[x][y]!='#');
}

int dp(int i, int j){
    if(i==h-1&&j==w-1)return 1;
    if(memo[i][j]!=-1) return memo[i][j];
    int r=0,d=0;
    if(valid(i,j+1))r=dp(i,j+1);
    if(valid(i+1,j))d=dp(i+1,j);
    return memo[i][j]=(r+d)%mod;

}

int main(){
    memset(memo,-1,sizeof memo);
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> maze[i];
    dp(0,0);
    cout << memo[0][0];
    return 0;
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> point(n, k - q);
  for (int i = 0; i < q; ++i) {
    int a;
    cin >> a;
    point.at(a - 1) += 1;
  }
  for (int& x : point) {
    if (x <= 0) {
      puts("No");
    } else {
      puts("Yes");
    }
  }

  return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,ans=0x3f3f3f3f;
void dfs(int x,int d) {
	if(x>=ans) return;
	if(d==n) {ans=x;return;}
	dfs(x+k,d+1),dfs(x*2,d+1);
}
int main()
{
	scanf("%d%d",&n,&k);dfs(1,0);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long n, x;
    cin >> n >> x;
    int k;
    cin >> k;
    long long ans = abs(k - x);
    for (int i = 1; i < n; i++){
        int xi;
        cin >> xi;
        ans = __gcd(ans, abs(xi - x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])

Measured memory_bytes: 74824
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(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 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

int main(){
    int N; cin >> N;
    vector<int> W(N);
    REP(i, N) cin >> W[i];

    vector<int> SUM(N);


    SUM[0] = W[0];
    FOR(i,1,N){
        SUM[i] += SUM[i-1] + W[i];
    }

    ll ans = INF;

    REP(i,N){
        //iを区間として、累積和の区間から絶対値を求める
        ll a = SUM[i];
        ll b = SUM[N-1] - SUM[i];
        ans = min(ans,abs(a-b));


    }
    cout << ans << endl;
    
    
}

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

int main() {
  int n, k, ans=1;
  cin >> n >> k;

  rep(i, n)
  {
    ans = min(ans*2, ans+k);
  }
  cout << ans << endl;

}


Measured memory_bytes: 3584
//#include <iostream>
//#include <vector>
//#include <set>
//#include <map>
//#include <algorithm>

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll len = 2 * (int) 1e5 + 1;


int main() {
//    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[i - 1]) {
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

constexpr int mod = 998244353;
constexpr int N = 5e5;

// WARN : use H with larger N
/// --- Modulo Factorial {{{ ///
template < int N, int mod = (int) 1e9 + 7 >
struct Factorial {
  constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = 0;
    return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  constexpr ll modinv(ll a) {
    ll x = 0, y = 0;
    extgcd(a, mod, x, y);
    return (x + mod) % mod;
  }
  int arr[N + 1], inv[N + 1];
  ll operator[](int i) const { return arr[i]; }
    Factorial()
    : arr(), inv() {
      arr[0] = 1;
      for(int i = 1; i <= N; i++) {
        arr[i] = (ll) i * arr[i - 1] % mod;
      }
      inv[N] = modinv(arr[N]);
      for(int i = N - 1; i >= 0; i--) {
        inv[i] = (ll)(i + 1) * inv[i + 1] % mod;
      }
    }
  ll C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (ll) arr[n] * inv[r] % mod * inv[n - r] % mod;
  }
  ll H(int n, int r) const { return C(n + r - 1, r); }
};
/// }}}--- ///

Factorial < N * 2, mod > fact;

ll n, k;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  ll ans = 0;
  for(int r = n; r <= k; r++) {
    int b = k - r;
    if(r < b) continue;
    int j = r + 1 - n;
    if(r == b) {
      ans += fact.C(k - 1, r);
      if(j <= b - 1) {
        ans -= fact.C(j + r + (b - 1 - j), b - 1 - j);
      }
    } else {
      ans += fact.C(k, r);
      if(j <= b) {
        ans -= fact.C(j + r + (b - j), b - j);
      }
    }
  }
  ans %= mod;
  if(ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
//vector<vector<ll>> vec(1e6+1,vector<ll>(1e6+1,0));
//void cal(){
//  rep(i,1e6+1){
//    vec[i][0] = 1;
//    vec[i][i] = 1;
//  }
//  REP(i,1,1e6+1){
//    rep(j,i+1){
//      vec[i][j] = (vec[i-1][j-1] + vec[i-1][j]) % mod;
//    }
//  }
//}

const int MAX = 1000001;
const int MOD = 1000000007;

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(){
  ll x,y;
  cin >> x >> y;
  ll ans;
  if((x + y) % 3 != 0 || x * 2 < y || y * 2 < x){
    ans = 0;
  }else{
    tmp1 = (x + y) / 3;
    x -= tmp1;//
    y -= tmp2;//

    // 前処理
    COMinit();

    // 計算例
    //cout << x << y;
    ans = COM(tmp1, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 23680
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int m = n % 10;
  if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9) {
    cout << "hon\n";
  } else if(m == 0 || m == 1 || m == 6 || m == 8) {
    cout << "pon\n";
  } else {
    cout << "bon\n";
  }
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
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;}

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

int main() {
    int n; cin >> n;
    int ans=0;
    for(int i=1; i<=n; i++) {
        if(i%2==1 && enum_div(i).size()+1==8) {
            ans++;
        }
    }
    cout << ans << endl;
}



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

int main() {
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  vector<string> a(N);
  vector<string> b(N);
  vector<string> c(2*N);
  /*for (int i = 0;i < N; i++) {
    a.at(i) = S.at(i);
    b.at(i) = T.at(i);
    cout << a.at(i) << b.at(i) << endl;
  }*/
  for (int i = 0;i < N; i++) {
    c[2*i] = S[i];
  }
  for (int i = 0;i < N; i++) {
    c[2*i+1] = T[i];
  }
  for (int i = 0;i < 2 *N; i++) {
    cout << c[i] ;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int inf=1e9,M=1<<18|2,N=18;
int dp[M][51],a[N][2],cnt[M],yc[N];
void cl(int &a,int b){
	a=min(a,b);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	For(i,0,n-1)a[i][0]=read();
	For(i,0,n-1)a[i][1]=read();
	For(i,0,(1<<n)-1)For(j,0,50)dp[i][j]=inf;
	dp[0][0]=0;
	For(i,0,(1<<n)-1){
		if(i)cnt[i]=cnt[i>>1]+(i&1);
		For(j,0,n-1)if(!(i>>j&1)){
			yc[j]=0; For(k,j+1,n-1)yc[j]+=i>>k&1;
		}
		For(k,0,50)if(dp[i][k]<inf){
			//cout<<i<<" "<<k<<endl;
			For(j,0,n-1)if(!(i>>j&1)&&k<=a[j][abs(cnt[i]-j)&1]){
				cl(dp[i|(1<<j)][a[j][abs(cnt[i]-j)&1]],dp[i][k]+yc[j]);
			}
		}
	}
	int ans=inf;
	For(i,0,50)ans=min(ans,dp[(1<<n)-1][i]);
	cout<<(ans<inf?ans:-1)<<endl;
}
/*
0 1 1 0
0 0 1 1 1 0 1 '

*/

Measured memory_bytes: 56892
# 最短距離は当然abs(sx-tx)回x方向とabs(sy-ty)回y方向
# 同じ座標の周囲4マスすべてを使うことになるのでそうする
# 位置関係が判明しているのを利用

sx, sy, tx, ty = map(int, input().split())
difx, dify = abs(tx - sx), abs(ty - sy)
ans = "R" * difx + "U" * dify + "R" + "D" * (dify + 1) + "L" * (difx + 1) + "U"
ans += "U" * dify + "R" * difx + "U" + \
    "L" * (difx + 1) + "D" * (dify + 1) + "R"
print(ans)


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


int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if(s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h,a);
    }else{
        double w = s*2/b;
        rad = atan2(b,w);
    }
    printf("%.6f\n", 180*rad/acos(-1));
}


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

int main() {
	string s,t;

	cin>>s>>t;
	int m=s.length(),n=t.length();
	
	   
    int i, j;  
int L[m + 1][n + 1];
    for (i = 0; i <= m; i++)  
    {  
        for (j = 0; j <= n; j++)  
        {  
        if (i == 0 || j == 0)  
            L[i][j] = 0;  
      
        else if (s[i - 1] == t[j - 1])  
            L[i][j] = L[i - 1][j - 1] + 1;  
      
        else
            L[i][j] = max(L[i - 1][j], L[i][j - 1]);  
        }  
    } 
    char ans[L[m][n]];
  //  cout<<L[m][n];
    i=0;
    //int y=m,z=n;
     while (n > 0 && m > 0) {
    if (L[m][n] == L[m - 1][n]) {
      --m;
    } else if (L[m][n] == L[m][n - 1]) {
      --n;
    } else {
      --n;
      --m;
      ans[i++] = t[ n];
    }
  }
 for(m=i-1;m>=0;m--)
 cout<<ans[m];
	return 0;
}


Measured memory_bytes: 35456
H,W = map(int,input().split())
field = [input() for x in range(H)]
vx = [0,0,1,-1]
vy = [1,-1,0,0]
reached = [[-1 for x in range(W)]for x in range(H)]
from collections import deque
def bfs(y,x):
    q = deque([[y,x]])
    reached[y][x] = 1

    while q:
        y,x = q.popleft()
        if [y,x] == [H-1,W-1]:
            return reached[y][x]
        for dy,dx in zip(vy,vx):
            ny,nx = y+dy,x+dx
            if not (0<=ny<H and 0<=nx<W):
                continue
            if field[ny][nx] == '.' and reached[ny][nx] == -1:
                q.append([ny,nx])
                reached[ny][nx] = reached[y][x] + 1
    return -1
bk = 0
for x in field:
    for y in x:
        if y == '#':
            bk += 1
ans = bfs(0,0)
if ans==-1:
    print(-1)
else:
    print(H*W-ans-bk)


Measured memory_bytes: 3380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#define MAXN 100010
#define LL long long
using namespace std;

int n;
map<LL,int> S;
LL a[MAXN],b[MAXN];

pair<LL,LL> trans(LL x){
	LL tx=x;
	LL y1=1,y2=1;
	for(LL i=2;i*i*i<=x;i++)
		if(tx%i==0){
			int cnt=0;
			while(tx%i==0) tx/=i,cnt++;
			cnt%=3;
			for(int j=0;j<cnt;j++) y1*=i;
			cnt=(3-cnt)%3;
			for(int j=0;j<cnt;j++) y2*=i;
		}
	if(tx>1){
		LL temp=max((LL)(sqrt(tx)-2),1LL);
		for(LL i=0;i<4;i++)
			if((temp+i)*(temp+i)==tx){
				y1*=tx;
				y2*=temp+i;
				return make_pair(y1,y2);
			}
		y1*=tx;
		y2*=tx*tx;
	}
	return make_pair(y1,y2);
}

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
		pair<LL,LL> temp=trans(a[i]);
		a[i]=temp.first;
		b[i]=temp.second;
		S[a[i]]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(S[a[i]]){
			if(a[i]==1){
				S[a[i]]=0;
				ans++;
				continue;
			}
			int t1=S[a[i]],t2=S[b[i]];
			S[b[i]]=S[a[i]]=0;
			ans+=max(t1,t2);
		}
	printf("%d\n",ans);
}


Measured memory_bytes: 14336
N,M = map(int,input().split())
ans = 0
for n in range(1,N + 1):
        for m in range(1,M + 1):
                m = str(m)
                if len(m) == 1:
                        continue
                if int(m[1]) < 2 or int(m[0]) < 2:
                        continue
                if n == int(m[0]) * int(m[1]):
                        ans += 1
print(ans)

Measured memory_bytes: 3060
s = input()
N = len(s)
a, b, c = 0, 0, 0
for i in range(N):
    if s[i] == "a":
        a += 1
    elif s[i] == "b":
        b += 1
    else:
        c += 1

r = [a, b, c]
r = sorted(r, reverse=True)
if len(s) % 3 == 0 and len(s) // 3 >= r[0]:
    print("YES")
elif len(s) % 3 == 1 and len(s) // 3 + 1 >= r[0] and len(s) // 3 >= r[1]:
    print("YES")
elif len(s) % 3 == 2 and len(s) // 3 + 1 >= r[0] and len(s) // 3 + 1 >= r[1] and len(s) // 3 >= r[2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
while True:
    d, w = map(int, input().split())
    if d == 0 and w == 0:
        break

    e = [list(map(int, input().split())) for i in range(d)]
    V = 0
    for i_l in range(d - 2):
        for i_r in range(min(i_l + 2, d), d):
            for j_l in range(w - 2):
                for j_r in range(min(j_l + 2, w), w):
                    min_out = 10 ** 10
                    max_in = 0
                    tmp = 0
                    for i in range(i_l, i_r + 1):
                        for j in range(j_l, j_r + 1):
                            if i == i_l or i == i_r or j == j_l or j == j_r:
                                #print(i, j)
                                min_out = min(min_out, e[i][j])
                            else:
                                max_in = max(max_in, e[i][j])

                    for i in range(i_l, i_r + 1):
                        for j in range(j_l, j_r + 1):
                            if min_out > max_in:
                                if i == i_l or i == i_r or j == j_r or j == j_l:
                                    1
                                else:
                                    #print(i_l, i_r, j_l, j_r, i, j, min_out, max_in, e[i][j])
                                    tmp += min_out - e[i][j]


                    #print(tmp)
                    V = max(tmp, V)

    print(V)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ni,sum,yaku;
	cin >> n;
	if(n == 3){
		printf("2 5 63\n");
		return 0;
	}
	ni = n - 2;
	while(ni * 2 > 30000 || ni * (ni + 1) / 2 % 3 || (n - ni) % 2) ni--;
	for(int i = 0;i < ni;i++) cout << (i ? " " : "") << (i + 1) * 2;
	if(n - ni > 5000){
		cout << " 30000";
		ni++;
	}
	for(int i = 0;i < n - ni;i++) cout << " " << (i * 2 + 1) * 3;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define p(S) cout<<S<<endl;
using namespace std;

int N;
double r[510];
double x[510];

double calc_x(double a, double b){
    return sqrt((a+b)*(a+b) - (a-b)*(a-b));
}
double ans;
int main() {
    cin >> N;
    REP(i,0,N) cin>> r[i];

    REP(i,1,N){
        double mx=0;
        RREP(j,0,i) {
            double now = calc_x(r[j], r[i]);
            mx = max(mx, now+x[j]);
            if(r[j]>=r[i]) break;
        }
        x[i]=mx;
    }
    double  mn=0;
    REP(i,0,N) {
        mn = min(mn, x[i] - r[i]);
        ans = max(ans, x[i] + r[i]);
    }
    ans -= mn;

    printf("%.6lf\n", ans);
    return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <sstream>
using namespace std;
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;


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

    vector<ll> b(n-1);
    rep(i,n-1) cin >> b[i];

    ll ans=b[0]+b[n-2];
    rep(i,n-2){
        ans += min(b[i],b[i+1]);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=10;
void solve()
{
    string s, t;
    cin>>s>>t;
    int n=sz(s);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N;
    cin>>N;
    while (N--) {
        string s;
        cin>>s;
        int turn=0;
        int n=s.size();
        while (n>1) {
            ++turn;
            int x=s[n-1]-'0'+s[n-2]-'0';
            if (x>9) {
                s[n-2]='1';
                s[n-1]=x-10+'0';
            }
            else {
                s[n-2]=x+'0';
                n--;
            }
            if (n==1) break;
        }
        cout<<(turn%2 ? "Fabre " : "Audrey ")<<"wins.\n";
    }
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum;
    if(a>=b && a>=c){
        sum=a*pow(2,k)+b+c;
    }else if(b>=a && b>=c){
        sum=b*pow(2,k)+a+c;
    }else if(c>=a && c>=b){
        sum=c*pow(2,k)+a+b;
    }
    
    pr(sum);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvii vector<vector<ii>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

void write();
template <typename T, typename... Args>
void write(T x, Args... args);

void solve() {
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for (int i = 0; i < h; ++i) cin >> g[i];

    for (auto& i : g)
        for (auto& j : i) j = (j == '.' ? 1 : 0);

    vvi color(h, vi(w));
    vii q(h * w);
    vii step = {{0, 1}, {1, 0}};
    int s = 0;
    q[s++] = {0, 0};
    color[0][0] = 1 + (g[0][0] == 0);

    int l = 0;
    for (int i = color[0][0]; i < h * w + 7; ++i) {
        // write("step", i, l, s);

        for (int j = l; j < s; ++j) {
            for (int k = 0; k < 2; ++k) {
                int u = q[j].fi + step[k].fi;
                int v = q[j].se + step[k].se;
                if (u < h && v < w && !color[u][v] && (g[u][v] & 1) == i % 2) {
                    q[s++] = {u, v};
                    color[u][v] = i;
                    // write("push", u, v, i);
                }
            }
        }

        int stop = s;
        for (int j = l; j < stop; ++j) {
            for (int k = 0; k < 2; ++k) {
                int u = q[j].fi + step[k].fi;
                int v = q[j].se + step[k].se;
                if (u < h && v < w && !color[u][v] && (g[u][v] & 1) != i % 2) {
                    q[s++] = {u, v};
                    color[u][v] = i + 1;
                    // write("push", u, v, i + 1);
                }
            }
        }

        l = stop;

        if (color[h - 1][w - 1]) break;
    }

    write(color[h - 1][w - 1] / 2);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

template <typename T, typename... Args>
void write(T x, Args... args) {
    cout << x;
    if (sizeof...(args)) {
        cout << ' ';
        write(args...);
    } else
        cout << '\n';
}

Measured memory_bytes: 384
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
int fact[N];
int invf[N];
long long power(long long x, long long y)
{
   long long res = 1;
   x = x % mod;
   while (y > 0)
   {
       if (y & 1)
            res = (res*x) %mod;
       y = y>>1;
       x = (x*x) %mod;
   }
   return res;
}
int ncr(int n,int k){
    if(n<0||k<0||n<k) return 0;
    int res=fact[n];
    res=(res*invf[k])%mod;
    res=(res*invf[n-k])%mod;
    return res;
}
int f(int n,int m){
    return ncr(n+m-2,n-1);
}
void solve()
{
    fact[0]=1;
    rep1(i,N-1) fact[i]=(fact[i-1]*i)%mod;
    invf[N-1]=power(fact[N-1],mod-2);
    for(int i=N-2;i>=0;i--){
        invf[i]=(invf[i+1]*(i+1))%mod;
    }
    int n,m,r,c;
    cin>>n>>m>>r>>c;
    int left=0;
    int up=0;
    int ans=0;
    for(int i=c+1;i<=m;i++){
        up=f(n-r,i);
        ans=(ans+((up+left)*f(r-1,m-i+1))%mod)%mod;
        left=(left+up)%mod;
    }
    if(r==1){
        ans=left;
    }
    cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,ans,q,t;
ll x[500005],y[500005],r[500005];
bool flag,dame;

int main(){
    cin >> n >> k;
	for(i=0;i<k;i++){
		cin >> r[i];
	}
	r[k] = INF;
	cin >> q;
	d = -1;
	num = 0;
	ll na = 0,nb = n,va = 0,vb = n,nt = 0;
	for(i=0;i<q;i++){
		cin >> t >> a;
		while(t > r[num]){
			//num++;
			va += d * (r[num] - nt);
			vb += d * (r[num] - nt);
			if(va < 0){
				na += 0 - va;
				va = 0;
			}
			if(vb > n){
				nb -= vb - n;
				vb = n;
			}
			if(vb < 0){
				va = vb = 0;
				na = nb = n;
			}
			if(va > n){
				va = vb = n;
				na = nb = 0;
			}
			nt = r[num];
			d *= -1;
			num++;
		}
		va += d * (t - nt);
		vb += d * (t - nt); 
		if(va < 0){
			na += 0 - va;
			va = 0;
		}
		if(vb > n){
			nb -= vb - n;
			vb = n;
		}
		if(vb < 0){
			va = vb = 0;
			na = nb = n;
		}
		if(va > n){
			va = vb = n;
			na = nb = 0;
		}
		nt = t;
		if(a <= na){
			x[i] = va;
		}else if(a >= nb){
			x[i] = vb;
		}else{
			x[i] = va + a - na;
		}
	}
	for(i=0;i<q;i++){
		p(x[i]);
	}

	return 0;
}


Measured memory_bytes: 30976
s = str(input())
n = len(s)
cnt = 0
if n%2==0:
  for i in range(int(n/2)):
    if s[i]!=s[n-i-1]:
      cnt += 1
else:
  for i in range(int((n-1)/2)):
    if s[i]!=s[n-i-1]:
      cnt += 1
print(cnt)


Measured memory_bytes: 3060