akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n, res = 0, max = 0, min = 0;
    cin >> n;
    vector<vector<int64_t>> matrix(10, vector<int64_t>(10, 0));
    int keta = 1;
    for (int i = 1; i < n+1; i++) {
        min = i % 10;
        if (i / keta >= 10) {
            keta *= 10;
        }
        max = i / keta;
        matrix.at(max).at(min)++;
    }
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if(i==j){
                res += matrix.at(i).at(j) * matrix.at(i).at(j);
            }
            if(i!=j){
                res += matrix.at(i).at(j) * matrix.at(j).at(i);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


static const int N = 1000;


int lcs(string x, string y) {
    int c[N + 1][N + 1];
    int m = x.size();
    int n = y.size();
    int res = 0;

    x = ' ' + x;
    y = ' ' + y;

    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int i = 0; i <= n; i++) c[0][i] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i][j - 1], c[i - 1][j]);
            }
            res = max(res, c[i][j]);
        }
    }

    return res;
}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


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

int solve(int n, vector<int> & ws);

int main()
{
    int n = 0;
    cin >> n;
    vector<int> ws(n);
    for (auto & w : ws) cin >> w;
    cout << solve(n, ws) << endl;
    return 0;
}

int solve(int n, vector<int> & ws){
    vector<int> i2w;
    int w2i[10001] = {0};
    for (auto w : ws) w2i[w] = 1;
    int cum = 0;
    for (int w = 0; w != 10001; ++w){
        if (w2i[w]){
            w2i[w] = cum++;
            i2w.push_back(w);
        }
    }
    vector<int> as;
    for (auto w : ws) as.push_back(w2i[w]);
    // loop ???????????????????§?????????????????¨???????
    vector<bool> visited(n);
    for (int i = 0; i != n; ++i) visited[i] = false;
    int cum_cost = 0;
    for (int i = 0; i != n; ++i){
        if (visited[i] || as[i] == i) continue;
        int start = i;
        int pos = as[i];
        int cost = 0;
        int swap_counts = 0;
        while (pos != start){
            ++swap_counts;
            cost += i2w[pos];
            visited[pos] = true;
            pos = as[pos];
        }
        int cost_original = cost + i2w[start] * swap_counts;
        int cost_with_swap = cost + i2w[0] * swap_counts + (i2w[start] + i2w[0]) * 2;
        cum_cost += min(cost_original, cost_with_swap);
    }
    return cum_cost;
}

Measured memory_bytes: 3200
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

def score(s):
  if s == 'r':
    output = P
  elif s == 's':
    output = R
  else:
    output = S
  return output

k_list = [0]*K 
answer = 0
for i in range(K):
  s = T[i]
  ind = i%K
  k_list[ind] = s
  answer += score(s)
for j in range(K,N):
  s = T[j]
  ind = j%K
  if s == T[j-K] and k_list[ind] == s:
    k_list[ind] = 0
  elif s == T[j-K] and k_list[ind] != s:
    k_list[ind] = s
    answer += score(s)
  else:
    k_list[ind] = s
    answer += score(s)
print(answer) 

