akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[105];

int cnt[26];

int main() {
	int N = strlen(in), i, j, ans = 0;
	scanf("%d %s", &N, in);

	for (i = 0; i <= N; i++) {
		for (j = 0; j < 26; j++) cnt[j] = 0;
		for (j = 0; j < i; j++) cnt[in[j] - 'a'] |= 1;
		for (j = i; j < N; j++) cnt[in[j] - 'a'] |= 2;

		int c = 0;
		for (j = 0; j < 26; j++) if (cnt[j] == 3) c++;
		ans = max(ans, c);
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll m,a,b; cin >> m >> a >> b;
        if(!m && !a && !b) break;
        vl p(m); rep(i,m) cin >> p[i];
        sort(rall(p));
        ll mxid = 0;
        ll mx = 0;
        REP(i,a,b+1){
            if(mx <= p[i-1] - p[i]){
                mx = p[i-1] - p[i];
                mxid = i;
            }
        }
        cout << mxid << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    bool f = true;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 1)
        {
            if (s[i] == 'R')
            {
                f = false;
                break;
            }
        }
        else
        {
            if (s[i] == 'L')
            {
                f = false;
                break;
            }
        }
    }

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

    return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int n; cin >> n;
    int S[n];
    REP(i, n) {
        cin >> S[i];
    }

    int q; cin >> q;
    int T[q];
    REP(i, q) {
        cin >> T[i];
    }

    int cnt = 0;

    REP(i, q) {
        REP(j, n) {
            if(T[i] == S[j]) {
                ++cnt;
                break;
            }
        }
    }

    cout << cnt << endl;

}



Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>

int main() {
	char A[15], B[15], C[15];
	int lenA, lenB;
	scanf("%s %s %s", A, B, C);
	
	lenA = strlen(A);
	lenB = strlen(B);
	if (A[lenA-1] == B[0] && B[lenB-1] == C[0]) {
		printf("YES\n");
	}
	else {
		puts("NO");
	}
	

	return 0;
}

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

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

def comb(n,r):
    if r >= n:
        return 1
    return fact[n]*pow(fact[n-r], mod-2, mod)*pow(fact[r], mod-2, mod) % mod

n,m,k = LI()
ans = 0
fact = [1]*(max(n,m)+1)
for i in range(1,n):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

for i in range(k+1):
    ans += comb(n-1, i) * m * pow(m-1, n-i-1, mod)
    ans %= mod
print(ans)

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

using namespace std;

int cnt_s[26] = {0};
int cnt_t[26] = {0};

