akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
    }

    int cnt  = -1;
    int cnt2 = -1;
    FOR(i, 1, N) {
        if (0 <= cnt && a[i - 1] > a[i]) {
            cnt2 = i;
            break;
        }
        if (cnt == -1 && a[i - 1] > a[i]) {
            cnt = i - 1;
        }
    }
    if (0 <= cnt && 0 <= cnt2)
        swap(a[cnt], a[cnt2]);
    FOR(i, 1, N) {
        if (a[i] < a[i - 1]) {
            print("NO");
            return 0;
        }
    }
    print("YES");

    return 0;
}

Measured memory_bytes: 256
N ,A, B, C = [int(i) for i in input().split()]
L = []
for _ in range(N):
    L.append(int(input()))
minMP = 100000
for Ai in range(2**N):
    bin_Ai = format(Ai, "08b")
    bin_Ai = list(bin_Ai)
    bin_Ai.reverse()
    bambooA = []
    bambooBC = []
    for ni in range(N):
        if bin_Ai[ni] == "1":
            bambooA.append(L[ni])
        else:
            bambooBC.append(L[ni])
    if bambooA == []:
        continue
    k = len(bambooBC)
    for Bi in range(2**k):
        bin_Bi = format(Bi,"08b")
        bin_Bi = list(bin_Bi)
        bin_Bi.reverse()
        bambooB = []
        bambooCD = []
        for ki in range(k):
            if bin_Bi[ki] == "1":
                bambooB.append(bambooBC[ki])
            else:
                bambooCD.append(bambooBC[ki])
        if bambooB == []:
            continue
        m = len(bambooCD)
        for Ci in range(2**m):
            bin_Ci = format(Ci, "08b")
            bin_Ci = list(bin_Ci)
            bin_Ci.reverse()
            bambooC = []
            for mi in range(m):
                if bin_Ci[mi] == "1":
                    bambooC.append(bambooCD[mi])
            if bambooC == []:
                continue
            MP = 10*(len(bambooA)-1)+abs(sum(bambooA)-A)+10*(len(bambooB)-1)+abs(sum(bambooB)-B)+10*(len(bambooC)-1)+abs(sum(bambooC)-C)
            if MP < minMP:
                minMP = MP
print(minMP)


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	char a[1001],b[1001];
	long least,var,lena=0,lenb=0,l=1;
	cin>>a>>b;                       
	for(;b[lenb];lenb++);                  
	for(;a[lena];lena++);                
	for(int i=0;i<=lena-lenb;i++){
		var=0;
		for(int j=0;j<lenb;j++){                 
			if(a[i+j]!=b[j]){              
				var++;
			}
		}
		                                   
		if(var<least||l)least=var;
		if(l)l=0;

		
	}
	cout<<least;
	return 0;
}

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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int n, k;
string s;
//ll a[maxn];

//check T
void solve()
{
  //cin >> n; rep(i, 0, n) cin >> a[i];
  cin >> n >> k;
  k--;
  cin >> s;
  s[k] = s[k] + ('a'-'A');
  cout << s << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  rep(tc, 1, T+1)
  {
    //cout << "Case #" << tc << ": ";
    solve();
  }
  return 0;
}


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

const int MAXN = 100010;

int a[MAXN];

int main(){
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + N);
	for (int i = 1, s; i <= N; ++i){
		if (a[i] >= N - i + 1){
			if (a[i] == a[i - 1]) 
				s ^= 1;
			else if (a[i - 1] == N - i + 1) 
				s = 1 ^ (s && !((a[i] - (N - i + 1)) & 1));
			else 
				s = (a[i] - (N - i + 1)) & 1;
			if (s) printf("First");
			else printf("Second");
			break;
		}
		if (a[i] != a[i - 1])
			s = 0;
		else
			s ^= 1;
	}
	return 0;
}