Measured memory_bytes: 4660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi H(N);
	REP(i, N)cin >> H[i];
	int pre = -1;
	int ans = 0;
	int cnt = 0;
	REP(i, N) {
		if (pre < H[i]) {
			chmax(ans, cnt);
			cnt = 0;
		}
		else {
			cnt++;
		}
		pre = H[i];
	}
	chmax(ans, cnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 200005
#define MAXM 200005

int n, s[MAXN], sum;

int main()
{
    cin >> n;
    REP(i, 0, n){
        cin >> s[i];
        sum += s[i];
    }
    if(sum % 10){
        printf("%d\n", sum);
        return 0;
    }
    sort(s, s + n);
    REP(i, 0, n){
        if((sum - s[i]) % 10){
            printf("%d\n", sum - s[i]);
            return 0;
        }
    }
    printf("0\n");


    return 0;
}
/*
*/





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    ll n;
    cin>>n;
    int dame=0;
    Rep(i,1,3501){
        Rep(j,1,3051){
            if(dame==1){
                continue;
            }
            ll memoa=4*i*j-n*(i+j);
            ll memob=n*i*j;
            if(memoa<=0){
                continue;
            }
            else{
                if(memob%memoa==0){
                    cout<<memob/memoa<<" "<<i<<" "<<j<<endl;
                    dame=1;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

void decitobinbitodeci()
{
    string binary = bitset<8>(128).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();
    cout<<decimal<<"\n";
}

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

/*
1.always remember for ncr(n,2), you can calculate by
n*(n-1)/2
2.Power of 2 ->  (1ll<<i)
*/

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c;
    cin>>a>>b>>c;
    for(int i=b; i<=c; i++)
    {
        if(i%a==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3652
import numpy as np
N,M = map(int, input().split())

p = [tuple(map(int,input().split()))for i in range(N)]
c = [tuple(map(int,input().split()))for i in range(M)]

def distance(a,b):
  return abs(a[0]-b[0]) + abs(a[1]- b[1])

for i in p:
  print(np.argmin([distance(i,j)for j in c])+1)


Measured memory_bytes: 12432
from operator import itemgetter
n = int(input())
s = []
for i in range(n) :
	a,b = input().split()
	s.append([i+1,a,int(b)])
s.sort(key=itemgetter(2),reverse=True)
s.sort(key=itemgetter(1))
print("\n".join(str(s[i][0]) for i in range(n)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],b[1000005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),b[a[i]]=i;
	for(int i=1;i<=n;i++)
	printf("%d ",b[i]);
}

Measured memory_bytes: 5248
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string A;
map<char,ll> mp;
int main (){
      cin>>A;
      ll n=A.size();
      ll ans=(n*(n+1))/2;
      rep0(i,n){
            mp[A[i]]++;
      }
      ll hoge=0;
      for(char c='a';c<='z';c++){
            hoge+=((mp[c]*(mp[c]+1))/2);
      }
      cout<<1+ans-hoge<<endl;
      
      return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    base = [0] * n
    midway = [0] * (n//100 + 1)
    last = [0] * (n//10000 + 1)

    for _ in range(q):
        a, v = (int(s) for s in readline().split())

        a -= 1
        base[a] += v

        b = a - a % 100

        index = b
        value = base[b]
        end = b + 100 if b + 100 < n else n
        for i in range(b, end):
            if value < base[i]:
                value = base[i]
                index = i
        midway[b//100] = index

        c = a - a % 10000
        cc = c // 100

        index = c
        value = base[c]
        for i in midway[cc:cc+100]:
            if value < base[i]:
                value = base[i]
                index = i
        last[c//10000] = index

        index = last[0]
        value = base[index]
        for i in last:
            if value < base[i]:
                value = base[i]
                index = i

        print(index+1, value)
    exit()


if __name__ == '__main__':
    main()

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

bool good(int a, int b) {
	return a + b <= 16 && a <= 8 && b <= 8;
}

int main() {
	int A, B; cin >> A >> B;
	cout << (good(A, B) ? "Yay!" : ":(") << '\n';
	return 0;
}


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


//最大公約数
ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

//最小公倍数
ll lcm(ll x,ll y){

	if(x > y)swap(x,y);

	return y/gcd(x,y)*x;
}

int main(){

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

	ll LCM = 1;
	ll tmp;

	for(int i = 0; i < N; i++){

		scanf("%lld",&tmp);
		LCM = lcm(LCM,tmp);
	}

	printf("%lld\n",LCM);

	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    string s,t;cin>>s>>t;
    vector<ll>sa(s.size()+1),sb(s.size()+1),ta(t.size()+1),tb(t.size()+1);
    REP(i,1,s.size()+1){
        sa[i]=sa[i-1];
        sb[i]=sb[i-1];
        if(s[i-1]=='A')sa[i]++;
        else sb[i]++;
    }
    REP(i,1,t.size()+1){
        ta[i]=ta[i-1];
        tb[i]=tb[i-1];
        if(t[i-1]=='A')ta[i]++;
        else tb[i]++;
    }
    ll q;cin>>q;
    rep(i,q){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        ll x=sa[b]-sa[a-1]-(sb[b]-sb[a-1]);
        ll y=ta[d]-ta[c-1]-(tb[d]-tb[c-1]);
        x%=3,y%=3;
        if(x<0)x+=3;
        if(y<0)y+=3;
        cout<<(x==y?"YES":"NO")<<endl;
    }
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int a[MAXN],cnt[MAXN];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,x,y;
	cin>>n>>m;
	a[1]=1;
	for(int i=1;i<=n;i++)
	{
		cnt[i]=1;
	}
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		cnt[x]--;
		cnt[y]++;
		if(a[x])
		{
			a[y]=1;
			if(!cnt[x])
			{
				a[x]=0;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i])
		{
			ans++;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1024
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    H, W, A, B = InputToInt()
    for i in range(H):
        for j in range(W):
            if (j < A) ^ (i < B):
                print('1', end = '')
            else:
                print('0', end = '')
        print('')


Measured memory_bytes: 5360
#include <bits/stdc++.h>
#define lowbit(x) ((x) & (-x))
#define Finline __inline__ __attribute__((always_inline))
#define DEBUG                                                                  \
    printf("Running on Line %d in Function %s\n", __LINE__, __FUNCTION__)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const ll INF = 0x7fffffffffffffff;
const double eps = 1e-8;

uint seed = 19260817;
const uint _RAND_MAX_ = 4294967295u;
Finline uint Rand() { return seed = seed * 998244353u + 1000000007u; }

template <typename T> T gcd(const T &a, const T &b) {
    return (!b) ? a : gcd(b, a % b);
}
template <typename T> Finline T abs(const T &a) { return a > 0 ? a : -a; }
template <typename T> Finline T mmax(const T &a, const T &b) {
    return a < b ? b : a;
}
template <typename T> Finline T mmin(const T &a, const T &b) {
    return a < b ? a : b;
}
template <typename T> Finline void chmax(T &a, const T &b) {
    (a < b) && (a = b);
}
template <typename T> Finline void chmin(T &a, const T &b) {
    (a > b) && (a = b);
}
template <typename T> Finline bool _cmp(const T &a, const T &b) {
    return abs(a - b) <= eps;
}
template <typename T> Finline void read(T &x) {
    register char ch(getchar());
    bool f(false);
    while (ch < 48 || ch > 57)
        f |= ch == 45, ch = getchar();
    x = ch & 15, ch = getchar();
    while (ch >= 48 && ch <= 57)
        x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
    if (f)
        x = -x;
}
template <typename T, typename... Args>
Finline void read(T &t, Args &... args) {
    read(t);
    read(args...);
}
Finline int read_str(char *s) {
    register char ch(getchar());
    while (ch == ' ' || ch == '\r' || ch == '\n')
        ch = getchar();
    register char *tar = s;
    *tar = ch, ch = getchar();
    while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
        *(++tar) = ch, ch = getchar();
    return tar - s + 1;
}

using namespace std;

int main(int argc, char **argv) {
    int n;
    read(n);
    n--;
    n /= 2;
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int D;
int c[26];
vector<int> s;


void input()
{
    scanf("%d", &D);
    s.resize(D * 26);
    int i, j;
    for (i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
#define P(i,j) ((i)*26+(j))
    for (i = 0; i < D; i++) {
        for (j = 0; j < 26; j++) {
            scanf("%d", &s[P(i, j)]);
        }
    }
    return;
}

void calc(const vector<int>& t, vector<int>& ans)
{
    vector<int> last(26,-1);
    int sum = 0;
    int i,k;
    for (i = 0; i < D; i++) {
        sum += s[P(i, t[i])];
        last[t[i]] = i;
        for (k = 0; k < 26; k++) {
            sum -= c[k] * (i - last[k]);
        }
        ans[i] = sum;
    }

    return;
}

void solve()
{
    input();

    vector<int> t(D);
    int i;
    for (i = 0; i < D; i++) {
        scanf("%d", &t[i]); t[i]--;
    }
    
    vector<int> ans0(D);
    calc(t, ans0);

    for (i = 0; i < D; i++) {
        printf("%d\n", ans0[i]);
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3240
/*
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>
*/

#include<bits/stdc++.h>

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18 + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	Fast;
	int n; cin >> n;
	priority_queue<double> pq;
	vi a(n);
	for (int& x : a) {
		cin >> x;
		pq.push(-x);
	}
	for (int i = 1; i <= n - 1; ++i) {
		double u, v;
		u = pq.top();
		pq.pop();
		v = pq.top();
		pq.pop();
		u = -u;
		v = -v;
		pq.push(-(u + v) / 2.00);
	}
	double x = -pq.top();
	pq.pop();
	printf("%.6lf", x);
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()


if N % 2 != 0:
    ans1 = 0
    tmp = [-1,-1] + [2]*((N-1)//2) + [-2]*((N-2)//2)
    for i,j in zip(sorted(tmp),A):
        ans1 += (i*j)
    
    ans2 = 0
    tmp = [1,1] + [2]*((N-2)//2) + [-2]*((N-1)//2)
    for i,j in zip(sorted(tmp),A):
        ans2 += (i*j)
    print(max(ans1,ans2))
else:
    ans = 0
    tmp = [-1,1] + [2]*((N-2)//2) + [-2]*((N-2)//2)
    for i,j in zip(sorted(tmp),A):
        ans += (i*j)
    print(ans)

Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, A, B;
  cin >> K >> A >> B;
  vector<int> vec(B-A+2);
  for (int i=1;i<B-A+2;i++){
    vec.at(i)=A+i-1;
  }
  for(int i=1;i<B-A+2;i++){
    if(vec.at(i)%K==0){
      cout << "OK" << endl;
      break;
    }
    if(i==B-A+1){
      cout << "NG" << endl;
    }
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int MAX_N = (1e+5)+1;
int par[MAX_N];//親
int pank[MAX_N];//木の深さ
 
//n要素で初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        pank[i]=0;
    }
}
 
//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
 
//xとyの属する集合を併合
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(pank[x]<pank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(pank[x]==pank[y])pank[x]++;
    }
}
 
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
int main(){
    int n,m;cin>>n>>m;
    init(n);
    rep(i,m){
        int x,y,z;cin>>x>>y>>z;x--;y--;
        unite(x,y);
    }
    int res=0;
    rep(i,n)if(find(i)==i)res++;
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int a[N],vis[N];
vector<int>e[N],g[N]; 
priority_queue<int>pq;
void dfs(int v)
{
	vis[v]=1;
	for(int i=0;i<e[v].size();i++)
	{
		int u=e[v][i];
		if(vis[u])
			continue;
		g[v].push_back(u);
		dfs(u);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)	
		for(int j=1;j<=n;j++)
			if(__gcd(a[i],a[j])>1)
				e[i].push_back(j);
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
			pq.push(i);
		}
	}
	while(!pq.empty())
	{
		int k=pq.top();
		pq.pop();
		printf("%d ",a[k]);
		for(int i=0;i<g[k].size();i++)
			pq.push(g[k][i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 16000
#include <cstdio>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int s[100] = {};
	int sum = 0;
	int min = 101;
	for (int i = 0; i < n; i++ )
	{
		scanf("%d", &s[i]);
		sum += s[i];
		if (s[i] < min && s[i] % 10 != 0)
		{
			min = s[i];
		}
	}
	if (sum % 10 != 0)
	{
		printf("%d\n", sum);
	}
	else
	{
		if (sum - min > 0 && min != 101)
		{
			printf("%d\n", sum -min);
		}
		else
		{
			printf("%d\n", 0);
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
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; }

using namespace std;

int main(void)
{
	int N; cin >> N;
	set<string> get;
	rep(i, 0, N) {
		string S; cin >> S;
		get.insert(S);
	}

	cout << get.size() << endl;

	return 0;
}


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


int main()
{
	double a, b, c, d;
	cin >> a >> b >> c >> d;
    
	printf("%lf\n", sqrt(pow(c - a, 2) + pow(d - b, 2)));
	return 0;
}



Measured memory_bytes: 3188
import java.math.BigDecimal;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner s = null;
		try {
			s = new Scanner(System.in);
			while (s.hasNextInt()) {
				BigDecimal a = s.nextBigDecimal();
				BigDecimal b = s.nextBigDecimal();
				BigDecimal c = s.nextBigDecimal();
				BigDecimal d = s.nextBigDecimal();
				BigDecimal e = s.nextBigDecimal();
				BigDecimal f = s.nextBigDecimal();

				BigDecimal y = ((c.multiply(d)).subtract((f.multiply(a))))
						.divide(((b.multiply(d)).subtract((e.multiply(a)))));
				BigDecimal x = (c.subtract(b.multiply(y))).divide(a);

				System.out.println(x.setScale(3, BigDecimal.ROUND_DOWN)
						.toPlainString()
						+ " "
						+ y.setScale(3, BigDecimal.ROUND_DOWN).toPlainString());
			}
		} finally {
			s.close();
		}
	}
}

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

int n;
int e[3][100000];

//dp[i][j]: j-1번째 놀이가 i일 때 이번에 확인할 것이 j 앞으로 얻을 수 있는 즐거움 최댓값
int dp[4][100001];

int solve(int i,int j){
	int& ret=dp[i][j];
	if(ret!=-1) return ret;
	if(j==n) return 0;
	ret=0;
	for(int k=0;k<3;k++){
		if(k!=i) ret=max(ret,solve(k,j+1)+e[k][j]);
	}
	return ret;
}

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		scanf("%d %d %d",&e[0][i],&e[1][i],&e[2][i]);
	}
	memset(dp, -1, sizeof(dp));
	cout<<solve(3,0);
	return 0;
}

Measured memory_bytes: 10752
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;

int N, M, Q;
vvi G;
vector<Edge> q;
vi col;
vb used;
vi painted;

void paint(int v, int d, int c) {
	queue<P> q;
	q.push(mp(v, d));
	while (!q.empty()) {
		int pos = q.front().first;
		int dist = q.front().second;
		q.pop();
		if (painted[pos] >= dist)continue;
		painted[pos] = dist;
		if (col[pos] == 0) {
			col[pos] = c;
		}
		used[pos] = true;

		rep(i, G[pos].size()) {
			int next = G[pos][i];
			if (used[next])continue;
			if (dist > 0) q.push(mp(next, dist - 1));
		}
	}
}

int main() {
	cin >> N >> M;
	G = vvi(N);
	col = vi(N, 0);
	painted = vi(N, -1);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cin >> Q;
	q = vector<Edge>(Q);
	rep(i, Q) {
		int v, d, c;
		cin >> v >> d >> c;
		v--;
		q.push_back(mp(v, mp(d, c)));
	}
	reverse(q.begin(), q.end());

	rep(i, Q) {
		used = vb(N, false);
		paint(q[i].first, q[i].second.first, q[i].second.second);
	}

	rep(i, N) {
		cout << col[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 10468
#A[i]の部分列P[i]に0が含まれない場合、P[i]にあるカードを最大限利用し、sum(P[i])//2組構成でき、あまりは一切持ち越されない。
#これより、先頭から0が現れるまで要素を加算していき、0が出たら2で割って切り捨て
#この解はコーナーケースなくできる

#sum(P[i])//2組は何らかの順序でgreedyに取れば必ず構成でき、そうすることでP[i]のどこか1つがsum(P[i])%2となる以外は全て0となる
#... 0 [ P[i] ] 0 [ P[i+1] ]...と構成するため、
#... 0 [(1/0) 0 0 ... (0/1)] 0 [p[i+1][0] p[i+1][1] ...]があまりを活用できそうな最良配置だが、
#P[i]のあまりがあったときのあまり1はどのように扱ってもP[i-1],P[i+1]に活用できることはないとわかる


N=int(input())
A=[int(input()) for _ in range(N)]
cnt=0
buf=0
#print(A)
"""
if N==1:
    print(A[0]//2)
else:
    for i in range(N-1):
        su=A[i]+A[i+1]
        cnt=cnt+su//2
        buf=(su//2)*2
        if buf>A[i]:
            A[i+1]=A[i+1]-(buf-A[i])
            A[i]=0
        else:
            A[i]=A[i]-buf
    #print(A,cnt)
    print(cnt)
"""
su=0
for i in range(N):
    if A[i]!=0:
        su=su+A[i]
    else:
        cnt=cnt+su//2
        su=0
cnt=cnt+su//2
print(cnt)


Measured memory_bytes: 49624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define REPV(i, v, n) for (int i=0,tmp=v;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)

using namespace std;

typedef unsigned char byte;

byte mask[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
#define tget(i) !!(t[(i)>>3]&mask[(i)&7])
#define tset(i, b) t[(i)>>3]=(b) ? (mask[(i)&7]|t[(i)>>3]) : ((~mask[(i)&7])&t[(i)>>3])
#define chr(i) (cs==sizeof(int)?((int*)s)[i]:((byte *)s)[i])
#define isLMS(i) (i>0 && tget(i) && !tget(i-1))

void getBuckets(byte *s, int *bkt, int n, int K, int cs, bool end=true){
  fill(bkt, bkt + K + 1, 0);
  REP(i,n)bkt[chr(i)]++;
  REPV(i, 0, K+1)tmp += bkt[i], bkt[i] = end ? tmp : tmp - bkt[i];
}

void induceSAl(byte *t, int *SA, byte *s, int *bkt, int n, int K, int cs, bool end=false){
  getBuckets(s, bkt, n, K, cs, end);
  REP(i,n)if(SA[i]>0 && !tget(SA[i]-1)) SA[ bkt[chr(SA[i]-1)]++ ] = SA[i]-1;
}

void induceSAs(byte *t, int *SA, byte *s, int *bkt, int n, int K, int cs, bool end=true){
  getBuckets(s, bkt, n, K, cs, end);
  DWN(i,n,0)if(SA[i]>0 && tget(SA[i]-1))SA[--bkt[chr(SA[i]-1)]] = SA[i]-1;
}

void SA_IS(byte *s, int *SA, int n, int K=128, int cs=1) {
  byte t[(n >> 3) + 1];
  int bkt[K + 1],n1=0,name=0;
  
  tset(n-2, 0), tset(n-1, 1);
  DWN(i,n-2,0)tset(i, (chr(i)<chr(i+1) || (chr(i)==chr(i+1) && tget(i+1))));
  getBuckets(s, bkt, n, K, cs);
  fill(SA, SA+n, -1);
  FOR(i,1,n)if(isLMS(i))SA[--bkt[chr(i)]] = i;

  induceSAl(t, SA, s, bkt, n, K, cs);
  induceSAs(t, SA, s, bkt, n, K, cs);
  
  REP(i,n)if(isLMS(SA[i]))SA[n1++] = SA[i];
  fill(SA + n1, SA + n, -1);

  REPV(i,-1,n1){
    int pos = SA[i], diff = false;
    for(int d = 0; d < n && !diff; d++){
      diff = chr(pos+d) != chr(tmp+d) || tget(pos+d) != tget(tmp+d);
      if(!diff && d && (isLMS(pos+d) || isLMS(tmp+d)))break;
    }
    if(diff)name++,tmp=pos;
    SA[ n1 + ((pos - (pos & 1)) >> 1) ] = name - 1;
  }
  int *s1 = SA + n - n1;
  for(int i=n-1,j=n-1;i>=n1;i--)if(SA[i]>=0)SA[j--]=SA[i];
  if(name < n1)SA_IS((byte*)s1, SA, n1, name - 1, sizeof(int));
  else REP(i,n1)SA[s1[i]]=i;
  
  getBuckets(s, bkt, n, K, cs);
  for(int i = 1, j = 0; i < n; i++)if(isLMS(i))s1[j++] = i;
  REP(i,n1)SA[i]=s1[SA[i]];
  fill(SA + n1, SA + n, -1);

  DWN(i,n1,0){
    int tmp = SA[i];
    SA[i] = -1, SA[--bkt[chr(tmp)]] = tmp;
  }
  induceSAl(t, SA, s, bkt, n, K, cs);
  induceSAs(t, SA, s, bkt, n, K, cs);
}

const int maxn = 1000001;
int n,sa[maxn];

bool contain(string S, int *sa, string T){
  int a = 0, b = S.length();
  while( b - a > 1 ){
    int c = (a + b ) / 2;
    if ( S.compare(sa[c], T.length(), T) < 0 ) a = c;
    else b = c;
  }
  return S.compare(sa[b], T.length(), T) == 0;
}

char a[maxn],b[maxn];

int main(void){
  int q;
  scanf("%s", a);
  string s = string(a);
  SA_IS((byte*) s.c_str(), sa, s.size()+1);

  scanf("%d", &q);
  while(q--){
    scanf("%s", b);
    if(contain(s, sa, string(b))) printf("1\n");
    else printf("0\n");
  }

  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
	    double r = Double.parseDouble(str);;
		System.out.printf("%6f %6f", r * r * Math.PI, r * 2 * Math.PI);
	}

}

Measured memory_bytes: 24656
s = int(input())

xl = int(s ** 0.5) + 1
if (xl - 1) * xl >= s:
  yl = xl - 1
  if (xl - 1) * (xl - 1) >= s:
    xl -= 1
else:
  yl = xl

diff = xl * yl - s
print(*[0, 0, xl, diff, 1, yl])

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

int main() {
    int N, K;
    std::cin >> N >> K;

    int p[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> p[i];
    }

    std::sort(p, p + N);

    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += p[i];
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(a*b);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}

}


Measured memory_bytes: 32684
import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    res=[]
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        res.append((i*j)%2019)
    print(min(res))
  else:
    print(0)
else:
  print(0)

Measured memory_bytes: 84576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll fact[3000];
ll choose(int n,int r){
	if(n-r<0||r<0)return 0;
	return fact[n]*invp(fact[n-r],MOD)%MOD*invp(fact[r],MOD)%MOD;
}

int main(){
	fact[0]=1;
	rep(i,1,2100)fact[i]=fact[i-1]*i%MOD;
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,1,k+1){
		printf("%lld\n",choose(n-k+1,i)*choose(k-1,i-1)%MOD);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll X, Y;
	cin >> X >> Y;
	int ans = 0;
	while (X <= Y)
	{
		X *= 2;
		ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
N, K = tuple(map(int, input().split()))

def make_link(M, s):
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            link[i].append(j)
            M += 1
            s -= 1
            if s == K:
                return M

max_link = (N - 1) * (N - 2) / 2
if K > max_link:
    print(-1)
else:
    link = {i: [] for i in range(1, N+1)}
    for i in range(2, N+1):
        link[1].append(i)
    M = N - 1
    if max_link == K:
        pass
    else:
        M = make_link(M, max_link)
    print(M)
    for i in range(1, N+1):
        for j in link[i]:
            print(i, j)

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
string s;
int main(){
  cin >> s;
  int ans=0;
  string sub = s.substr(roundup(s.size(),2),s.size()-roundup(s.size(),2));
  for (size_t i = 0; i < sub.size(); i++) {
    if(s[i] != sub[sub.size()-i-1])ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n ,k;

int main(){
    
    IN n >> k;

    P(n-k+1);
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        string s[n];
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        vector <vector<int>> dp(n,vector<int> (m,n+m+10));
        if(s[0][0]=='.')
            dp[0][0]=0;
        else
            dp[0][0]=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(j-1>=0&&s[i][j]=='#'&&s[i][j-1]=='.')
                    dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                else if(j-1>=0)
                    dp[i][j]=min(dp[i][j],dp[i][j-1]);
                if(i-1>=0&&s[i][j]=='#'&&s[i-1][j]=='.')
                    dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
                else if(i-1>=0)
                    dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }
        }
        cout<<dp[n-1][m-1]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 384
# import platform
# ver = platform.python_version_tuple()
# if int(ver[1]) < 5:
#     from fractions import gcd
# else:
#     from math import gcd

# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import permutations

# from functools import lru_cache
# @lru_cache(maxsize=1024)

def main():
    N = int(input())
    S = tuple(input() for _ in [0] * N)
    M = int(input())
    T = tuple(input() for _ in [0] * M)

    blue = dict()
    for s in S:
        blue[s] = blue.get(s, 0) + 1

    red = dict()
    for t in T:
        red[t] = red.get(t, 0) + 1

    ans = 0
    for k, v in blue.items():
        if k in red:
            ans = max(ans, v - red[k])
        else:
            ans = max(ans, v)
    print(ans)

main()


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

int main(){
    int H,W;
    while(cin >> H >> W && H){
        map<char,pair<int,int>> m;
        char c;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                cin >> c;
                m[c] = {i,j}; 
            }
        }
        string S;
        cin >> S;
        int ans = (int) S.size();
        int x = 1,y = 1;
        for(auto a:S){
            ans += abs(x-m[a].first)+abs(y-m[a].second);
            x = m[a].first; y = m[a].second;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];
    rep(i, n)
    {
        int MIN = INF, ans;
        rep(j, m)
        {
            int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (MIN > tmp)
                MIN = tmp, ans = j + 1;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, A, B; cin >> N >> A >> B;
  if ((B-A)%2==0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#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, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<pair<ll, ll>> v(2*n);
  for(int i=0;i<2*n;i+=2) {
    cin >> v[i].first >> v[i+1].first;
    v[i].second = i;
    v[i+1].second = i+1;
  }


  sort(ALL(v));
  int cnta = 0, cntb = 0;
  vector<bool> sel(n);
  ll su = 0;
  REP(i, n) {
    su += v[i].first;
    sel[v[i].second/2] = true;
    cnta += v[i].second % 2 == 0;
    cntb += v[i].second % 2;
  }

  int cnt = 0;
  REP(i, n) {
    cnt += sel[i];
  }

  if(cnta > 0 && cntb > 0 && cnt == n) {
    ll mi = LINF;
    if(v[n].second / 2 != v[n-1].second / 2) chmin(mi, v[n].first - v[n-1].first);
    if(v[n+1].second / 2 != v[n-1].second / 2) chmin(mi, v[n+1].first - v[n-1].first);
    if(v[n].second / 2 != v[n-2].second / 2) chmin(mi, v[n].first - v[n-2].first);
    cout << su + mi << endl;
  } else {
    cout << su << endl;
  }


}
























Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S;
  cin >> S;
  if(S[S.size()-1] == 's') cout << S + "es" << endl;
  else cout << S + "s" << endl;
}

Measured memory_bytes: 3640
S = STDIN.gets.chomp

while true
  if S[-5..-1] == "dream" || S[-5..-1] == "erase"
    S.slice!(-5..-1)
  elsif S[-7..-1] == "dreamer"
    S.slice!(-7..-1)
  elsif S[-6..-1] == "eraser"
    S.slice!(-6..-1)
  else
    puts "NO"
    break
  end

  if S == ""
    puts "YES"
    break
  end
end

Measured memory_bytes: 1916