akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 1e5;
int n, k, now, cnt, ans, l, r, tmp, next_l, next_r;
char S[MAX];
string s;
vector<int> C, SUM;

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", S);
    s = S;
    now = 1;
    cnt = 0;

    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == '0' + now ) {
            cnt++;
        } else {
            C.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }

    if ( cnt != 0 ) {
        C.push_back(cnt);
    }

    if ( C.size() % 2 == 0 ) {
        C.push_back(0);
    }

    SUM.push_back(0);
    for ( int i = 0; i < (int)C.size(); i++ ) {
        SUM.push_back(SUM[i] + C[i]);
    }

    ans = 0;

    for ( int i = 0; i < (int)C.size(); i += 2 ) {
        l = i;
        r = min(i + 2 * k + 1, (int)C.size());
        tmp = SUM[r] - SUM[l];
        ans = max(tmp, ans);
    }

    printf("%d\n", ans);
    return 0;
}




Measured memory_bytes: 1656
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	string s = scan;
  int x;
  foreach(c; s){
    x += (c - '0');
    x %= 9;
  }
  if(x % 9 == 0) "Yes".writeln;
  else "No".writeln;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    rep(i, 0, N) cin >> x[i];
    rep(i, 0, M) cin >> y[i];
    for (int Z = X + 1; Z <= Y; ++Z)
    {
        bool ok = true;

        rep(i, 0, N)
        {
            if (x[i] >= Z)
            {
                ok = false;
                break;
            }
        }

        rep(i, 0, M)
        {
            if (y[i] < Z)
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            cout << "No War" << endl;
            return;
        }
    }
    cout << "War" << endl;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 500010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll binPowMod(ll a, ll b) {
    a %= MODBASE;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MODBASE;
        a = a * a % MODBASE;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a+b) % MODBASE;
}

ll mul(ll a, ll b) {
    return (a*b) % MODBASE;
}

ll sub(ll a, ll b) {
    return (a-b+MODBASE) % MODBASE;
}

ll f[MAXN], inv[MAXN];
int n, m;

ll C(int N, int K) {
    if (K > N || K < 0) return 0;
    return mul(f[N], mul(inv[N-K], inv[K]));
}