Measured memory_bytes: 512
import java.math.BigDecimal
import java.math.MathContext

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c = sc.nextLong()
    val abd = new BigDecimal(a)
    val bbd = new BigDecimal(b)
    val cbd = new BigDecimal(c)

    if(sqrt(abd, 50).add(sqrt(bbd, 50)).compareTo(sqrt(cbd, 50)) < 0) {
      println("Yes")
    }else {
      println("No")
    }
  }


  def sqrt(a: BigDecimal, scale: Int): BigDecimal = {
    var x = new BigDecimal(Math.sqrt(a.doubleValue), MathContext.DECIMAL64)
    if (scale < 17) return x
    val b2 = new BigDecimal(2)
    var tempScale = 16
    while ( {
      tempScale < scale
    }) {
      x = x.subtract(x.multiply(x).subtract(a).divide(x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN))

      tempScale *= 2
    }
    x
  }
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 2019;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0) { ll pow=power(x,y/2); return (pow*pow)%MOD; } 
	else { ll pow=power(x,y/2); return ((pow*pow)%MOD)*x%MOD; }
}

int main() {
	string s; cin >> s;
	reverse(ALL(s));
	int n=s.size();
	VI p(2019,0); p[0]++;
	ll k=0;
	REP(i,n){
		k+=power(10,i)*(s[i]-'0');
		k%=2019;
		p[k]++;
	}
	ll ans=0;
	REP(i,2019){
		ans+=(p[i]*(p[i]-1))/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c<=0){
      cout << "Yes" << "\n";
      return 0;
    }
    a -= d;
    if(a<=0){
      cout << "No" << "\n";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int a=0,b=0,c=0;
	int l,r;
	int N;
	int temp;
	int ans;
	scanf("%d",&N);
	scanf("%d%d",&l,&r);
	while(N--){
		scanf("%d",&temp);
		if(temp<=l){
			a++;
		}else if(temp>=r+1){
			c++;
		}else{
			b++;
		}
	}
	ans=min(a,b);
	ans=min(ans,c);
	printf("%d",ans);
	return 0;
}

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

using namespace std;

int main() {
	int N, K, M;
	cin>>N>>M;
	int p;
	string result;
	int correct = 0;
	int penalties = 0;
	int prev = -1;
	vector<bool> AC(N);
	vector<int> WC(N);
	for (int i = 0;i < M;++i) {
		cin>>p>>result;
		if (AC[p]) {
			continue;
		}

		if (result == "AC") {
			correct += 1;
			penalties += WC[p];
			AC[p] = true;
		}
		else {
			WC[p] += 1;
		}

	}
		
	cout<<correct<<" "<<penalties<<endl;
	return 0;
}


Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):  # 1-index
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):  # 1-index
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    """
    # 使用例
    bit = BinaryIndexedTree(10)     # 要素数を与えてインスタンス化
    bit.add(2, 10)    # a2に10を加える
    bit.add(3, -6)    # a3に-6を加える
    print(bit.sum(6)) # a1～a6の合計を返す
    print(bit.sum(6) - bit.sum(3))  # a4～a6の合計を返す
    """

s = S()
n = len(s)
s_index = defaultdict(list)
for i, x in enumerate(s):
    s_index[x].append(i)