int main() {
    string s, t;   cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        cnt_s[s[i]-'a']++;
        cnt_t[t[i]-'a']++;
    }
    int l = s.length();
    sort(cnt_s, cnt_s + 26);
    sort(cnt_t, cnt_t + 26);

    for (int i = 0; i < 26; i++) {
        
        if (cnt_s[i] != cnt_t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 1020
V,E = map(int,input().split())
d =[[float('inf')]*V for _ in range(V)]
for i in range(V):
    d[i][i] = 0
for i in range(E):
    s,t,c = map(int,input().split())
    d[s][t] = c

for k in range(V):
    for i in range(V):
        for j in range(V):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

for i in range(V):
    if d[i][i] != 0: #負の閉路が存在するならこのような頂点が存在する
        print('NEGATIVE CYCLE')
        exit()

for i in range(V):
    for j in range(V):
        if d[i][j] == float('inf'):
            d[i][j] = 'INF'
    print(*d[i])


Measured memory_bytes: 6276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200005];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int cnt=0,las=0;
	for(int i=0;i<n;i++){
		if(a[i]==las+1) cnt++,las=a[i];
	}
	if(cnt!=0) printf("%d",n-cnt);
	else printf("-1");
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			k := n - i - j
			if k < 0 {
				break
			}

			if 10000*i+5000*j+1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化。最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大小が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

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

    int n,m;
    cin>>n>>m;
    int x,y,z;
    int cnt=0;
    UnionFind uni(n);
    for(int i=0;i<m;i++){
        cin>>x>>y>>z;
        x--,y--;
        uni.connect(x,y);
    }
    int used[n]={};
    for(int i=0;i<n;i++){
        if(!used[uni.root(i)]){
            cnt++;
            used[uni.root(i)]=true;
        }
    }
    cout<<cnt<<endl;

    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y,int MOD) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%MOD;
        }
        x = x*x%MOD;
        y/=2;
    }
    return res;
}
signed main() {
    int N; string X;
    cin >> N >> X;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(X[i] == '1') {
            cnt++;
        }
    }
    if(cnt == 0) {
        for(int i = 0; i < N; i++) {
            cout << 1 << endl;
        }
    }
    else if(cnt == 1) {
        for(int i = 0; i < N; i++) {
            if(X[i] == '1') {
                cout << 0 << endl;
            }
            else {
                if(X[N-1] == '1' || i+1 == N) {
                    cout << 2 << endl;
                }
                else {
                    cout << 1 << endl;
                }
            }
        }
    }
    else {
        vector<int>syuturyoku;
        int res = 0;
        int res2 = 0;
        int kake = 1;
        for(int i = N-1; i >= 0; i--) {
            if(X[i] == '1') {
                res+=kake;
                res%=(cnt-1);
                res2+=mod_pow(2,N-i-1,cnt+1);
                res2%=(cnt+1);
            }
            kake*=2;
            kake%=(cnt-1);
        }
        for(int i = N-1; i >= 0; i--) {
            int Y = 0,ans = 1;
            if(X[i] == '0') {
                Y = (res2+mod_pow(2,(N-i-1),cnt+1)+cnt+1)%(cnt+1);
            }
            else {
                Y = (res-mod_pow(2,(N-i-1),cnt-1)+cnt-1)%(cnt-1);
            }
            while(Y) {
                int cnt2 = 0;
                int Y2 = Y;
                while(Y2) {
                    if(Y2 & 1) {
                        cnt2++;
                    }
                    Y2>>=1;
                }
                Y%=cnt2;
                ans++;
            }
            syuturyoku.push_back(ans);
        }
        for(int i = N-1; i >= 0; i--) {
            cout << syuturyoku[i] << endl;
        }
    }
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int fj(int n)
{
    int cnt = 0;
    while(n)
    {
        cnt += n % 10;
        n /= 10;
    }
    return cnt;
}
int main()
{
    int n, a, b, cnt = 0;
    scanf("%d%d%d", &n, &a, &b);
    for(int i=1; i<=n; i++)
        if(fj(i) <= b && fj(i) >=a)
            cnt += i;
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long int n, m;
	cin >> n >> m;
	string a, b;
	cin >> a >> b;
	long long int t = n,w=m;
	if (t > w)swap(t, w);
	while (w%t) {
		long long int p = t;
		t = w%t;
		w = p;
	}

	long long int r = n*m / t;

	for (long long int i = 0; i < t; i++) {
		if (a[(n*i) / t] != b[(m*i) / t]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << r << endl;



	return 0;

}

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

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

int main(){
    int N,M;
    cin>>N>>M;
    rep(i,M){
        int A;
        cin>>A;
        N-=A;
    }
    if(N<0){
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<N<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
    float x1,y1,x2,y2,x3,y3,x,y,a,b,c;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x>>y)
    {
        a=((y-y2)*(x-x1)-(y-y1)*(x-x2))*((y3-y2)*(x3-x1)-(y3-y1)*(x3-x2));
        b=((y-y3)*(x-x2)-(y-y2)*(x-x3))*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3));
        c=((y-y3)*(x-x1)-(y-y1)*(x-x3))*((y2-y3)*(x2-x1)-(y2-y1)*(x2-x3));
        if(a>0&&b>0&&c>0)
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
}

Measured memory_bytes: 1192
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int count = std.nextInt();
        int challengeCount = std.nextInt();
        String text = std.next();
        List<String> directions = Arrays.asList(text.split(""));

        int unHappy = IntStream.range(0, directions.size())
                .reduce(0, (acc, index) -> {
                    if (index + 1 == directions.size()) {
                        return acc + 1;
                    }
                    String left = directions.get(index);
                    String right = directions.get(index + 1);
                    if (!left.equals(right)) {
                        return acc + 1;
                    } else {
                        return acc;
                    }
                });

        unHappy = (unHappy - 2 * challengeCount);
        if (unHappy <= 0) {
            unHappy = 1;
        }

        System.out.println(count - unHappy);
    }
}

