akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S, T;
    cin >> S >> T;

    int cnt = 0;
    REP(i, S.size()) cnt += S[i] != T[i];

    cout << cnt << endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double kane;
		string syu;
		cin >> kane >> syu;
		if (syu == "BTC")kane *= 380000;
		ans += kane;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll dp[10010][2][100];
const int mod = 1000000007;

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

	string K;
	int D;
	cin >> K >> D;
	int N = K.size();
	dp[0][0][0] = 1;
	REP(i, N)REP(smaller, 2)REP(j, D) {
		REP(x, smaller ? 10 : K[i] - '0' + 1) {
			dp[i + 1][smaller || x < (K[i] - '0')][(j + x) % D] += dp[i][smaller][j];
			dp[i + 1][smaller || x < (K[i] - '0')][(j + x) % D] %= mod;
		}
	}

	cout << (dp[N][0][0] + dp[N][1][0] - 1 + mod) % mod << endl;

	return 0;
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++)
  {
    int x = s[i] - 'A';
    x = (x + n) % 26;
    char c = x + 'A';
    s[i] = c;
  }
  cout << s << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mochi.at(i) = x;
  }
  sort(mochi.begin(), mochi.end());
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      sum += 1;
    }
    else if (mochi.at(i) > mochi.at(i-1)) {
      sum += 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include<unordered_map>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define F first
#define S second
#define bit(x,n) (x & (1<<(n)))
#define EPS 1e-8
#define all(x) (x).begin(),(x).end()
#define INF 0x3f3f3f3f3f3f3
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
#define RAND(x,y) ((x) + (rand()%(y-x+1)))

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;

ii DR8[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
ii DR4[] = {{-1,0},{0,-1},{0,1},{1,0}};

const ll mod = 1e9+7;

ll nop = 2;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}


bool isVowel(char ch) { ch = tolower(ch);return (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'); }

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

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

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    string s,t;
    cin>>s>>t;
    int ans = 0;
    for0(i,s.length()) {
        ans += (s[i] != t[i]);
    }
    deb1(ans);
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t){
        //cout<<"Case #"<<T<<": ";
        solve();
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


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

using namespace std;

int main(void) {
  int x;
  cin >> x;

  for(int i = 1; i <= x; i++) {
    if(i * (i + 1) / 2 >= x) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
a = list(map(int, input().split()))

ma = a[0] - 1
for i in range(m-1):
    ma = max(ma, (a[i + 1] - a[i]) // 2)
ma = max(ma, n - a[-1])

print(ma)

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

long long int mod = 1000000007;
long long int g(int x) {
  if (x == 0 || x == 1) {
    return 1;
  }
  else {
    return g(x - 1) * x % mod;
  }
}
long long int inv(int x) {
  if (x == 1) {
    return 1;
  }
  else {
    return mod - inv(mod % x) * (mod / x) % mod;
  }
}
long long int ig(int x) {
  if (x == 0 || x == 1) {
    return 1;
  }
  else {
    return ig(x - 1) * inv(x) % mod;
  }
}

int main() {
  int x, y;
  cin >> x >> y;
  int z = x + y;
  if (z % 3 != 0) {
    cout << 0 << endl;
  }
  else if (y > 2 * x || x > 2 * y) {
    cout << 0 << endl;
  }
  else {
    z /= 3;
    int a = max(x, y);
    int b = min(x, y);
    int w = a - b;
    int A = (z + w) / 2;
    int B = (z - w) / 2;
    printf("%lld\n", g(z) * (ig(A) * ig(B) % mod) % mod);
  }
}


Measured memory_bytes: 13440
#include <stdio.h>

void bubble_sort(int* A, int n);
void print_line(int* A, int n);
void swap(int* a, int* b);

int main(void){
    int N;
    int A[100];
    int i;
    scanf("%d", &N);

    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
    }
    bubble_sort(A, N);
    return 0;
}

void bubble_sort(int* A, int N){
    int j;
    int flag = 1;
    int count = 0;
    while(flag){
        flag = 0;
        for(j=N-1; j>=1; --j){
            if(A[j] < A[j-1]){
                swap(&A[j], &A[j-1]);
                flag = 1;
                ++count;
            }
        }
    }
    print_line(A, N);
    printf("%d\n", count);
}

void print_line(int *A, int N){
    int i;
    for(i = 0; i < N-1; ++i){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}

void swap(int* a, int* b){
    int tmp;
    tmp = *b;
    *b = *a;
    *a = tmp;
}


Measured memory_bytes: 1932
import Data.Maybe
import Data.List
import Data.Bits
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main = do
  [n,k] <- getIntList
  as <- getIntList
  print $ solve k n as

solve :: Integer -> Integer -> [Integer] -> Integer
solve k n as = solve' cs where
  a = maximum (k:as)
  bs = takeWhile (a >=) $ iterate (2*) 1
  cs = reverse $ snd $ mapAccumL f 0 bs

  f :: Integer -> Integer -> (Integer, (Bool, Integer, Integer, Integer))
  f e b = (e', (isOn, offv, onv, e)) where
    isOn = (k .&. b) /= 0
    onCnt = genericLength $ filter (\x -> x .&. b /= 0) as
    offv = b * onCnt
    onv = b * (n - onCnt)
    e' = e + max offv onv

solve' :: [(Bool, Integer, Integer, Integer)] -> Integer
solve' [] = 0
solve' ((False, offv, _, e): cs) = offv + solve' cs
solve' ((True, offv, onv, e): cs)
  | offv >= onv = w
  | offv + e < onv = z
  | otherwise = max w z
  where
    w = offv + e
    z = onv + solve' cs


Measured memory_bytes: 9596
x, y, a, b, c = map(int, input().split())
p_l = sorted(list(map(int, input().split())), reverse=True)[:x]
q_l = sorted(list(map(int, input().split())), reverse=True)[:y]
r_l = list(map(int, input().split()))
p_l = sorted(p_l + q_l + r_l, reverse=True)

print(sum(p_l[:x+y]))

Measured memory_bytes: 28140
#define _DEBUG 1

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(std::string S) {
  bool result = S != "AAA" && S != "BBB";
  yesOrNo(result);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli n,a,b;
    cin>>n>>a>>b;
    if((abs(a-b)+1)%2==0)
    {
        cout<<"Borys";
    }
    else
    {
        cout<<"Alice";
    }
}


Measured memory_bytes: 256
s=input()
n=len(s)
count=0
flag=0
i=1
list="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for chara in s:
    if i==1:
        if chara!="A":
            flag=2
            break
    elif i==2:
        if chara in list:
            flag=2
            break
    elif i>=3 and i<=n-1:
        if chara=="C":
            count+=1
            if count==1:
                flag=1
            elif count==2:
                flag=2
                break
    elif i==n:
        if chara in list:
            flag=2
            break
    i+=1
            
if flag==1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  cout<<(N+1)/2<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

fac=fac_list(10**5+100,mod)
def C(n,r):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod

 
#main
N=int(input())
Q=[0]*N
for a in range(N):
    Q[int(input())-1]=a

ans=1
K=1
for a in range(1,N):
    if Q[a-1]<Q[a]:
        K+=1
    else:
        K=1
    ans=max(K,ans)
ans=N-ans
print(ans)


Measured memory_bytes: 17420
S = input()
 
dp = [[0]*13 for j in range(len(S)+1)]
mod = 10**9+7
 
dp[0][0] = 1
k = 1
L0 = list(range(10))

for s in S:
  if ('?' == s):
    L = L0
  else:
    L = [int(s)]
 
  for l in L:
    for i in range(13):
      tmp = (i * 10) + l
      m = tmp % 13
      dp[k][m] = ((dp[k][m] + dp[k-1][i]) % mod)
  k += 1
print(dp[k-1][5])


Measured memory_bytes: 61788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long a;
    string s;
    cin >> a >> s;
    string t = "";
    forn (i, 0, sz(s))
        if (s[i] != '.')
            t += s[i];
    cout << (a * stoi(t)) / 100;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,i=0,j,c=0,n,l[100010],r[100010],max=0, min=20000000;
    cin >> n >> m;
    for(i=0;i<m;i++)
    {
        cin >> l[i] >> r[i];
        if(max<l[i])
        {
            
            max=l[i];
        }
        if(min>r[i])
        {
            min=r[i];
        }
    }
    if(min<max)
    {
        cout << "0" << endl;
    }
    else{
        
        cout << min-max+1 << endl;
    }
    return 0;

}


Measured memory_bytes: 4360
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define mod 1000000007
using namespace std;


int main(void){
    ll n; cin>>n;
    vl d(n);
    for(int i=0;i<n;++i) cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;
}


Measured memory_bytes: 1024
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define clr clear()
#define ll long long int
#define inf (1<<30)
#define ins insert
#define endl '\n'
#define xx first
#define yy second
#define eps 1e-9
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000
#define mx 0
inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


int main() {
    FAST_IO
    string s;
    cin>>s;
    ll ans=s.length();
    for(ll i=0;i<s.length()-1;i++)
    {
	if(s[i]!=s[i+1])
        ans=min(ans,max(i+1,(ll)s.length()-i-1));
    }

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


Measured memory_bytes: 512
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$W) = explode(" ",trim(fgets(STDIN)));
$A = explode(" ",trim(fgets(STDIN)));
$B = explode(" ",trim(fgets(STDIN)));

if (array_sum($A)<array_sum($B)) {
  printf("%d\n",-1);
  exit;
}
$goukaku  = true;
$amari = array();
$husoku = array();
for($i=0;$i<$N;$i++) {
  if ($A[$i] < $B[$i]) {
    $goukaku = false;
    $husoku[] = $B[$i]-$A[$i];
  }
  if ($A[$i] > $B[$i]) {
    //余り
    $amari[] = $A[$i]-$B[$i];
  }
}
if ($goukaku) {
  printf("%d\n",0);
  exit;
}
rsort($amari);
$s = array_sum($husoku);
$total = count($husoku);
foreach($amari as $v) {
  $s = $s - $v;
  $total++;
  if ($s < 0) break;
}
printf("%d\n",$total);


Measured memory_bytes: 27248
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

// カウンター
template <typename T>
struct Counter {
  map<T, ull> cnt;
  void add(T key) {
    if (cnt.count(key)) {
      cnt[key]++;
    } else {
      cnt[key] = 1;
    }
  }
  void add(vector<T> keys) {
    for (auto key : keys) {
      add(key);
    }
  }
  ll get(T key) {
    if (cnt.count(key)) {
      return cnt[key];
    } else {
      return 0;
    }
  }
  pair<T, ull> max() {
    T key;
    ull mx = 0;
    for (auto kv : cnt) {
      if (kv.second > mx) {
        mx = kv.second;
        key = kv.first;
      }
    }
    return make_pair(key, mx);
  }
};

int counts[200010] = {};

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

  int N, K;
  cin >> N >> K;
  Counter<int> c;

  REP(i, N) {
    int a;
    cin >> a;
    c.add(a);
  }
  int tot = 0;
  for (auto kv : c.cnt) {
    counts[tot++] = kv.second;
  }
  sort(counts, counts + tot);
  int ans = 0;
  REP(i, tot - K) {
    ans += counts[i];
  }

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


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

const int MAXN = 2e5 + 10, MAXA = 1e6 + 6, SQRT = 447;
int p[300];
string s1, s2;

int main() {
    cin >> s1 >> s2;
    for (int i = 0; i < s1.size(); i++) {
        bool ok = true;
        for (int j = 0; j + i < s1.size(); j++)
            if (s1[i + j] != s2[j])
                ok = false;
        for (int j = 0; j < i; j++)
            if (s1[j] != s2[s1.size() - i + j])
                ok = false;
        if (ok) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
while True:
	m, f, r = list(map(int, input().split()))
	if m == f == r ==-1:
		break
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif 65 <= m + f < 80:
		print("B")
	elif 50 <= m + f < 65:
		print("C")
	elif 30 <= m + f < 50:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")
		


Measured memory_bytes: 5592
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

vector<int> msp;

bool isMSP(int n) {
  for (int i = 0; i < msp.size(); i++) {
    if (n % msp[i] == 0) return false;
  }
  return true;
}

void makeMSP(int n) {
  msp.pb(6);
  msp.pb(8);
  for (int i = 2; i <= n/7; i++) {
    if (isMSP(7*i-1)) msp.pb(7*i-1);
    if (isMSP(7*i+1)) msp.pb(7*i+1);
  }
}

int main() {
  int n;
  makeMSP(300000);
  while (cin >> n, n > 1) {
    vector<int> msp_n;
    for (int i = 0; i < msp.size(); i++) {
      if (n % msp[i] == 0) msp_n.pb(msp[i]);
    }
    cout << n << ":";
    for (int i = 0; i < msp_n.size(); i++) {
      cout << " " << msp_n[i];
    }
    cout << el;
  }
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;
typedef  long long ll;
const int maxn=200;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
int arr[maxn];

int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    int ans=0;
    for(ll i=n;i<=m;i*=2)
    {
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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

#define MAX 10000
#define INFTY (1<<29)

class DisjointSet{
	public:
		vector<int> rank, p;

	//constructor
	DisjointSet() {}
	DisjointSet(int size){
		rank.resize(size, 0);
		p.resize(size, 0);
		for(int i=0; i<size; ++i) makeSet(i);
	}


	void makeSet(int x){
		p[x]=x;
		rank[x]=0;
	}

	bool same(int x, int y){
		return findSet(x)==findSet(y);
	}

	void unite(int x, int y){
		link(findSet(x), findSet(y));
	}

	void link(int x, int y){
		if(rank[x]>rank[y]){
			p[y]=x;
		}
		else {
			p[x]=y;

			if(rank[x]==rank[y]) rank[y]++;
		}
	}

	int findSet(int x){
		if(x!=p[x]) p[x]=findSet(p[x]);

		return p[x];
	}
};

class Edge{
public:
	int source, target, cost;

	Edge(int source=0, int target=0, int cost=0):
	source(source), target(target), cost(cost) {}

	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges){
	int totalcost=0;

	sort(edges. begin(), edges.end()); //??°??????????????????????????????????????????

	DisjointSet dset = DisjointSet(N+1);
	for(int i=0; i<N; ++i) dset.makeSet(i);

	int source, target;
	for(int i=0; i<edges.size(); ++i){
		Edge e = edges[i];

		if( !dset.same(e.source, e.target) ){
			totalcost += e.cost;
			dset.unite(e.source, e.target);
		}
	}

	return totalcost;
}

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

	vector<Edge> edges;

	for(int i=0; i<M; ++i){
		int s, t, c;
		cin >> s >> t >> c;
		edges.push_back(Edge(s, t, c));
	}

	cout << kruskal(N, edges) << endl;
}

Measured memory_bytes: 3616
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		Deque<Integer> stack = new LinkedList<Integer>();
		for (int i=0; i<n; i++) {
			stack.add(stdIn.nextInt());
		}
		while(stack.size()>1){
			System.out.print(stack.pollLast()+" ");
		}
		System.out.println(stack.pollLast());
	}
}

Measured memory_bytes: 19108
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define prinvec(a, n) for(ll i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	int n;
	string s;
	cin >> n >> s;

	vi r, g;
	ll sz = 0;
	fr(i,0,n)
	{
		if(s[i] == 'R')
			r.pb(i);
		else if(s[i] == 'G')
			g.pb(i);
		else
			sz++;
	}


	ll sum = 0;
	for(auto x: r)
	{
		for(auto y: g)
		{
			int a = x;
			int b = y;
			if(a > b)
				swap(a, b);
			int tmp1 = 2 * b - a;
			int tmp2 = 2 * a - b;
			int tmp3 = ((a + b) & 1) ? -1 : ((a + b) / 2);
			int diff = 0;
			
			if(tmp1 < n && s[tmp1] == 'B')
				diff++;

			if(tmp2 >= 0 && s[tmp2] == 'B')
				diff++;

			if(tmp3 >= 0 && s[tmp3] == 'B')
				diff++;

			sum += sz - diff;
		}
	}

	cout << sum;
}

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

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

  vector<pair<int,int>> r(N),b(N);
  for(int i = 0;i < N;i++) cin >> r.at(i).first >> r.at(i).second;

  for(int i = 0;i < N;i++) cin >> b.at(i).first >> b.at(i).second;

  sort(b.begin(),b.end());
  int ans = 0;
  for(int i = 0;i < N;i++) {
    int x = b.at(i).first,y = b.at(i).second;
    int MY = -1,idx = -1;
    for(int j = 0;j < N;j++) {
      if(r.at(j).first == -1 || r.at(j).first >= x) continue;
      if(r.at(j).second > MY && r.at(j).second < y) {
        MY = r.at(j).second;
        idx = j;
      }
    }
    if(idx != -1) {
      r.at(idx).first = -1;
      ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, n;

void solve(){
    scanf("%d", &n);
    ans = 1000*(n/500);
    n%=500;
    ans += 5*(n/5);
    printf("%d\n", ans);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    int n; cin >> n;
    int dp[n+1]; rep(i,n+1) dp[i] = 1<<30; dp[0] = 0;

    rep(i,n){
        for(int j=1; i+j <= n; j*=6){
            dp[i+j] = min(dp[i+j], dp[i]+1);
        }
        for(int j=1; i+j <= n; j*=9){
            dp[i+j] = min(dp[i+j], dp[i]+1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3916
//
// Created by tattsun on 2017/02/11.
//

#include <iostream>
#include <vector>
#include <algorithm>

#define NODE_MAX 8
#define EDGE_MAX 28
#define NIL -1

using namespace std;

struct Edge {
    Edge(): a(NIL), b(NIL) {
    }
    int a;
    int b;

    int destination(int from) {
        if(a == from) return b;
        else if(b == from) return a;
        else {
            cout << "err: destination" << endl;
            exit(1);
        }
    }

    bool is_nil() {
        return a == NIL && b == NIL;
    }
};

int n, m;
vector<Edge*> ns[NODE_MAX];
Edge es[EDGE_MAX];

int visit(int node, vector<int> visited) {
    visited.push_back(node);

    if(visited.size() == n) return 1;

    int paths = 0;
    for(int i=0; i<ns[node].size(); i++) {
        int dest = ns[node][i]->destination(node);
        if(find(visited.begin(), visited.end(), dest) != visited.end()) {
            continue;
        }

        paths += visit(dest, visited);
    }

    return paths;
}

int solve() {
    return visit(0, vector<int>());
};

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

    int a, b;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        a -= 1;
        b -= 1;
        es[i].a = a;
        es[i].b = b;
        ns[a].push_back(&es[i]);
        ns[b].push_back(&es[i]);
    }

    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	string s;
  	cin >> s;
  	if(s[0]==s[2]){
      cout << "Yes" << endl;
    }
  	else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long ll;
int a[3], i;

int main()
{
	while(cin >> a[0] >> a[1] >> a[2])
	{
		sort(a, a + 3);
		if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
l=[0]*4
while 1:
    try:
        a,b=map(str,raw_input().split(","))
        if b=="A":
            l[0]+=1
        elif b=="B":
            l[1]+=1
        elif b=="AB":
            l[2]+=1
        else:
            l[3]+=1
    except:
        break
for i in l:
    print i

Measured memory_bytes: 6228
import math
while True:
    n = int(input())
    if n == 0:
        break
    points = list(map(int, input().split()))
    m = sum(points) / len(points)
    t = 0
    for i in range(n):
        t += (points[i] - m)**2
    a2 = t/n
    print(math.sqrt(a2))


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int H, W;
    cin >> H >> W;
    string str;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> str;
            if (str == "snuke") {
                cout << (char)('A' + j) << i+1 << endl;
                return;
            }
        }
    }

    


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  string s;
  cin >> s;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';
  REP(x, 0, (1 << 3)) {
    int tmp = a;
    if ((x >> 0) & 1) {
      tmp += b;
    } else {
      tmp -= b;
    }
    if ((x >> 1) & 1) {
      tmp += c;
    } else {
      tmp -= c;
    }
    if ((x >> 2) & 1) {
      tmp += d;
    } else {
      tmp -= d;
    }
    // cout << tmp << endl;
    if (tmp == 7) {
      cout << a;
      if ((x >> 0) & 1) {
        cout << "+";
      } else {
        cout << "-";
      }
      cout << b;
      if ((x >> 1) & 1) {
        cout << "+";
      } else {
        cout << "-";
      }
      cout << c;
      if ((x >> 2) & 1) {
        cout << "+";
      } else {
        cout << "-";
      }
      cout << d;
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;
 

int main()
{
    int N; ll K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> F(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];
    sort(A.rbegin(),A.rend());
    sort(F.begin(),F.end());
    ll l = -1LL;
    ll r = 1e12;
    ll X;
    while(l+1<r){
        ll Kc = K;
        X = (l+r)/2;
        rep(i,N){
            Kc -= max(0LL,A[i] - X/F[i]);
        }
        if (Kc<0) l = X;
        else r = X;
        
    }
    cout << r;
    
    rn 0;
}

Measured memory_bytes: 1792
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

total = sum(a2)+a1[0]
ans = total
for i in range(1, n):
    total = total + a1[i] - a2[i-1]
    ans = max(ans, total)

print(ans)


Measured memory_bytes: 3060
import java.io.*;

class Main {
	public static void main(String[] args){
		int a, b, c, x, A;
		String buf;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			buf = br.readLine();
			String[] line = buf.split(" ");
			
			a = Integer.parseInt(line[0]);
			b = Integer.parseInt(line[1]);
			c = Integer.parseInt(line[2]);
			A = 0;
			for(x=a;x<=b;x++){
				if(c % x == 0){
					A = A+1;
				}
			}
			System.out.print(A);
		} catch(Exception e){
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 24264
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int R;
    cin >> R;
    if (R < 1200)
    {
        cout << "ABC" << endl;
    }
    else if (R >= 1200 && R < 2800)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int i,temp;
	int num[100];
	int t;
	cin >> t;
	for( i=0;i<t;i++ ){
		cin >> num[i];
	}
	for( i=0;i<t/2;i++ ){
		temp = num[i];
		num[i] = num[t-i-1];
		num[t-i-1] = temp; 
	}
	for( i=0;i<t;i++ ){
		if(i==t-1)
			cout << num[i] << endl;
		else 
		cout << num[i] << " ";	
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
	long long int m,k,n,a[200009];
	string s;
	cin>>n>>m>>k;
	cout<<k<<" "<<n<<" "<<m;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	int f,a[101]={0},c[100]={0},d[101]={0},e[101]={0},ans=0;
	scanf("%d",&f);
	for(int i=0;i<f-1;i++){
		scanf("%d",&c[i]);
	}
	e[f-1]=c[f-2];
	for(int i=f-2;i>=0;i--){
		if(i==0){
			e[i]=c[0];
			continue;
		}
		a[i]=c[i];
		d[i]=a[i];
		a[i-1]=a[i]=c[i-1];
		e[i]=a[i];
		if(a[i]>=d[i]){
			e[i]=d[i];
		}
	}
	for(int i=0;i<f;i++){
		ans+=e[i];
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
long long A,B;



long long facctorialMethod(int k);


long long facctorialMethod(int k){
    long long sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = sum * i % 1000000007;
    }
    return sum;
}


int main()
{

	cin >> A >> B;
	long long ans = 0;
	if(abs(A-B) >= 2){
		cout << 0 << endl;
		return 0;
	}else{
		ans = facctorialMethod(A) * facctorialMethod(B) % 1000000007;
	}

	if(abs(A-B) == 0)
		ans = ans * 2 % 1000000007;

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24244
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
    }else{
        cout<<1000-(n%1000)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3224
from collections import deque
N = int(input())
que = deque(['a'])

while len(que) > 0:
    s = que.popleft()
    if len(s) == N:
        print(s)
    else:
        for i in range(ord(sorted(s)[-1]) - 95):
            que.append(s + chr(97 + i))

Measured memory_bytes: 11864
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
# 終了時、T*P枚支払う
graph = []
for _ in range(M):
    a, b, c = lr()
    graph.append((a, b, c))

def bellmanford(N, start):
    INF = 10 ** 12
    dist = [-INF] * (N+1) # 1-indexed
    dist[start] = 0
    for i in range(N+N+5):
        for (pre, ne, weight) in graph:
            if dist[pre] != -INF and dist[pre] + weight - P > dist[ne]:
                dist[ne] = dist[pre] + weight - P
                # n回繰り返してもスコアが更新された場合
                if i > N-1:
                    dist[ne] = INF
    if dist[N] == INF:
        return -1
    else:
        return max(0, dist[N])

answer = bellmanford(N, 1)
print(answer)


Measured memory_bytes: 41968
#include<stdio.h> 

int Sun[105];

int main(){
	//数组：Sun为0；有食物为1；输出为0的Sun
	for(int i=0;i<105;i++) {
		Sun[i]=0;
	}
	int num=0,row=0;
	scanf("%d %d",&num,&row);
	
	int d=0,temp=0;
	
	for(int i=0;i<row;i++){
		d=0;
		scanf("%d",&d);
		for(int i=0;i<d;i++){
			temp = 0;
			scanf("%d",&temp);
			Sun[temp-1]=1;
		}
	}
	
	int count=0;
	for(int i=0;i<num;i++){
		if(Sun[i]==0)count++;

	}
	printf("%d\n",count);
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21)
        cout<<"bust";
    else
        cout<<"win";
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

sum = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        sum += math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)

ans = sum / n
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	char s[30];
	cin >> s;
	int cnt;
	for (cnt = 0; s[cnt] != ','; cnt++){
		cout << s[cnt];
	}
	cout << " ";
	for (cnt += 1; s[cnt] != ','; cnt++){
		cout << s[cnt];
	}
	cout << " ";
	for (cnt += 1; s[cnt] != '\0'; cnt++){
		cout << s[cnt];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	bool f = true;
	for (int i = 0; i < n/2; i++) {
		if (s[i] != s[i + n / 2])f = false;
	}

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

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll N;
    cin >> N;
    vll a(N+1),b(N+1);
    a[0]=0; b[0]=0;
    bool f;
    FOR(i,1,N){
        cin >> a[i];
    }
    if(N>2){
        //b[N/2+1] ~ b[N]は確定
        FOR(i,N/2+1,N){
            b[i] = a[i];
        }
//        puts("a");
        rFOR(i,1,N/2){
            f=0;
            FOR(j,2,N/i){
                f ^= b[j*i];
            }
            b[i] = f^a[i];
//            cout << "b[" << i << "]=" << b[i] << endl;;
        }
    }else if(N==1){
        b[1]=a[1];
    }else{ //N==2
        b[2]=a[2];
        b[1]=a[1]^a[2];
    }
    ll balls = count(b.begin(),b.end(),1);
    cout << balls << endl;
    if(balls>0){
        FOR(i,1,N){
            if(b[i]==1){
                cout << i << endl;
            }
        }
    }
}

Measured memory_bytes: 3968