T = [0]*n  # sでi番目の文字は、最終的な回文でT[i]番目の文字となる
flag = False  # 奇数個の文字が前にあったかフラグ(奇数個の文字が2つ以上あってはならない)
AC = []  # 最終的な回文での前半Aと後半Cのペア
for x, index_list in s_index.items():
    count = len(index_list)
    if count % 2 == 1:
        if flag:
            print(-1)
            exit()
        else:
            flag = True
            mid = index_list[count//2]
            T[mid] = n//2  # 回文の中心(B)
    for i in range(count//2):
        a = index_list[i]
        c = index_list[-i-1]
        AC.append((a, c))

AC.sort(key=itemgetter(0))  # 前半(a)の順番でソート
for i, (a, c) in enumerate(AC):
    T[a] = i  # a == i
    T[c] = n - i - 1

BIT = BinaryIndexedTree(n)
inversion = 0
for i, t in enumerate(T):
    i += 1  # 1-indexに変換
    t += 1  # 1-indexに変換
    BIT.add(t, 1)
    inversion += i - BIT.sum(t)
print(inversion)

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

int k, size;
// 0-9
int num[1001];
// dp[ 決めた桁数 ][ 未満フラグ ][ 0以外(1-9)==K個 ] :[size][0-1][K] 総数
// 未満フラグ == 0 : ちょうどその数の時。今回は以下なので含む、未満の時は含まない。
int64_t dp[1001][2][4];

void add(int i, bool smaller, int current_k, int x)
{
  int64_t now = dp[i][smaller][current_k];
  if (now == 0)
    return ;

  if (x < num[i])
    smaller = true;

  if (x != 0)
    current_k++;

  if (current_k > k)
    return ;

  dp[i + 1][smaller][current_k] += now;
  return ;
}

void loop(int i, bool smaller, int current_k)
{
  int max;
  if (smaller)
    max = 9;
  else
    max = num[i];

  rep(x, max + 1)
      add(i, smaller, current_k, x);
}

int main()
{
  string s;
  cin >> s >> k;
  size = s.size();

  rep(i, size)
      num[i] = s[i] - '0';

  dp[0][0][0] = 1;
  rep(i, size)
      rep(smaller, 2)
          rep(kk, k + 1)
              loop(i, smaller, kk);
  int64_t cnt = dp[size][0][k] + dp[size][1][k];
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

bool is_even(string s)
{
  int n = s.length();
  // 奇数長はだめ
  if (n % 2 == 1) return false;
  // 違う文字があった時点で、false
  for (int i = 0, j = n/2; j < n; ++i, ++j) {
    if (s[i] != s[j]) return false;
  }
  return true;
}

int main()
{
  string S;
  cin >> S;
  int i = S.length() - 1;
  for (; i >= 0; --i) {
    string t = S.substr(0, i);
    if (is_even(t)) break;
  }

  cout << i << endl;
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;



void solve()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> f(n);

	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for(int i = 0; i < n; ++i)
	{
		cin >> f[i];
	}

	sort(a.begin(), a.end());
	sort(f.begin(), f.end(), greater<int>());

	ll le = -1, re = 1000000000000LL;
	while(re - le > 1)
	{
		ll mid = (le + re) / 2;
		{
			ll tmp_k = 0;
			for(int i = 0; i < n; ++i)
			{
				if (a[i] * f[i] > mid)
				{
					tmp_k += (a[i] * f[i] - mid - 1) / f[i] + 1;
				}
			}
			if (tmp_k <= k) re = mid;
			else le = mid;
		}
	}
	cout << re;


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N;
    cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    ll rem = N, sgn = -1; 
    string ans;
    while(rem != 0){
        //cout << rem << endl;
        if(rem % 2 == 0){
            ans += "0";
        }else{
            ans += "1";
            if(sgn == -1)rem += -1;
        }
        rem = rem / 2 * -1;
        //digit *= -2;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 3005;
int memo[N][N];

string x, y;

int solve(int i, int j)
{
	if (i == sz(x) || j == sz(y))
		return 0;

	int &ret = memo[i][j];

	if (~ret)
		return ret;

	ret = max(solve(i + 1, j), solve(i, j + 1));

	if (x[i] == y[j])
		ret = max(ret, 1 + solve(i + 1, j + 1));

	return ret;
}

void build(int i, int j)
{
	if (i == sz(x) || j == sz(y))
		return;

	int &ret = memo[i][j];

	if (x[i] == y[j] && ret == 1 + solve(i + 1, j + 1))
	{
		cout << x[i];
		build(i + 1, j + 1);
	}
	else if (ret == solve(i + 1, j))
		build(i + 1, j);
	else
		build(i, j + 1);
}

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

	cin >> x >> y;
	reset(memo, -1);
	solve(0, 0);
	build(0, 0);

	return 0;
}


Measured memory_bytes: 35968
def examA():
    T, X = LI()
    ans = T/X
    print(ans)
    return

def examB():
    N = I()
    L = LI()
    ans = "Yes"
    if max(L)*2>=sum(L):
        ans = "No"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int gcd(int x, int y) { return x ? gcd(y % x, x) : y; }

// 3
// 12 15 18

int main() {
  int n;
  scanf("%d", &n);

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  vector<int> l(n);
  l[0] = a[0];
  for (int i = 1; i < n; i++) {
    l[i] = gcd(l[i - 1], a[i]);
  }

  vector<int> r(n);
  r[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    r[i] = gcd(r[i + 1], a[i]);
  }

  int ans = 0;
  ans = max(l[n - 2], r[1]);

  for (int i = 1; i <= n - 2; i++) {
    int v = gcd(l[i - 1], r[i + 1]);
    ans = max(ans, v);
  }

  cout << ans << endl;
}

// 0 1 2
//

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 1;
    int ans = n;
    rep(i, n-1) {
        if ( a[i] * 2 >= a[i+1] ) ++cnt;
        else {
            ans -= cnt;
            cnt = 1;
        }
        a[i+1] += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
// AOJ 0279: A Pair of Prizes
// 2017.8.22 bal4u@uu
// 2017.10.29 retry

#include <stdio.h>
#include <stdlib.h>

char buf[60105];
int main()
{
	int n, one, many;
	char *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		one = many = 0;
		fgets(p=buf, 60100, stdin);
		while (n--) {
			if (*(p+1) >= '0' || *p > '1') many++;
			else if (*p == '1') one++;
			while (*p >= '0') p++;
			p++;
		}
		if (many == 0) puts("NA");
		else printf("%d\n", one + many + 1);
	}
	return 0;
}

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

const int INF = numeric_limits<int>::max();

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> arr(h + 1, INF);
  arr[h] = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    for (int j = h; j >= 0; --j) {
      if (arr[j] != INF) {
        arr[max(0, j - a)] = min(arr[max(0, j - a)], arr[j] + b);
      }
    }
  }
  cout << arr[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<vector<int> >all;
vector<int>cur;
int n,m,q;
int a[5000],b[5000],c[5000],d[500000];
void gen (int i,int lst)
{
    if (i==n)
    {
        all.push_back(cur);
        return ;
    }

    for (int j=lst; j<=m; ++j)
    {
        cur.push_back(j);
        gen(i+1,j);
        cur.pop_back();
    }
}
int main()
{
    cin>>n>>m>>q;

    for (int i=0; i<q; ++i)
        cin>>a[i]>>b[i]>>c[i]>>d[i];

    gen(0,1);

    int ans=0;
    for (int i=0; i<all.size(); ++i)
    {
        int an=0;
        for (int j=0; j<q; ++j)
        {
            if (all[i][b[j]-1]-all[i][a[j]-1]==c[j])
                an+=d[j];
        }
        ans=max(ans,an);
    }
    cout<<ans;





}


Measured memory_bytes: 9788
import kotlin.math.abs
import kotlin.math.max

fun main() {
    val n = readInt()
    val xy = List(n) {
        val (x, y) = readInts()
        Pair(x, y)
    }

    fun manhattan(x: Pair<Int, Int>, y: Pair<Int, Int>): Int {
        return abs(x.first - y.first) + abs(x.second - y.second)
    }

    val maxPlus = xy.maxBy { it.first + it.second }!!
    val minPlus = xy.minBy { it.first + it.second }!!

    val maxMinus = xy.maxBy { it.first - it.second }!!
    val minMinus = xy.minBy { it.first - it.second }!!

    println(max(manhattan(maxPlus, minPlus), manhattan(maxMinus, minMinus)))
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 71576
<?php
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
	fscanf(STDIN, "%d", $a);
	$b[$a] = 1;
	if (isset($b[$a-1])) exit('0');
}
echo st(0);

function st($p) {
	global $b, $n;
	static $c = [];
	if (isset($b[$p]) || $p > $n) return 0;
	if ($p == $n) return 1;
	if (isset($c[$p])) return $c[$p];
	return $c[$p] = (st($p + 1) + st($p + 2)) % 1000000007;
}

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

int main () {
  int N;
  cin >> N;
  
  int x = 0, a = 0;
  char c;
  for (int i = 0; i < N; i++) {
    cin >> c;
    if (c == 'I') {
      a++;
    }
    if (c == 'D') {
      a--;
    }
    x = max(x,a);
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k, result = 0;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < k; ++i) {
		result += p.at(i);
	}
	cout << result << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#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 FI first
#define SE second
constexpr ll MOD = 1e9 + 7;

ll extgcd(ll a,ll b, ll &x, ll &y){ //extended Euclidean algorithm, used for modular multiplicative inverse
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1; y = 0;
    }
    return d; //return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD){ //return inv(a) mod m, ax+my=gcd(a,m)=1, m is prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m; //From (possibly) negative x to positive x
}

vector<ll> fact,invfact;
void calc_fact(int n, ll m = MOD)
{ //Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n)
    {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n,int k ,ll m = MOD){
    if(n<0||k<0||k>n)return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n,int k, ll m = MOD){
    if(n<0||k<0||k>n)return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    calc_fact(n * m);
    ll ans=0;
    FOR(i,1,n) {
        ans += i * (n - i) % MOD * m % MOD * m % MOD;
        ans %= MOD;
    }
    FOR(i,1,m){
        ans += i * (m - i) % MOD * n % MOD * n % MOD;
        ans %= MOD;
    }
    ans *= comb(n * m - 2, k - 2);
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
    int x,y,r,W,H;
    cin >>W>>H>>x>>y>>r;

    if (x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
        cout <<"Yes"<<endl;
    }
    else{
        cout <<"No"<<endl;
    }


}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    const int INF = 1 << 30;
    // num steps to win
    vector<int> dp(n+1, INF);
    dp[n] = 0;

    // num steps to win in reachable area
    queue<int> q;
    q.push(0);
    for(int i=n-1; i >=0; --i){
        while(true){
            if(q.size() == 0){
                cout << "-1" << endl;
                return 0;
            }
            // if furthest reachable block is winnable, take
            if(q.front() != INF &&  q.size() <= m) break;
            // if queue is longer than m, q.front() is not reachable
            // if q.front() is INF, q.front() is not winnable
            q.pop();
        }
        // if s[i] is not winnable, ignore
        if(s[i] == '0') dp[i] = q.front()+1;

        // add current block to queue
        q.push(dp[i]);
    }

    vector<int> ans;
    int x = 0;
    int moves = dp[0];
    while(x < n){
        --moves;
        int i=1;
        while(dp[x+i] != moves) i++;
        ans.push_back(i);
        x += i;
    }

    view(ans);

     return 0;
}


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

namespace SelfCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var array  = Console.ReadLine().Split(' ');

            var array2 = array.Select(int.Parse).ToArray();

            var maxi = array2[0];
            var cnt = 0;

            for (int i = 0;i < n;i++)
            {
                if(maxi <= array2[i])
                {
                    maxi = array2[i];
                    cnt++;
                }
            }
            Console.WriteLine(cnt); 
        }
    }
}


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


int main() {
    int N = 0;
    cin >> N;
    set<string> st;
    for (int i = 0; i<N ; i++){
        string S = "";
        cin >> S;
        st.insert(S);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 19188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int x;
    cin >> x;

    int maxval=1;
    for(int b=1;b<x;b++){
        for(int p=2;p<x;p++){
            int nowval=1;
            for(int i=0;i<p;i++){
                nowval*=b;
            }
            if(nowval>x){
                break;
            }
            maxval=max(maxval,nowval);
        }
        if(maxval==x)break;
    }

    cout << maxval << endl;

    return 0;
}


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

int main() {
int t, n;
for(int i = 0; i < 4; i++) {
cin >> t >> n;
if(t == 1) {
cout << 6000 * n << std::endl;
}
if(t == 2) {
cout << 4000 * n << std::endl;
}
if(t == 3) {
cout << 3000 * n << std::endl;
}
if(t == 4) {
cout << 2000 * n << std::endl;
}
}
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const ll MAX = 1e6 + 5;

int a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b;
	if(a == 1)
		a = 14;
	if(b == 1)
		b = 14;
	if(a > b)
		cout<<"Alice";
	else if(a < b)
		cout<<"Bob";
	else
		cout<<"Draw";
	return 0;
}

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

int nil=-1;

struct Node{
	int parent,left,right;
};

Node T[10000];
int Depth[10000],Height[10000];

void setDepth(int u,int d){
	if(u==nil) return;
	Depth[u]=d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1,h2;
	h1=h2=0;
	if(T[u].left!=nil){
		h1= setHeight(T[u].left)+1;
	}
	if(T[u].right!=nil){
		h2=setHeight(T[u].right)+1;
	}
	Height[u]=max(h1,h2);
	return Height[u];
}

int getSibling(int u){
	if(T[u].parent==nil) return nil;
	if(T[T[u].parent].left!=u && T[T[u].parent].left!=nil){
		return T[T[u].parent].left;
	}
	if(T[T[u].parent].right!=u && T[T[u].parent].right!=nil){
		return T[T[u].parent].right;
	}
	return nil;
}

int degree(int u){
	int deg=0;
	if(T[u].left!=nil) deg++;
	if(T[u].right!=nil) deg++;
	return deg;
}

void print(int u){
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].parent<<", ";
	cout<<"sibling = "<<getSibling(u)<<", ";
	cout<<"degree = "<<degree(u)<<", ";
	cout<<"depth = "<<Depth[u]<<", ";
	cout<<"height = "<<Height[u]<<", ";
	if(T[u].parent==nil) cout<<"root"<<endl;
	else if(T[u].left==nil && T[u].right==nil) cout<<"leaf"<<endl;
	else cout<<"internal node"<<endl;
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) T[i].parent=nil;
	int u,l,r;
	for(int i=0;i<n;i++){
		cin>>u>>l>>r;
		T[u].left=l;
		T[u].right=r;
		if(l!=nil) T[l].parent=u;
		if(r!=nil) T[r].parent=u;
	}
	int root;
	for(int i=0;i<n;i++) if(T[i].parent==nil) root=i;

	setDepth(root,0);
	setHeight(root);

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

	return 0;


}



Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