Measured memory_bytes: 33384
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = in.next();
        }

        Map<String, Integer> count = new HashMap<>();
        for (String s1 : s) {
            count.put(s1, count.getOrDefault(s1, 0) + 1);
        }

        int max = count.values().stream().mapToInt(i -> i).max().orElse(0);
        List<String> ans = count.entrySet()
                .stream().filter(e -> e.getValue() == max)
                .map(e -> e.getKey())
                .sorted()
                .collect(Collectors.toList());
        for (String an : ans) {
            out.println(an);
        }
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        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: 65112
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>


using namespace std;

int main() {
	int a;
	cin >> a;
	if (a % 2 == 0) {
		cout << "0.5000000000000000000000000000000000" << endl;
	}
	else {
		double kisuua =(int) a / 2 + 1;
		cout << kisuua / a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;


int main(){

	vector<int> zeronum;
	zeronum.push_back(0);
	int count = 0;
	for(int i = 1; i <= 100000; i++){
		int tmp = i;
		while(tmp % 5 == 0){
			count++;
			tmp /= 5;
		}
		zeronum.push_back(count);
	}

	int n = 0;
	while(cin >> n && n != 0){
		cout << zeronum[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1716
#include <iostream>

using namespace std;

int main()
{
  int X,Y,Z,V,U ;
  cin >> X>> Y>>Z;
  V=X;
  X=Y;
  Y=V;
  U=X;
  X=Z;
  Z=U;
  cout <<X <<" "<<Y<<" "<<Z;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e12 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    map<string, ll> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(ALL(s));
        if(mp.count(s) > 0)mp[s]++;
        else mp[s] = 1;
    }

    ll ans = 0;
    all_map(itr, mp){
        ans += itr->second*(itr->second-1) /2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11372
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=256;

int n,k;
vvl dp,DP;

int main(){
	cin>>n>>k;
	dp=DP=vvl(n+1,vl(M));
	dp[0][0]=DP[0][0]=1;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		for(int j=0;j<n;j++) for(int l=0;l<M;l++) (DP[j+1][l^A]+=dp[j][l])%=mod;
		dp=DP;
	}
	ll res=0,f=1;
	for(int i=1;i<=n;i++){
		(f*=i)%=mod;
		(res+=f*dp[i][k])%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define mod 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll k,a,b; cin>>k>>a>>b;
  haha(i,a,b+1){
    if(i%k==0){
      cout<<"OK"; return;
    }
  }
  cout<<"NG"; 
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;
    map<pair<int, int>, int> counts;
    vector<int> dx = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
    vector<int> dy = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
    for (int n = 0; n != N; ++n){
        int a, b;
        cin >> a >> b;
        for (int i = 0; i != 9; ++i) {
            auto key = make_pair(a + dx[i], b + dy[i]);
            if (counts.count(key) > 0){
                counts[key] += 1;
            }else{
                counts[key] = 1;
            }
        }
    }
    vector<int> freq(10, 0);
    for (auto iii : counts){
        int a, b;
        tie(a, b) = iii.first;
        if (a > 1 and a < H and b > 1 and b < W) freq[iii.second] += 1;
    }
    int sum = accumulate(freq.begin(), freq.end(), 0);
    cout << (H - 2LL) * (W - 2LL) - sum << endl;
    for (int i = 1; i != 10; ++i) cout << freq[i] << endl;
    return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    switch(n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        default:
            cout << "bon";
            break;
    }
    cout <<  endl;
    return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<math.h>

int n;
float ax, ay, bx, by, cx, cy;

int main(void)
{
	double p, q, r;
	
	scanf( "%d", &n );
	
	while ( n-- ) {
		scanf( "%f %f %f %f %f %f", &ax, &ay, &bx, &by, &cx, &cy );
		
		p = ( (ay - cy) * (ay*ay - by*by + ax*ax - bx*bx) - (ay - by) * (ay*ay - cy*cy + ax*ax - cx*cx) ) / ( 2*(ay-cy)*(ax-bx)-2*(ay-by)*(ax-cx));
		q = ( (ax - cx) * (ax*ax - bx*bx + ay*ay - by*by) - (ax - bx) * (ax*ax - cx*cx + ay*ay - cy*cy) ) / ( 2*(ax-cx)*(ay-by)-2*(ax-bx)*(ay-cy));
		
		r = sqrt( pow( ax - p, 2 ) + pow( ay - q, 2 ) );
		
		printf( "%.3f %.3f %.3f\n", p, q, r );
	}
	
	return 0;
}

Measured memory_bytes: 660
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod = (int) 1e9 + 7;
	static ArrayList<Integer> gr[];
	static long ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	// static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();

		while (t-- > 0) {

			String s=sc.next();
			String t1=sc.next();
			if(s.length()==0 || s.length()>10) {
				out.append("No");
				continue;
			}
			boolean f=true;
			if(t1.length()-1!=s.length()) {
				out.append("No");continue;
			}
			for(int i=0;i<s.length();i++) {
				if(s.charAt(i)!=t1.charAt(i)) {
					f=false;
					break;
				}
			}
			if(!f) {
				out.append("No");
				
			}
			else out.append("Yes");
			
			
		}

		System.out.println(out);
	}
}


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

int main()
{
	string str;

	getline(cin, str);

	while (str[0] != '0') {
		int n = 0;

		for (unsigned int i = 0; i < str.size(); i++) 
			n += str[i] - '0';

		cout << n << endl;

		getline(cin, str);
	}

    return 0;
}

Measured memory_bytes: 3148
// oh yea mr krabs
// REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second

const int maxn = 610 ;
const long long mod = 1e9+7 ;

int n, m ;

vector<int> adj[maxn] ;
bool mark[maxn][maxn] ;
pair<long long, long long> e[maxn*maxn] ;
long double ans ;
long double dp[maxn] ;

void bigupdate(){

    for(int u = n-2; u >= 0; u--){
        dp[u] = 0 ;
        int cnt = 0 ;
        for(auto v:adj[u]){
            if(!mark[u][v]){
                cnt++ ;
                dp[u] += dp[v]+1 ;
                if(v!=n-1 && dp[v]==0){
                    dp[u] = 0 ;
                    break ;
                }
            }
        }
        dp[u] /= cnt ;
    }
}

void solve(int u){

    if(u == n-1)
        return ;
    if(adj[u].size()==1){

        solve(adj[u][0]) ;
        return ;

    }
    long double S = 0 ;
    int SI = 0 ;
    for(auto v:adj[u]){
        if(dp[v] > S){
            SI = v ;
            S = dp[v] ;
        }
    }
    mark[u][SI] = 1 ;
    bigupdate() ;
    mark[u][SI] = 0 ;

}

int main(){

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

    cin >> n >> m ;

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

        int u, v ;
        cin >> u >> v ;
        u-- ;
        v-- ;
        adj[u].push_back(v) ;

    }
    bigupdate() ;
    ans = dp[0] ;

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

        solve(i) ;
        ans = min(ans, dp[0]) ;

    }

    cout << fixed << setprecision(15) << ans ;

}


Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
 
 
/**
 * Lesson4D???n  ????????´??° a i (i=1,2,...n) ?????\?????????????????????????°????????????§??????????¨????????±???????????????°??????
 * @author ?????¶??????
 * @version 2014/12/1
 */
class Main {
 
    // ????????°???????????¨?????????????????????
    public static void main(String[] args) {
 
        //??\?????? ????????? 2???????????±?????°
        int intNum = 0;
 
        //????°????
        int intMin = 0;
 
        //?????§???
        int intMax = 0;
 
        //????¨?
        double dbSum = 0;
 
 
        try{
            //??????????????????????????\?????????
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
            //??????????????????????????\??????String?????§?????????????????????
            String strLine = br.readLine();
 
            //??\?????? ????????????2???????????±?????°
            intNum = Integer.parseInt(strLine);
 
            //??????????????????????????\??????String?????§????????????
            strLine = br.readLine();
 
            //??????????????????:??\?????????" "??§?????????
            //?????????????????????strLineAry[0]??¨strLineAry[1]??¨strLineAry[2]??????????????????
            String[] strLineAry = strLine.split(" ");
 
            //1???????????????????°?????????\????????????
            intMin = Integer.parseInt(strLineAry[0]);
 
            //?????§?????????????°???????????????\????????????
            intMax = intMin;
 
            //?????°???????????????????????????
            dbSum += (double)intMin;
 
            //2????????\???
            for(int i = 1; i < intNum; i++) {
 
                int intNum2 = Integer.parseInt(strLineAry[i]);
 
                //????°???????????°?????????????
                if(intNum2 < intMin) {
 
                    //?????????????°?????????????
                    intMin = intNum2;
                }
 
                //?????§???????????§????????????
                if(intMax < intNum2) {
 
                    //??????????????§????????????
                    intMax = intNum2;
                }
 
                //?????°???????????????????????????
                dbSum += (double)intNum2;
            }
 
            //?°???°5????????§
            DecimalFormat insDF = new DecimalFormat("0");
 
            //??????
            System.out.println(intMin + " " + intMax + " " + insDF.format(dbSum));
 
            //????????????
        }catch(IOException e) {
 
            //??????????????????
            System.out.println(e);
 
        }catch(NumberFormatException e) {
 
            //??°?????\????????\????????§??????
            System.out.println("??°?????§??\??????????????????");
        }
    }
}

Measured memory_bytes: 29748
#include <bits/stdc++.h>
using namespace std;
 
const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}
 
int main(){
    int N, K;
    cin >> N >> K;
 
    // Aには全部入れて、Apos, Anegはそれぞれ正と負の値のみ入れる。全て絶対値で管理。
    vector<int64_t> A, Apos, Aneg;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(abs(a));
        if(a > 0) Apos.push_back(a);
        if(a < 0) Aneg.push_back(abs(a));
    }
    int szp = Apos.size(), szn = Aneg.size();
 
    int64_t ans = 1;
 
    if(szp + szn/2*2 >= K && (K%2 == 0 || szp > 0)){
        // 正にできる場合：絶対値を大きくしたい
        sort(Apos.rbegin(), Apos.rend());
        sort(Aneg.rbegin(), Aneg.rend());
        // Kが奇数ならまず正側の最大値を1個使う
        if(K%2) ans = Apos[0];
        // 正負それぞれで絶対値の大きいものから2個ずつペアにして、大きいものから使う
        vector<int64_t> V;
        for(int i=K%2; i+1<szp; i+=2) V.push_back(Apos[i]*Apos[i+1]);
        for(int i=0; i+1<szn; i+=2) V.push_back(Aneg[i]*Aneg[i+1]);
        sort(V.rbegin(), V.rend());
        for(int i=0; i<K/2; i++) mul(ans, V[i] % MOD);
    }else{
        // 正にできない場合：絶対値を小さくしたい
        // 全部混ぜて絶対値の小さいものから使う
        sort(A.begin(), A.end());
        for(int i=0; i<K; i++) mul(ans, A[i]);
        ans = (MOD-ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int n;cin >> n;
    vector<int> t(n),v(n);
    rep(i,n){
        cin >> t[i];
        t[i]*=2;
    }
    rep(i,n)cin >> v[i];
    rep(i,n-1)t[i+1]+=t[i];
    
    int t_max = t[n-1];
    vector<double> v1(t_max+1,0.0),v2(t_max+1,0.0);
    int now=0;
    rep(i,t_max){
        if(t[now]==i)now++;
        v1[i+1]=min((double)v[now],v1[i]+0.5);
    }
    for(int i=t_max;i>0;i--){
        if(t[now-1]==i)now--;
        v2[i-1]=min((double)v[now],v2[i]+0.5);
    }

    double res = 0;
    rep(i,t_max+1)res+=min(v1[i],v2[i]);
    cout << fixed << setprecision(5) << res/2 <<endl;
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N > 0 && M > 0 && N + M >= 2) {
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl; ;
  }
  else if (N >= 2 && M == 0) {
    cout << N * (N - 1) / 2 << endl;
  }
  else if (N == 0 && M >= 2) {
    cout << M * (M - 1) / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}
    

Measured memory_bytes: 256
from operator import itemgetter
n,m=map(int,input().split())
a=[]
for i in range(m):
    pi,yi=map(int,input().split())
    a.append([i,pi,yi])
b=[]
c=[]
for i in range(n):
    b.append([])
    c.append([])
for i in range(m):
    x=a[i][0]
    y=a[i][2]
    b[a[i][1]-1].append([x,y])

for i in range(n):
    b[i].sort(key=itemgetter(1))
    l=len(b[i])
    for j in range(l):
        a[b[i][j][0]].append(j+1)
for i in range(m):
    xi=a[i][1]
    yi=a[i][3]
    print('{0:06d}{1:06d}'.format(xi,yi))



Measured memory_bytes: 56068
#include<bits/stdc++.h>
#define ll  long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define f(i,n)   for(int i=0;i<n;i++)

using namespace std;
/************************BELIAL**********DEVIL*********BELIAL***********DEVIL*************************/
int main()
{

	int n, w;

	cin >> n >> w;
	ll wt[n], val[n];
	f(i, n)
	{
         cin>>wt[i]>>val[i];


	}
ll dp[n+1][w+1];
memset(dp,0,sizeof(dp));

for(int i=1;i<=n;i++)
{
		for(int j=1;j<=w;j++)
		{
              dp[i][j]=dp[i-1][j];
              if(j>=wt[i-1])
              dp[i][j]=max(dp[i][j],dp[i-1][j-wt[i-1]]+ val[i-1]);


		}


}

   cout<<dp[n][w];


}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        int total = 0;
        
		for (int i = 0; i < s.length(); i++) {
			for ( int j = i + 1; j < s.length(); j++) {
				if (s.charAt(i) == s.charAt(j)) {
					total++;
				}
			}
		}
		
		System.out.println(total == 2 ? "Yes" : "No");
	}
}

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

int main(){
  	int K;
    string S;
  	string T;
    cin >> K; 
    cin >> S;
  	if(S.size() <= K){
    	cout << S << endl;
    }else{
      	T = S.substr(0,K);
      	cout << T << "..." << endl;
    }
    
}

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

using namespace std;


int main(){
int k; cin >> k;
int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << v[k-1];
return 0;
}


Measured memory_bytes: 256
#include <stack>
using namespace std;

struct Rectangle {
  int height;
  int pos;
};
 

#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ+1];
int st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	r=0;
/*
	for(i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		//printf("%d %d %d %d\n",i,j,ptr,m[j][i]);
		if(!ptr || st[ptr-1]<m[j][i])st[ptr++]=m[j][i];
		else{
			for(;ptr && st[ptr-1]>m[j][i];){
				int _y=(j-(ptr-1)),_x=st[--ptr];
				//printf("%d %d\n",_x,_y);
				if(r<_x*_y)r=_x*_y;
			}
			st[ptr++]=m[j][i];
		}
	}
*/
  Rectangle rect;
  for (int i = 0; i < x; i++) {
    stack<Rectangle> stk;
    for (int j = 0; j <= y; j++) {
      rect.height = m[j][i];
      rect.pos = j;
      if (stk.empty()) {
        stk.push(rect);
      } else {
        if (stk.top().height < rect.height) {
          stk.push(rect);
        } else if (stk.top().height > rect.height) {
          int target = j;
          while (!stk.empty() && stk.top().height >= rect.height) {
            Rectangle pre = stk.top(); stk.pop();
            int area = pre.height * (j - pre.pos);
            r = max(r, area);
            target = pre.pos;
          }
          rect.pos = target;
          stk.push(rect);
        }
      }
    }
  }

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

Measured memory_bytes: 14312
#include <iostream>
using namespace std;
int main(void){
    
    //変数の宣言
    int a, b, c;
    
    //h変数の入力
    cin >> a >> b >> c;
    
    //if：条件を与え判定する➡　判定は成立する or 成立しない
    if(a < b && b < c) {
        cout << "Yes" << endl;
    }
    //else：if文が成立しないとき条件
    else {
        cout << "No" << endl;
    }
    
    return 0;
    
}


/*******************if文とは************************

if(条件式){
    条件が成立するとき通過できる所
}
else {
    条件を成立してない所が通過できる所
}


※条件式とは
    不等号を使用する
        ・AよりBの方が大きい　➡　A < B
        ・AよりBの方が小さい　➡　A > B
        ・AよりBの方がi以上　➡　A <= B
        ・AよりBの方がi以下　➡　A >= B
        ・AとBは等しい　➡　A == B 
        ・AとBは等しくない　➡　A != B
        ・A以外の値　➡　!A
        
    
********************************************************/


















Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
main()
{
    string s;
    int l,N,x=0;
    int m=x;
    cin>>N>>s;
    for(int i=0;i<N;i++)
    {
        if(s[i]=='I')
            x++;
        else if(s[i]=='D')
            x--;
        if(x>m)
            m=x;
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict, deque

K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

minDist = K + A[0] - A[-1]
for x, y in zip(A, A[1:]):
    minDist = max(minDist, y - x)
print(K - minDist)


Measured memory_bytes: 25300
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=5e5+1;
 
typedef long long ll;
typedef long double ld;

ll blocksize = 2000, n, m, ans = 0;
ll a[N];
ll cont[N];

void remove(ll ind)
{
	if(cont[a[ind]] == 1)
		ans--;
    cont[a[ind]]--;
}
void add(ll ind)
{
    cont[a[ind]]++;
    if(cont[a[ind]] == 1)
		ans++;
}
ll getanswer()
{
    return ans;
}
struct Query
{
    ll l, r, ind;
    bool operator<(Query other) const
    {
        return make_pair(l/blocksize, r)<make_pair(other.l/blocksize, other.r);
    }
};

vector<ll> mosalgo(vector<Query> queries)
{
    vector<ll> answer(queries.size());
    sort(all(queries));
    ll curl=0, curr=-1;
    for(Query q : queries)
    {
        while(curl>q.l)
        {
            curl--;
            add(curl);
        }
        while(curr<q.r)
        {
            curr++;
            add(curr);
        }
        while(curl<q.l)
        {
            remove(curl);
            curl++;
        }
        while(curr>q.r)
        {
            remove(curr);
            curr--;
        }
        answer[q.ind]=getanswer();
    }
    return answer;
}

void test_case()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<Query> v;
    for(int i = 0; i < m; i++)
    {
        ll x,y;
        cin >> x >> y;
        x--;y--;
        v.pu({x,y,i});
    }
    vector<ll> res = mosalgo(v);
    for(int i = 0; i < m; i++)
        cout<<res[i]<<'\n';

}

int main()
{
    IOS();
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

const int N = 15, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if (a < 0)
		a += MOD;
	else if (a >= MOD)
		a -= MOD;
	return a;
}
void _sum(int &a, int b) {
	a = sum(a, b);
}
int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
void _mul(int &a, int b) {
	a = mul(a, b);
}

int count(int x) {
	return __builtin_popcount(x);
}

int n, m, nei[N], dp[1 << N];
int ans = 1;

void input() {
	cin >> n >> m;
	while (m--) {
		int x, y;
		cin >> x >> y;
		nei[--x] |= 1 << (--y);
		_mul(ans, 2);
	}
}

int f(int big, int small) {
	int res = 1;
	for (int i = 0; i < n; i++)
		if (big >> i & 1)
			_mul(res, (1 << count(nei[i] & small)) - 1);
		else if (small >> i & 1)
			_mul(res, 1 << count(nei[i] & big));
	return res;
}

bool ok(int mask) {
	return (mask & 1) == (mask >> 1 & 1);
}

void calc() {
	dp[0] = 1;
	for (int mask = 1; mask < (1 << n); mask++)
		if (ok(mask))
			for (int sub = mask; sub; sub = --sub & mask)
				if (ok(sub) && ok(mask ^ sub))
					_sum(dp[mask], mul(dp[mask ^ sub], f(mask ^ sub, sub)));
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	calc();
	cout << sum(ans, -dp[(1 << n) - 1]);
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const ll MOD = 1e9 + 7;
const int N = 201000;

ll a[N], b[N], fac[N], inv[N];
int f[4010][4010], n;

ll C(int u, int v)
{
    return fac[u + v] * inv[u] % MOD * inv[v] % MOD;
}

int main()
{
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= 100000; i++) inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    for (int i = 1; i <= 100000; i++) inv[i] = inv[i - 1] * inv[i] % MOD;
    fac[0] = 1;
    for (int i = 1; i <= 100000; i++) fac[i] = fac[i - 1] * i % MOD;
    n = read();
    for (int i = 1; i <= n; i++)
    {
        a[i] = read(), b[i] = read();
        f[2000 - a[i]][2000 - b[i]]++;
    }
    for (int i = 0; i <= 4000; i++)
        for (int j = 0; j <= 4000; j++)
        {
            (f[i + 1][j] += f[i][j]) %= MOD;
            (f[i][j + 1] += f[i][j]) %= MOD;
        }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        (ans += f[2000 + a[i]][2000 + b[i]]) %= MOD;
    for (int i = 1; i <= n; i++)
        ans = (ans - C(a[i] + a[i], b[i] + b[i]) + MOD) % MOD;
    ans = ans * inv[2] % MOD;
    printf("%lld\n", ans);
}


Measured memory_bytes: 69376
///***###                               بسم الله الرحمن الرحيم                            ###***///


/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 27 June,2020;
*/


///************************Start Of Template*************************///


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
using namespace std;
using ll=long long;
const int N=2e5+5;
string str,ans,rafi,chk;

map<string,string>maap;
queue<int>q;

/*** this solution will not work in terminal because of freopen................
    If you close that freopen then its work here.
    But before submission you need to open freopen line ***/

     //////return sum of all digits///////

int arr[10000004];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    Read_Fast;
    int t;
    // cin>>t;
    //  while(t--)
    //  {
    ll n,m,i,j,cnt1=0,cnt2=0,cnt=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
    ll a=0,b=0,c=0,d,ans=0,zero=0,fst=0,snd=0,lst=0,one=0,mn=INT_MAX,mx=INT_MIN;
    char ch;
    int h1,h2,m1,m2,h,time;
    string str,store="";
    cin>>n;
   // map<ll,ll>arr;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j=j+i)
        {
            arr[j]++;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        sum=sum+(i*arr[i]);
    }
    cout<<sum<<endl;

    // }
    return 0;
///***###            ٱلْحَمْدُ لِلَّٰهِ          ###***///
}



Measured memory_bytes: 42668
#79-C:DFS

def dfs(i,f,f_sum):
    if i==3:
        if f_sum==7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1,f+'+'+s[i+1],f_sum+int(s[i+1]))
        dfs(i+1,f+'-'+s[i+1],f_sum-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))