void init() {
    f[0] = 1;
    inv[0] = binPowMod(f[0], MODBASE-2);
    FOR(i,1,500000) {
        f[i] = mul(f[i-1], i);
        inv[i] = binPowMod(f[i], MODBASE-2);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    init();
    cin >> n >> m;
    ll res = mul(C(m, n), f[n]);
    FOR(i,1,n) {
        ll k = mul(C(n,i), mul(C(m-i, n-i), f[n-i]));
        if (i % 2) res = sub(res, k);
        else res = add(res, k);
    }
    res = mul(res, mul(C(m, n), f[n]));
    cout << res;
    return 0;
}


Measured memory_bytes: 11408
#include<stdio.h>

int main(){
    int N;
    int ans=0;
    int tmp=10;

    scanf("%d", &N);
    for(int i=1; i<=N; i++){
        if(i==tmp){
            tmp=tmp*100;
            i=i*10-1;
        }else{
            ans++;
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    //入力
    int a, b, c, d, e;
    int k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    
    //処理
    string ans = "";
    int L = e - a;
    if (L > k) ans = ":(";
    else ans = "Yay!";
    
    //出力
    cout << ans << endl;
    
}

Measured memory_bytes: 256
n = gets.to_i
memo = Array.new(10) { Array.new(10, 0) }
memo_reverse = Array.new(10) { Array.new(10, 0) }
1.upto(n) do |num|
  next if num % 10 == 0
  s = num.to_s
  memo[s[0].to_i][s[-1].to_i] += 1
  memo_reverse[s[-1].to_i][s[0].to_i] += 1
end
memo_flatten = memo.flatten
memo_reverse_flatten = memo_reverse.flatten
sum = 0
100.times do |i|
  sum += memo_flatten[i] * memo_reverse_flatten[i]
end
puts sum


Measured memory_bytes: 1788
n = int(input())
s = input()
ans = 0

def isAvailable(pw):
    for i in range(len(s)):
        if s[i] == pw[0]:
            pw = pw[1:]
            if pw == '':
                break

    if len(pw) == 0:
        return True
    else:
        return False

for i in range(10):
    for j in range(10):
        for k in range(10):
            pw = str(i) + str(j) + str(k)
            if isAvailable(pw):
                ans += 1

print(ans)

Measured memory_bytes: 39792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,a,b;
  cin >> n>>a>>b;
  
  vector<ll> p(n);
  vector<ll> q(n);
  
  ll ans = 0;
  rep(i,n){
  cin>>p[i]>>q[i];
    if(p[i]>=a && q[i]>=b)ans++; 
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//int a[5];
	int ans,x,n,i;
	cin>>x>>n;
	if(n==0)
	cout<<x<<endl;
	else
	{  
	int a[102]={0};
	for(i=0;i<n;i++)
	{
	cin>>ans;
	a[ans]=1;
    }
    
int f,b,fans;
	for(i=x;i<=101;i++)
	{
	   if(a[i]==0)
	   {
	   f=i;
	   break;  
     }
 }
	for(i=x;i>=0;i--)
	{
	   if(a[i]==0)
	   {
	   b=i;
	   break;  
     } 
 }
b=x-b;
f=f-x;
if((f<b&&(x+f<=101))||(x-b<0))
fans=x+f;
else
fans=x-b;
cout<<fans;
}
}


Measured memory_bytes: 3592
<?php

$S = trim(fgets(STDIN));
$len = strlen($S) - 1;
 
$ti = [];
$ti[$len] = (int)$S[$len] % 2019;
$mod_table = [];
$mod_table[$ti[$len]] = 1;
$mod_pow_ten_table = [];
$mod_pow_ten_table[0] = 1;
 
$ans = 0;
for ($i = $len; $i > 0; $i--) {
    $mod_pow_ten_table[$len - $i + 1] = $mod_pow_ten_table[$len - $i] * 10 % 2019;
    $ti[$i - 1] = ((int)$S[$i - 1] * $mod_pow_ten_table[$len - $i + 1] + $ti[$i]) % 2019;
    $mod_table[$ti[$i - 1]] += 1;
}
 
foreach ($mod_table as $index => $num) {
    if ($index === 0) {
        $num += 1;
    }
    $ans += $num * ($num - 1) / 2;
}
 
echo $ans;


Measured memory_bytes: 33236
#import math
import fractions

N,X=input().split()
N=int(N)
X=int(X)
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
de=[]#deference 差
for i in range( 0, len(x)-1 ):
    dei=x[i+1]-x[i]
    if(dei>0):
        de.append(dei)

#最大公約数だった
#その数を作る素因数をすべて抜き出し、
#一致するものをすべて抜き出せばできる
gcddd=de[0]#最大公約数
for i in range(1,len(de)):
    gcddd=fractions.gcd(gcddd,de[i])
print(gcddd)

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

int main(){
  int n;
  cin >> n;
  map<int,int> m;
  for(int i = 0; i < n;i++){
    int a;
    cin >> a;
    if(m.count(a)) m.at(a)++;
    else m[a] = 1;
  }
  int ans = 0;
  for(pair<int,int> p : m) if(p.second % 2 == 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 4992
//2020年3月21日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


vi e[2005];

int anscnt[2005];
int dis[2005][2005];



int main(){
	int n,x,y;
	cin >> n >> x >> y;


	rep(i,n){
		e[i].push_back(i+1);
		e[i+1].push_back(i);
	}
	e[x-1].push_back(y-1);
	e[y-1].push_back(x-1);

	rep(i,2005)rep(j,2005){
		dis[i][j] = -1;
	}

	rep(i,n){
		queue<pii> q;
		q.push(mp(i,0));
		while(!q.empty()){
			pii tmp = q.front();
			q.pop();
			if(dis[i][tmp.F] !=-1) continue;
			dis[i][tmp.F] = tmp.S;
			for(const auto& j : e[tmp.F]){
				q.push(mp(j,tmp.S+1));
			}
		}
	}

	rep(i,n)rep(j,n){
		anscnt[dis[i][j]]++;
	}

	rep1(i,n-1){
		prints(anscnt[i]/2);
	}




	return 0;
}



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

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

    long long ans = 0;
    for (int i = 0; i < (1 << (s.size() - 1)); i++) {
        long long res = 0, last = 0;
        for (int j = 0; j < s.size(); j++) {
            last = 10 * last + (s[j] - '0');
            if (i & (1 << j)) {
                res += last;
                last = 0;
            }
        }
        ans += res + last;
    }

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

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

#define MAXN 100

using namespace std;

int main()
{
  int n,l;
  string S[MAXN+1];
  string ans;

  cin >> n >> l;

  for ( int i = 0; i < n; ++i ) cin >> S[i];

  sort( S, &S[n] );

  for ( int i = 0; i < n; ++i ) ans += S[i];

  cout << ans << "\n";
}


Measured memory_bytes: 760
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
k = 1000000000000000000
r = 1
if (a.include?(0))
  puts '0'
  exit
end

a = a.sort.reverse
a.each do |num|
  if (r > k)
    puts '-1'
    exit
  end
  r *= num
end
puts r > k ? '-1' : r

Measured memory_bytes: 24904
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main()
{
    vi x(5);
    rep(i, 5)
    {
        cin >> x[i];
        if (x[i] == 0)
        {
            cout << i + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,a[200001],i,j,ans=0;
  cin>>n;
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    ans^=a[i];
  }
  for(i=0;i<n;i++){
    j=ans^a[i];
    printf("%lld ",j);
  }
}


Measured memory_bytes: 5264
N = int(input())
A = list(map(int,input().split()))
from collections import deque
b = deque()
for i in range(N):
    if i%2==0:
        b.append(A[i])
    else:
        b.appendleft(A[i])
out = list(b)
if N%2==0:
    print(*out)
else:
    print(*out[::-1])


Measured memory_bytes: 106068
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vint d;

bool check(int n) {
    while (n > 0) {
        for (int di : d) {
            if (di == n%10) return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    int n, k;
    cin >> n >> k;
    d.resize(k);
    rep(i, k) cin >> d[i];
    sort(all(d));

    int ans = n;
    while (!check(ans)) {
        ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int a[2100];

void solve() {
  for (int i = 0; i < N; ++i) {
	for (int j = i+1; j < N; ++j) {
	  if (abs(a[i] - a[j]) % (N-1) == 0) {
		cout << a[i] << " " << a[j] << endl;
		return;
	  }
	}
  }
}

int main() {
  while (cin >> N) {
	for (int i = 0; i < N; ++i) cin >> a[i];

	solve();
  }
}











Measured memory_bytes: 3108
#include <algorithm>
#include <iostream>

using namespace std;

int dp[20200];

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

  for (int i = 0; i < N; i++) {
    int v, w;
    cin >> v >> w;

    for (int j = W; j >= 0; j--) {
      if (dp[j + w] < dp[j] + v) {
        dp[j + w] = dp[j] + v;
      }
    }
  }
  cout << max_element(dp, dp + W + 1)[0] << endl;

  return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
#include<bitset>
#define mod 998244353
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)mul(res,x);
	mul(x,x);
    }
    return res;
}

ll n;
string s;

ll f[200010];
void solve(ll m){
    ll res=0;
    for(int i=0;i<m;i++){
	if(s[i]=='1')mad(res,po(2,(m-i-1)));
    }
    bool ok=1;
    for(int i=0;i<n;i++){
	ll p=i%(2*m);
	char c;
	if(p<m)c=s[p];
	else c='0'+(s[p-m]=='0');
	
	if(s[i]<c)ok=0;
	if(s[i]!=c)break;
    }
    res+=ok;
    
    for(int i=1;i<m;i++){
	if(m%i==0)mad(res,-f[i]);
    }
    res%=mod;
    if(res<0)res+=mod;
    f[m]=res;
}

int main(){
    cin>>n>>s;
    ll ans=0;
    for(int i=1;i<=n;i++){
	if(n%i==0&&(n/i)%2==1){
	    solve(i);
	    mad(ans,i*f[i]);
	}
    }
    mul(ans,2);
    cout<<ans<<endl;
}



Measured memory_bytes: 644
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A;

  cin >> A;

  cout << A + A * A + A * A * A << endl;
  return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll x,n;
    cin >>x >> n;
    vector<ll>a(n);
    vector<bool>che(2000,true);
    bool one =false;
    for(int i=0;i<n;i++){
        cin >>a.at(i);
        if(a.at(i)==1)one =true;
        che.at(a.at(i))=false;
    }
    if(one&&x==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans =1e18;
    for(int j=0;j<2000;j++){
        ll ato = x-j;
        ll saki = x+j;
        if(ato<0||saki>=1000)continue;
        if(che.at(ato)){
            cout<<ato<<endl;
            return 0;
        }
        if(che.at(saki)){
            cout<<saki<<endl;
            return 0;
        }
    }
}
    



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 500005
#define MX 1048576
#define MOD 1000000007
using namespace std;
using LL = long long;
int n,in[M];
LL pw[M];
vector<int> pos[MX];
int find_nxt(int p,int num) {
    auto it = upper_bound(pos[num].begin(), pos[num].end(), p);
    if (it==pos[num].end()) return n+1;
    return *it;
}
int find_cnt(int p1,int p2,int num) {
    auto it1 = upper_bound(pos[num].begin(), pos[num].end(), p1);
    auto it2 = lower_bound(pos[num].begin(), pos[num].end(), p2);
    if (it2 == pos[num].begin()) return 0;
    it2 -= 1;
    if (it1<=it2) return it2-it1+1;
    return 0;
}
int main()
{
    pw[0] = 1;
    REP(i,1,M-1) pw[i] = (pw[i-1]*2) % MOD;
    
    while (~scanf("%d",&n)) {
        REP(i,0,MX-1) pos[i].clear();
        REP(i,1,n) scanf("%d", &in[i]);
        REP(i,2,n) in[i] ^= in[i-1];
        REP(i,1,n) pos[in[i]].push_back(i);

        //REP(i,1,n) printf("%d ",in[i]); puts("");

        LL ans = 0;
        REP(i,1,MX-1) if (in[n]==0 || in[n]==i) {
            LL frsum = 0;
            LL frdp = 0;
            LL dp = 0;

            REP(j,0,(int)pos[i].size()-1) {
                int fri = j==0 ? 0 : pos[i][j-1];
                int c0 = find_cnt(fri, pos[i][j], 0);
                
                frdp = (frdp + frsum * c0) % MOD;
                dp = (frdp + 1) % MOD;
                frsum = (frsum + dp) % MOD;
            }
           
            if (in[n]==0) {
                ans += frsum;
                ans %= MOD;
            } else {
                ans += dp;
                ans %= MOD;
            }
        }

        if (in[n]==0) {
            int len = 0;
            REP(i,1,n-1) if(in[i]==0) len++;
            ans += pw[len];
            ans %= MOD;
        }


        printf("%lld\n", ans);
    }
    return 0;
}







Measured memory_bytes: 40308
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            String c = in.next();

            if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
vector<int> routes[100001];

template <typename T>
void logVector(vector<T> data)
{
    cout << endl
         << "vector: " << typeid(T).name() << endl;
    rep(i, data.size())
    {
        cout << i << ": " << data[i] << endl;
    }
    cout << endl;
}

int main()
{
    ll n, m, res = 0;

    cin >> n >> m;
    vector<int> h(n), a(m), b(m);
    rep(i, n)
    {
        cin >> h[i];
    }
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        routes[a[i] - 1].push_back(b[i] - 1);
        routes[b[i] - 1].push_back(a[i] - 1);
    }
    rep(i, n)
    {
        // logVector<int>(routes[i]);
        bool flag = false;
        rep(j, routes[i].size())
        {
            if (h[i] <= h[routes[i][j]])
            {
                flag = true;
            }
        }
        if (!flag)
            res++;
    }

    cout << res << endl;
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

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

    int k, a, b;
    cin >> k >>  a >> b;       

    bool flag=false;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            flag=true;
            break;
        }
    }

    flag?cout<<"OK\n":cout<<"NG\n";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	string s;
	cin>>s;
	ll n=s.size(),f1=1,f2=1,f3=1;
	for(ll i=0;i<n;i++){
	    if(s[i]!=s[n-1-i]){
	        f1=0;
	        break;
	    }
	}
	for(ll i=0;i<(n-1)/2;i++){
	    if(s[i]!=s[(n-1)/2 - 1 -i]){
	        f2=0;
	        break;
	    }
	}
	for(ll i=0;i<(n-1)/2;i++){
	    if(s[(n+1)/2 + i]!=s[n - 1 -i]){
	        f3=0;
	        break;
	    }
	}
	if(f1*f2*f3){
	    cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL A[211];
char S[211];
LL B[60];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", A+i);
    scanf("%s", S);

    memset(B, 0, sizeof B);
    bool zero = true;

    for (int i=N; i--;) {
	LL a = A[i];
	if (S[i] == '0') {
	    REP (t, 60) if (a >> t & 1) {
		if (B[t]) a ^= B[t];
		else { B[t] = a; break; }
	    }
	} else {
	    REP (t, 60) if (a >> t & 1) {
		if (B[t]) a ^= B[t];
		else { break; }
	    }
	    if (a) { zero = false; break; }
	}
    }

    puts(zero? "0": "1");
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

struct req{
    int a,b,c,d;
};

template<class I, class F>
void each_series(I bg, I en, int mi, int mx, const F& f)
{
    if(bg == en){
        f();
        return;
    }
    for(int i = mi; i <= mx; ++i){
        *bg = i;
        each_series(bg + 1, en, i, mx, f);
    }
}

int calc_score(const vector<int>& A, const vector<req>& reqs)
{
    int score = 0;
    for(auto& r : reqs){
        if(A[r.b-1] - A[r.a - 1] == r.c){
            score += r.d;
        }
    }
    return score;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<req> reqs(Q);
    for(auto& r : reqs){ cin >> r.a >> r.b >> r.c >> r.d; }
    
    vector<int> A(N);
    int score = 0;
    each_series(begin(A), end(A), 1, M, [&](){
        //for(int a : A){
        //    cout << a << ',';
        //}
        //cout << '\n';
        score = max(score, calc_score(A, reqs));
    });
    cout << score << '\n';
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		System.out.println(((n * (n - 1)) / 2) + ((m * (m - 1)) / 2));
	}

}


Measured memory_bytes: 22740
/*
 * 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 = 105;
const ll mm = 1e+18;
vector<int>gr[N];
int ans=0;
void dfs(int he,int n,vector<bool>vis){
    vis[he]=true;
    int tot=0;
    rep1(i,n) if(vis[i]) tot++;
    if(tot==n){
        ans++;
        return;
    }
    for(auto x:gr[he]){
        if(!vis[x]){
            dfs(x,n,vis);
        }
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    rep0(i,m){
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    vector<bool>vis(n+1,false);
    dfs(1,n,vis);
    pr(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: 3668
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n, 0);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        v[a - 1]++;
        v[b - 1]++;
    }

    rep(i, n)
    {
        cout << v[i] << endl;
    }
    return (0);
}


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

using namespace std;

string str[4] = {"AC", "WA", "TLE", "RE"};

int main() {
    int N;
    string s;
    map<string, int> cnt;
    cin >> N;
    while(N--) {
        cin >> s;
        cnt[s]++;
    }
    for(int i = 0; i < 4; ++i) {
        cout << str[i] << " x " << cnt[str[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
n = int(input())
x = input()

# ビット反転させる場所
# one_pop_count（1 -> 0）：1回目の割る値
# zero_pop_count（0 -> 1）：1回目の割る値
original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    # one_pop_count が 0 である場合は剰余演算を行わない ==> one_mod は 0
    if one_pop_count != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

# f の前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i//2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

# pow2 の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
    zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count

# n-1, n-2, ... 0
for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt] + 1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt] + 1)


Measured memory_bytes: 30260
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x;
      cin>>x;

      int rem = x % 100;

       int div = x/100;

     if(x==0)
     cout<<"0";

     else
     {
         int z=div*5;

           if(rem>=0 && rem<=z)
           cout<<"1";

           else
           cout<<"0";
     }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000010
#define RANGE 10010

int A[MAX];
int B[MAX];
int C[RANGE] = {0};

void countingSort(int A[], int B[], int n, int r)
{
    int i;
    // ??????
    for (i=0; i<n; i++) {
        C[A[i]]++;
    }
    
    // ??°?????????
    for (i=1; i<r; i++) {
        C[i] += C[i-1];
    }
    
    // ?????????
    for (i=n-1; i>=0; i--) {
        B[--C[A[i]]] = A[i];
    }    
}

int main()
{
    int i, N;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    
    countingSort(A, B, N, RANGE);
    
    for (i=0; i<N; i++) {
        printf("%d", B[i]);
        if (i<N-1) printf(" ");
    }
    puts("");
    
    return 0;
}

Measured memory_bytes: 16280
#include <stdio.h>
#include <string.h>
const int maxn = 1e3 +5;
char a[maxn];
int main()
{
    gets(a);
    int n = strlen(a);
    for (int i = 0; i < n / 2; i++)
    if (a[i] != a[n - 1 - i]) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 200010, Mod = 1e9 + 7;
int A[N], B[N], n, fac[8010], ifac[8010];
int C(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int f[4010][4010];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>();
	for (int i = 1; i <= n; i++) {
		A[i] = gi<int>(), B[i] = gi<int>();
		f[2000 - A[i]][2000 - B[i]]++;
	}
	fac[0] = 1;
	for (int i = 1; i <= 8000; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	ifac[8000] = fpow(fac[8000], Mod - 2);
	for (int i = 8000; i >= 1; i--) ifac[i - 1] = 1ll * ifac[i] * i % Mod;
	for (int i = 0; i <= 4000; i++)
		for (int j = 0; j <= 4000; j++) {
			if (i) f[i][j] = (f[i][j] + f[i - 1][j]) % Mod;
			if (j) f[i][j] = (f[i][j] + f[i][j - 1]) % Mod;
		}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + f[A[i] + 2000][B[i] + 2000]) % Mod;
		ans = (ans - C(A[i] + A[i] + B[i] + B[i], A[i] + A[i]) + Mod) % Mod;
	}
	printf("%d\n", 1ll * ans * fpow(2, Mod - 2) % Mod);
	return 0;
}


Measured memory_bytes: 64768
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()
        N := parseInt(line)

        str := nextLine()

        max := -1
        for i := 1; i < N; i++ {
                left := map[string]bool{}

                leftstr := str[:i]
                rightstr := str[i:]

                for _, s := range leftstr {
                        if _, ok := left[string(s)]; !ok {
                                left[string(s)] = true
                        }
                }

                count := 0
                for _, s := range rightstr {
                        if v, _ := left[string(s)]; v {
                                left[string(s)] = false
                                count++
                        }
                }
                if count > max {
                        max = count
                }
        }

        fmt.Println(max)

}


Measured memory_bytes: 768
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 10000
int from[NUM],to[NUM];

int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	if(K > N/2){
		printf("-1\n");
		return 0;
	}

	if(N%2 == 0){

		from[0] = N-1;
		to[0] = 0;

		for(int i = 0; i < N/2-1; i++){
			from[2*i+1] = i;
			to[2*i+1] = N-(i+2);
			from[2*i+2] = i+1;
			to[2*i+2] = N-(i+2);
		}

	}else{

		from[0] = 0;
		to[0] = 1;

		for(int i = 0; i < N/2-1; i++){
			from[2*i+1] = i+1;
			to[2*i+1] = N-(i+1);
			from[2*i+2] = i+2;
			to[2*i+2] = N-(i+1);
		}
		from[N-2] = N/2;
		to[N-2] = N/2+1;
	}

	for(int loop = 0; loop < K; loop++){
		for(int i = 0; i < N-1; i++){
			printf("%d %d\n",from[i]+1,to[i]+1);
			from[i] = (from[i]+1)%N;
			to[i] = (to[i]+1)%N;
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3300
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int a[202020];

int main() {
	int n, k;
	cin >> n >> k;
	int b;
	for (int i = 0; i < n; i++) {
		cin >> b;
		a[b]++;
	}
	vector<int> v;
	for (int i = 0; i < 202020; i++) {
		if (a[i] != 0) {
			v.emplace_back(a[i]);
		}
	}
	sort(ALL(v),greater<int>());
	int count = 0;
	for (int i = 0; i <min((int)(v.size()),k); i++) {
		count += v[i];
	}
	cout << n - count << endl;
}

Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] x = new int[n];
        for (int i = 0; i < n;i++)
        {
            x[i] = sc.NextInt();
        }

        int min = 1000000000;
        for (int i = 0; i < 100; i++)
        {
            int sum = 0;
            for (int j = 0; j < n;j++)
            {
                sum += (x[j] - i) * (x[j] - i);
            }
            if (sum < min) min = sum;
        }
        Console.WriteLine(min);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

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

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define pn putchar('\n')
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define mem0(a) memset(a,0,sizeof(a))
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int mod=1e9+7;
const int N=1e5+5;
ll a[N];
int main()
{
string s;
cin>>s;
int cc=0;
string now,tmp;
rep(i,0,s.length())
{
	 now+=s[i];
	 if(now!=tmp)
	 {
	 	 cc++;
	 	 tmp=now;
	 	 now="";
	 }
 } 
 cout<<cc<<"\n";
}



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

int K, N;
int a[60];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> a[i];
	sort(a, a + N, greater<int>());

	int sum = 0;
	for (int i = 0; i < K; ++i) {
		sum += a[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long a,b,c,ans;
  char j;
  cin >> a >> b >> j >> c;
  ans = a * b;
  ans += a * c / 100;
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3632