//#define abs(N) ((N>0)?N:-1*N)
//#define min(A,B) ((A>B)?B:A)
//#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

#define M_PI 3.14159265358979

int main(){
	int n;

	cin >> n;
	int x[n],y[n],d[n],ch=0;
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> y[i];
		d[i] = abs(x[i]-y[i]);
		ch = max(ch,d[i]);
	}

	for (int i = 1; i <= 3; ++i) {
		long long int sum=0;
		double rt;
		for (int j = 0; j < n; ++j) {
			sum += pow(d[j],i);
		}
		rt = pow(sum,1.0/i);
		printf("%.5f\n",rt);
	}
	printf("%.5f\n",(double)ch);

	return 0;
}



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll K; cin >> K;
  string S; cin >> S;
  ll n = S.size();
  if(n <= K) cout << S;
  else{
    REP(i,K) cout << S[i];
    cout << "...";
  }

  return 0;
}

Measured memory_bytes: 3648
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int a[1000001];
int32_t main()
{
	int n;
	cin >> n;
	for(int i =1 ; i<=n ; i++ ){
		if(i%3==0 || i%5==0){
			a[i]=-1;
		}
	}
	int sum = 0;
	for(int i = 1 ; i<=n ; i++ ){
		if(a[i]!=-1){
			sum+=i;
		}
	}
	cout << sum;
}





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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define ll long long
const ll INF = 2LL<<60;

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

    vector<int> w(N);
    rep(i, N) cin >> w[i];

    vector<int> sum1(N + 1, 0), sum2(N + 1, 0);
    sum1[1] = w[0];
    sum2[1] = w[N - 1];

    for(int i = 2; i < N + 1; i++)
    {
        sum1[i] = sum1[i - 1] + w[i - 1];
    }

    reverse(w.begin(),w.end());

    for(int i = 2; i < N + 1; i++)
    {
        sum2[i] = sum2[i - 1] + w[i - 1];
    }

    reverse(sum2.begin(), sum2.end());
    int ans = 100000;
    rep(i,N + 1)
    {
        ans = min(ans, abs(sum1[i] - sum2[i]));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int h,w,n,ans;
map<pii,int> vis;
set<int> s[N];
int main() {
    h=gi(),w=gi(),n=gi();
    for(int i=1;i<=n;i++) {
        int x=gi(),y=gi();
        vis[mp(x,y)]=1;
        s[y].insert(x);
    }
    ans=h;
    int x=1,y=1,cnt=0;
    while(1) {
        ++cnt;
        if(cnt>=ans) break;
        if(vis[mp(x+1,y)]) { chkmin(ans,cnt);break; }
        ++x;
        if(vis[mp(x,y+1)]) continue;
        else {
            auto z=s[y].upper_bound(x);
            if(z!=s[y].end()) chkmin(ans,cnt+(*z)-x);
            ++y;
        }
    }
    cout<<ans;
    return 0;
}


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

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long d=b%a;
    long long e=c%a;
    if(e==0 || d==0 || e<d){
        cout<<"OK";
    }
    else{
        if((c-b)>=a)cout<<"OK";
        else cout<<"NG";
    }
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define max(x) *max_element(all(x))
#define min(x) *min_element(all(x))

using namespace std;

ll fac[MAX], finv[MAX], inv[MAX];

//二項係数の計算
void comint()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com(ll n, ll k)
{
    if (n > k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//Nが素数か判定する
bool is_prime(ll N)
{
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

//Nを素因数分解した結果のリストを返す
vector<ll> soinsubunkai(long long N)
{
    vector<ll> tmp;
    ll num = N;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            if (is_prime(i))
            {
                while (num % i == 0)
                {
                    tmp.push_back(i);
                    num /= i;
                }
            }
            if (is_prime(j))
            {
                while (num % j == 0)
                {
                    tmp.push_back(j);
                    num /= j;
                }
            }
        }
    }
    return tmp;
}

//法mにおけるaの逆元を返す
ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

//法mにおけるa^bの値を返す
ll modpow(ll a, ll n, ll m)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll ans = 0;
    cin >> N;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    vector<ll> ruisekiwa(N + 1);
    set<ll> st;
    ruisekiwa[0] = 0;
    rep(i, N)
    {
        ruisekiwa[i + 1] = ruisekiwa[i] + vec[i];
    }
    sort(all(ruisekiwa));
    map<ll, ll> mp;
    for (auto i : ruisekiwa)
        mp[i]++;

    for (auto i : mp)
    {
        ans += i.second * (i.second - 1) / 2;
    }

    cout << ans << endl;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


/*
y>0としてx,yが互いにそになるように割ることを正規化と定義する。
正の整数a,bに対して
C(a,b):=入力のベクトルを正規化すると(a,b)になるものと(-b,a)になるものの個数

C(a,b):=(p,q)とすると、これらp+q本のベクトルに対し、前者と後者の両方を選ぶことはできないので
(2^p+2^q -1)通り選ぶことができる。

各(a,b)に対し、C(a,b)を求め、この値をかけていけば答えが求められる

*/

long long gcd(long long x,long long y){

    while(1){
        if(x<y)swap(x,y);
        if(!y)break;
        x%=y;
    }

    return x;


}

map<pair<long long,long long>,pair<long long,long long>>M;
long long z=0;//x,yどちらも0のベクトルの個数
long long x_zero=0,y_zero=0;
long long second[200010];
int main(){

    long long n;
    cin>>n;

    second[0]=1;
    rep2(i,n){
        second[i]=second[i-1]*2;
        second[i]%=mod;
    }
    
    rep(i,n){

        long long x,y;
        cin>>x>>y;
        if(x==0 &&y==0)z++;

        else if(x==0){
            x_zero++;
        }
        else if(y==0){
            y_zero++;
        }
        else{
            if(y<0){
                y=-y;
                x=-x;
            }
            long long g=gcd(abs(x),abs(y));
            x/=g;
            y/=g;
            
            //正規化して(b,-a)になる場合
            if(x<0)M[{y,-x}].first++;

            //正規化して(a,b)になる場合
            else M[{x,y}].second++;
        }

        
        
    }
    long long ret=1;

        for(auto m:M){
            long long a=second[m.second.first]+second[m.second.second]-1;
            ret=(ret*a)%mod;
        }
    long long single_one=second[x_zero]+second[y_zero]-1;
        ret=(ret*single_one)%mod;
/*
        ret+=z;
        ret%=mod;
        ret--;if(ret<0)ret+=mod;
        ret%=mod;
        cout<<ret<<endl;
*/
    cout<<(ret+z+mod-1)%mod<<endl;
    return 0;

}
/*

*/


Measured memory_bytes: 20768
#include <bits/stdc++.h>
using namespace std;
     
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
   ll n;
   cin >> n;
   map<string,ll> y;
   ll maxi = 0;
   for(ll i=0;i<n;i++)
   {
       string s;
       cin >> s;
       y[s]++;
       maxi = max(maxi,y[s]);
   }
   for(auto X:y)
   {
       if(X.ss==maxi)   cout<<X.ff<<"\n";
   }
}

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

const int N = 2e5 + 5;

int n, a[N], pos[N], p[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		if (i % 2 == (n + 1) % 2) {
			pos[i] = ((n + 1) - i) / 2 + i;
		} else {
			pos[i] = ((n + 1) - (i - 1)) / 2;
		}
	}
	for (int i = 1; i <= n; ++i) p[pos[i]] = a[i];
	for (int i = 1; i <= n; ++i) printf("%d ", p[i]); printf("\n");
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];