Measured memory_bytes: 3060
from math import gcd
A, B, C, D = map(int,input().split())

lcm = C*D // gcd(C,D)
a = (A-1)//C + (A-1)//D - (A-1)//lcm
b = B//C + B//D - B//lcm

print(B-A+1-b+a)

Measured memory_bytes: 9076
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    int n;
    cin>>n;
    int index = 0;
    while(index < n){
        string s;
        cin>>s;
        int len = s.length();
        set<string>st;
        for(int i = 0;i<len-1;i++){
            string pre = s.substr(0,i+1);
            string suf = s.substr(i+1,len - i - 1);
            string prerev ="";
            string sufrev ="";
            string ans = "";
            for(int id1 = 0;id1<2;id1++){
                for(int id2 = 0;id2 < 2;id2++){
                    for(int id3 = 0;id3<2;id3++){
                        prerev = pre;
                        sufrev = suf;
                        if(id1 == 1)reverse(prerev.begin(),prerev.end());
                        if(id2 == 1)reverse(sufrev.begin(),sufrev.end());
                        
                        if(id3 == 0){
                            st.insert(prerev+sufrev);
                        }
                        else{
                            st.insert(sufrev+prerev);
                        }
                    }
                }
            }
        }
        cout<<st.size()<<endl;
        index++;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<pair<int, int>> v;
    rep(i, 0, n)
    {
        ll a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    sort(begin(v), end(v));
    ll index = 0, res;
    rep(i, 0, n)
    {
        index += v[i].second;
        if (index >= k)
        {
            res = v[i].first;
            break;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1400
N = int(input())
S = input()
# ord()もchr()も一文字の変換を想定しているから空文字をfor文で結合
# 元の文字コードポイントにN加えた整数を26で割った余りを、'A'のコードポイントに足し合わせる
print(''.join(chr((ord(c) - ord('A') + N) % 26 + ord('A')) for c in S))

Measured memory_bytes: 3060