int main(){
    int x;
    cin >> x;
    if(x == 1){cout << 0;}
    else{cout << 1;}
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    int xored = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        xored ^= a[i];
    }

    for(int i = 0; i < n; i++) {
        cout << (xored ^ a[i]) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4304
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var a = cin.ReadInt;
            var s = cin.ReadLine;

            if (a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}




int main(void){
    int N;
    cin >> N;
    map<string, int> card;
    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        card[s]++;
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++){
        string s;
        cin >> s;
        card[s]--;
    }
    int max = 0;
    for (auto itr = card.begin(); itr != card.end(); itr++){
        max = max<itr->second?itr->second:max;
    }
    cout << max << endl;
    return 0;
    
}



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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    ll A, B, N;
    cin >> A >> B >> N;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (N < B - 1) {
        cout << (A * N) / B << endl;
    } else {
        cout << (A * (B - 1)) / B << endl;
    }
    return 0;
}

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

int main() {
  int A, B, C, count = 0;
  cin >> A >> B >> C;
  if (B >= C+1)
    count+= B + C;
  else {
    count += B*2;
    C -= B;
    if (C > A)
      count+= A+1;
    else
      count+= C;
  }
  cout << count << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<ll> ans(N + 1, 0);
    for (int i = 0; i < N; i++) {
        if (S.at(i) == '<') {
            ans.at(i + 1) = max(ans.at(i) + 1, ans.at(i + 1));
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (S.at(i) == '>') {
            ans.at(i) = max(ans.at(i), ans.at(i + 1) + 1);
        }
    }
    ll ansn = 0;
    for (ll x : ans) {
        ansn += x;
    }
    cout << ansn << endl;
}

Measured memory_bytes: 7696