akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  int w;
  cin >> s;
  cin >> w;
  string ans = "";
  rep(i,sz(s)) {
    if(i%w!=0) continue;
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())

theta_H=2*math.pi*(H/12+M/720)
theta_M=2*math.pi*M/60
#print(theta_H,theta_M)

ax,ay=A*math.sin(theta_H),A*math.cos(theta_H)
bx,by=B*math.sin(theta_M),B*math.cos(theta_M)
#print(ax,ay,bx,by)

print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;

    cin >> n;

    pair <int, int> p[n];

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

        cin >> p[i].first;
        p[i].second = i+1;
    }

    sort(p, p+n);

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

        cout << p[i].second << " ";
    }

    return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int A, B;
        cin >> A >> B;
        int ans = (B - 1) / (A - 1) + ((B - 1) % (A - 1) != 0);
        cout << ans << endl;
    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int tot=0;
int a[1000005],rt[1000005],pre[1000005];
int sonL[30000005],sonR[30000005],size[30000005];
inline int read() {
	register int x=0,f=1;register char s=getchar();
	while(s>'9'||s<'0') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=x*10+s-'0';s=getchar();}
	return x*f;
}
void build(int &p,int l,int r) {
	p=++tot;
	if(l==r) return;
	int mid=l+r>>1;
	build(sonL[p],l,mid);
	build(sonR[p],mid+1,r);
}
inline void assign(int p,int lst) {
	size[p]=size[lst];
	sonL[p]=sonL[lst];
	sonR[p]=sonR[lst];
}
void change(int &p,int lst,int l,int r,int pos) {
	p=++tot;assign(p,lst);++size[p];
	if(l==r) return;
	int mid=l+r>>1;
	if(pos<=mid) change(sonL[p],sonL[lst],l,mid,pos);
	else change(sonR[p],sonR[lst],mid+1,r,pos);
}
int ask(int p1,int p2,int l,int r,int L,int R) {
	if(L<=l&&r<=R) return size[p2]-size[p1];
	int mid=l+r>>1,res=0;
	if(L<=mid) res+=ask(sonL[p1],sonL[p2],l,mid,L,R);
	if(R>mid) res+=ask(sonR[p1],sonR[p2],mid+1,r,L,R);
	return res;
}
int main() {
	int n=read();int T=read();
	build(rt[0],0,n);
	for(register int i=1;i<=n;++i) {a[i]=read();change(rt[i],rt[i-1],0,n,pre[a[i]]);pre[a[i]]=i;}
	while(T--) {
		int l=read(),r=read();
		printf("%d\n",ask(rt[l-1],rt[r],0,n,0,l-1));
	}
	return 0;
}

Measured memory_bytes: 134736
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
typedef pair<ll,ll> pii;
//---------------------
#define MAXN 50
//---------------------
ll m,n,a[MAXN],b[MAXN],c[MAXN],d[MAXN];

ll getdist(ll stux,ll stuy,ll ckpx, ll ckpy){
	return abs(stux-ckpx)+abs(stuy-ckpy);
}

int main(){
	cin>>n>>m;
	REP(i,n) {cin>>a[i]>>b[i];}
	REP(i,m) {cin>>c[i]>>d[i];}
	REP(i,n){
	  	ll id=100;
	  	ll mindist=1000000000;
		REP(j,m){
			ll dist=getdist(a[i],b[i],c[j],d[j]);
			if(dist<mindist){
				id=j+1;
				mindist=dist;
			}
		}
		cout<<id<<endl;
	}
	  	
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  string s;
  cin >> s;

  int len = s.length();
  if(s[0] == s[len - 1]){
    //a babab a
    if(len % 2 == 0){
      printf("First\n");
    }else{
      printf("Second\n");
    }
  }else{
    //a bababa b
    if(len % 2 == 0){
      printf("Second\n");
    }else{
      printf("First\n");
    }
  }

  return 0;
}



Measured memory_bytes: 512
#include <cstdio>

char str[199999];
int cnt[9];
int main() {
	scanf("%s",str);
	int N=0;
	while(str[N]!='\0') {
		cnt[(int)(str[N++]-'a')]++;
	}
	int maxv=cnt[0];
	int minv=cnt[0];
	for(int i=1;i<3;i++) {
		if(maxv<cnt[i]) maxv=cnt[i];
		if(minv>cnt[i]) minv=cnt[i];
	}
	if(maxv-minv<2) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

bool ok[1000000010];

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

    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) {
        cin >> v[i];
        ok[v[i]]=true;
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    rep(i, n) {
        if (ans >= n-i-1) break;
        for (int j=i+1; j<n; ++j) {
            if (ans >= 2+n-j-1) break;
            ll d = v[j]-v[i];
            ll prev = v[j];
            ll num = 2;
            while (prev+d <= 1000000000 and ok[prev+d]) {
                num++;
                prev += d;
            }
            ans = max(ans, num);
            if (ans >= n-i-1) break;
        }
    }
    cout << ans << endl;
}



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

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n, a;
  std::cin >> n >> a;
  std::vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> x[i];
    x[i] -= a;
  }

  std::map<long long, long long> counts;
  for (int i = 0; i < n; ++i) {
    std::map<long long, long long> adds;
    adds[x[i]] = 1;
    for (auto kv : counts) {
      adds[kv.first + x[i]] += kv.second;
    }

    for (auto kv : adds) {
      counts[kv.first] += kv.second;
    }
  }

  std::cout << counts[0] << std::endl;
  /* */

  return EXIT_SUCCESS;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

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

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

	vector<int> x;
	long long int totalAll = 0;

	rep(i, n){
		long long int a;
		cin >> a;
		totalAll += a;
		x.push_back(a);
	}

	vector<long long int> mapping;
	long long int totalLeft = 0;
	rep(i, n){
		totalLeft += x[i];
		mapping.push_back(totalLeft);
	}


	long long int ans = __LONG_LONG_MAX__;

	rep(i, n){
		long long int left = mapping[i];
		long long int right = totalAll - mapping[i];
		if(abs(right - left) < ans){
			ans = abs(right - left);
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3188
nkq = input()
NKQ = nkq.split(" ")
point = []
for i in range(int(NKQ[0])):
  point.append(int(NKQ[1]) - int(NKQ[2])) #参加者のポイント
for j in range(int(NKQ[2])):
  Ai = int(input()) - 1
  point[Ai] = point[Ai] + 1
for k in range(int(NKQ[0])):
  if point[k] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 7848
m = gets.to_i
n = gets.to_i
vertex = (0...m).to_a
outEdge = Array.new(m){Array.new}
inDegree = Array.new(m, 0)
n.times do
  x, y = gets.split.map{|v|v.to_i-1}
  outEdge[x].push(y)
  inDegree[y] += 1
end
while vertex.size > 0 do
  x = inDegree.index(0)
  inDegree[x] = -1
  outEdge[x].each do |y|
    inDegree[y] -= 1
  end
  vertex.delete(x)
  p x+1
end

Measured memory_bytes: 6116
K,A,B = map(int, input().split())
C = B - A
if C > 2 and K > 1:
    K_rem = K - (A - 1)
    if K_rem > 1:
        print(A + C*(K_rem//2) + K_rem % 2)
    else:
        print(1+K)
else:
    print(1+K)

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


int main() {
    ll n;
    cin >> n;
    vll c(5);
    rep(i, 5) cin >> c[i];

    ll mn = LINF;
    int idx = -1;
    rep(i, 5) {
        if (c[i] < mn) {
            mn = c[i];
            idx = i;
        }
    } 

    ll ans = idx;
    ans += (n + (mn - 1)) / mn;
    ans += 5-idx-1;

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

Measured memory_bytes: 256
S = []
S_reverse = []
S_first = []
S_first_reverse = []
S_last = []
S_last_reverse = []

S = list(input())
S_reverse = S.copy()
S_reverse.reverse()
S_first = S[:len(S)//2]
S_last = S[(len(S)+1)//2:]
S_first_reverse = S_first.copy()
S_first_reverse.reverse()
S_last_reverse = S_last.copy()
S_last_reverse.reverse()


if S != S_reverse:
    print("No")
elif S_first == S_first_reverse and S_last == S_last_reverse:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#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 <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}int main() {
    ll N, K;
    cin >> N >> K;
    ll n;
    ll m;
    map<ll, bool> snack;
    rep(i, K) {
        cin >> n;
        rep(j, n) {
            cin >> m;
            snack[m] = true;
        }
    }
    ll cnt = 0;
    for (auto x : snack) {
        if (x.second)cnt++;
    }
    cout << N - cnt << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  string t = "";
  while(t.size()<s.size()-3) {
    int n = t.size();
    string u = "";
    rep(i,3) u += s[n+i];
    if(u=="mae") t += "maerd";
    else if(u=="rem") t += "remaerd";
    else if(u=="esa") t += "esare";
    else if(u=="res") t += "resare";
    else break;
    if(t==s) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		String[] inputS = new String[3];
		long k, a, b;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
			inputS = br.readLine().split(" ");
			k = Long.parseLong(inputS[0]);
			a = Long.parseLong(inputS[1]);
			b = Long.parseLong(inputS[2]);
		}
		if((b - a) <= 2 || k + 1 <= a) {
			System.out.println(k + 1);
		} else {
			long cookie = (long)1;
			int yen = 0;
			for(long i=0;i<k;i++) {
				if(yen != 0) {
					yen = 0;
					cookie += b;
				} else if(cookie < a || (k - i) < 2) {
					cookie++;
				} else {
					cookie -= a;
					yen = 1;
				}
			}
			System.out.println(cookie);
		}
	}
}

Measured memory_bytes: 22996
import sys
input = sys.stdin.readline

def GCD(a, b):
    if(b == 0):
        return a
    else:
        return GCD(b, a % b)

def LCM(a, b):
    return a * b // GCD(a, b)

n = int(input())
t = [int(input()) for i in range(n)]
ans = t[0]
for i in range(1,n):
    ans = LCM(ans, t[i])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    int r;
    cin>>r;
    printf("%.10f\n",2*3.14159265*r);
    return 0;
}

Measured memory_bytes: 3764
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s = X()
s.sort()
s = "".join(s)
if s == "abc":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10388
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    ans = 0
    for j in range(i, n - 1):
        ans = -(-1 *max(ans, csf[j][1]) // csf[j][2]) * csf[j][2] + csf[j][0]
    print(ans)

Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	dp := make([]int, n)
	dp[0] = 0
	dp[1] = abs(h[1] - h[0])

	for i := 2; i < n; i++ {
		costa := dp[i-1] + abs(h[i]-h[i-1])
		costb := dp[i-2] + abs(h[i]-h[i-2])
		dp[i] = min(costa, costb)
	}

	fmt.Println(dp[n-1])

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 3984
# coding: utf-8
bodies_count = list(map(int,input().split()))
enemy_life = list(map(int,input().split()))

if bodies_count[1] == 0:
    print(sum(enemy_life))
else:
    enemy_life.sort(reverse=True)
    if bodies_count[1] == 1:
        del enemy_life[0] 
    else:
        a = bodies_count[1]
        del enemy_life[0:a]

    if enemy_life != []:
        print(sum(enemy_life))
    else:
        print(0)
    # for i in range(bodies_count[1]):
    #     if enemy_life == []:
    #         print(count)
    #         break
    #     else:
    #         enemy_life.sort()
    #         print(enemy_life)
    #         enemy_life.pop(enemy_life.index(max(enemy_life)))



Measured memory_bytes: 26024
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 1234560
#endif

int N,M;
vector<int> A(SIZE);

pair<int,int> count(string s) {
    pair<int,int> ret = {0,0};
    for (char c:s) {
        if (c=='(') {
            ret.first++;
        } else if (ret.first) {
            ret.first--;
        } else {
            ret.second++;
        }
    }
    return ret;
}

void solve(int _t) {
    cin>>N;
    string s;
    map<int,vector<pair<int,int>>> B;
    vector<pair<int,int>> S,E;
    REP(i,N) {
        cin>>s;
        auto r = count(s);
        if (r.second <= r.first) {
            S.push_back({r.second,r.first});
        }
        else {
            E.push_back(r);
        }
    }
    sort(ALL(S));
    sort(ALL(E));
    reverse(ALL(E));
    int cnt=0;
    for (auto q:S) {
        cnt -= q.first;
        if (cnt < 0) {
            _PN("No");
            return;
        }
        cnt += q.second;
    }
    for (auto q:E) {
        cnt -= q.second;
        if (cnt < 0) {
            _PN("No");
            return;
        }
        cnt += q.first;
    }
    string ans = (!cnt ? "Yes" : "No");
    _PN(ans);
}
EXEC(1)



Measured memory_bytes: 28716
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int r[200000],l[200000];
struct data{
    int x,y;
};
int cmp_d(const void *a,const void *b){
    return ((struct data *)a)->x - ((struct data *)b)->x;
}
int main(void){
    int n=in(),m=in(),i,y,t1,t2;
    struct data d[100000];
    rep(i,m){
        d[i].x=in();
        d[i].y=in();
    }
    qsort(d,m,sizeof(struct data),cmp_d);
    rep(i,n)l[i]=r[i]=i;
    rep(i,m){
        y=d[i].y;
        r[y-1]=r[y];
        l[y]=l[y-1];
    }
    rep(i,n)printf("%d%c",r[i]-l[i]+1,i!=n-1?' ':'\n');
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

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

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

    int cnt = 0;
    while (s.length() >= 2) {
        int last = s.length() - 1;
        if (s[0] == s[last]) {
            s.erase(s.end() - 1);
            s.erase(s.begin());
        } else if (s[0] == 'x') {
            s.erase(s.begin());
            cnt++;
        } else if (s[last] == 'x') {
            s.erase(s.end() - 1);
            cnt++;
        } else {
            printf("-1\n");
            return 0;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
from itertools import accumulate
mod = 10**9+7
rng = 100100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
asum = [0] + list(accumulate(a))
ans = 0
for t in range(k-1,n):
  ans = (ans+cmb(t-1,k-2)*(asum[n]-asum[t]-asum[n-t]))%mod
print(ans)

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

int main(){
int on, two;
char therr;
//cin >> on >> therr >> two;
while(true){
cin >>on >> therr >> two;
if(therr == '?')
break;
int sum = 0;
switch(therr){
case '+':
sum = on + two;
break;
case '-':
sum = on - two;
break;
case '*':
sum = on * two;
break;
case '/':
sum = on / two;
break;
case '?':
break;
}
cout << sum << endl;
}

return 0;//
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
int solve(int h){
    if(h == 1) return 1;
    return 1 + 2*solve(h/2);
}
signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int h; cin>>h;
    cout<<solve(h)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<map>
ll ar1[210000];
ll ar2[10000];
ll fun(ll a)
{
    ll i;
    for(i=1; i<=32; i++)
    {
        if(ar2[i]>a)
            return ar2[i];
    }
}
int main()
{
    ll a,b=1,c,d,i,j;
    map<ll,ll>br;
    cin>>a;
    for(i=1; i<=a; i++)
    {
        cin>>ar1[i];
        br[ar1[i]]++;
    }
    sort(ar1+1,ar1+1+a);
    for(i=1; i<=32; i++)
    {
        b=b*2;
        ar2[i]=b;
    }
    ll cnt=0;
    for(i=a; i>=1; i--)
    {
        ll n=fun(ar1[i]);
        ll k=n-ar1[i];
        br[ar1[i]]--;
        if(br[k]>0 && br[ar1[i]]>=0)
        {
            cnt++;
            br[k]--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << 700 + 100 * counter << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import collections
n, k = map(int,input().split())

sunuke = [0 for i in range(1, n+1)]
ans = 0
for i in range(k):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        sunuke[j-1] += 1
c = collections.Counter(sunuke)
print(c[0])


Measured memory_bytes: 67920
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    n, m = get_int_list()
    A = []
    B = []
    for _ in range(n - 1 + m):
        a, b = get_int_list()
        A.append(a)
        B.append(b)

    root = (set(A) - set(B)).pop()
    graph = defaultdict(list)
    for a, b in zip(A, B):
        graph[a].append(b)
    known = {root}
    deq = deque([root])
    added = Counter()
    cnt = 0
    while cnt < n - 1 + m:
        parent = deq.popleft()
        children = graph[parent]
        for c in children:
            cnt += 1
            if c in known:
                added[c] += 1
                continue
            known.add(c)
            deq.append(c)
    parents = [0] * n
    deq = deque([root])
    cnt = 1
    while cnt < n:
        parent = deq.popleft()
        children = graph[parent]
        for c in children:
            if added[c] > 0:
                added[c] -= 1
                continue
            parents[c-1] = parent
            cnt += 1
            deq.append(c)
    for parent in parents:
        print(parent)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37904
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int p=a;p<b;p++)
#define modulo 1000000007

int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int c[n+1];
    int a[n+1][m+1];
    int sum[m+1];
    bool flag=true;
    for(int i=0;i<m;i++)
    {
        sum[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
            sum[j]+=a[i][j];
        }
    }
    for(int i=0;i<m;i++)
    {
        if(sum[i]<x)
        {
            cout<<-1<<endl;
            flag=false;
        }
    }
    if(flag)
    {
        int max=pow(2,n);
        int total[m+1];
        int ind=0;
        bool flagx=true;
        int very[50000];
        for(int i=1;i<max;i++)
        {
            int mot=0;
            set_null(total,m+1);
            flagx=true;
            for(int j=0;j<n;j++)
            {
                if(i&(1<<j)){
                    for(int l=0;l<m;l++)
                    {
                        total[l]+=a[j][l];
                    }
                    mot+=c[j];
                }
            }
            for(int k=0;k<m;k++)
            {
                if(total[k]<x)
                {
                    flagx=false;
                    break;
                }
            }
            if(flagx)
            {
                very[ind++]=mot;
            }
        }
        int min=1000000000;
        for(int i=0;i<ind;i++)
        {
            if(very[i]<min)
            {
                min=very[i];
            }
        }
        cout<<min<<endl;
    }


    return 0;
}



Measured memory_bytes: 4056
N = int(input())
A = list(map(int, input().split()))


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def add(self, k, x):
        while k < self.n:
            self.data[k] += x
            k += k & -k

    def get(self, k):
        s = 0
        while k > 0:
            s += self.data[k]
            k -= k & -k

        return s

    def init(self, n):
        self.n = n
        self.data = [0] * n


left, right = 0, 10 ** 9 + 5
bit = BIT(N)
while right - left > 1:
    x = (right + left) // 2

    S = [0] * (N + 1)
    for i in range(N):
        if A[i] >= x:
            S[i + 1] = S[i] + 1
        else:
            S[i + 1] = S[i] - 1

    p = abs(min(S)) + 1
    for i in range(N + 1):
        S[i] += p
    q = max(S) + 1
    bit.init(q)
    num = 0
    for i in S:
        num += bit.get(i)
        bit.add(i, 1)

    if num * 2 >= N * (N + 1) // 2:
        left = x
    else:
        right = x

print(left)


Measured memory_bytes: 110052
#D - Lucky PIN
#000～999までそれぞれ作成できるかをチェックする
n=int(input())
s=str(input())
ans = 0
for i in range (10):
    for j in range (10):
        for k in range (10):
            check_i = (s.find(str(i)))
            check_j = (s.find(str(j),check_i+1))
            check_k = (s.find(str(k),check_j+1))
            if(check_i >= 0 and check_j >= 0 and check_k >= 0):
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
long long read()
{
	char c=getchar();
	long long res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,m,s,t,h[405],cnt=1,lx[205],rx[205],ly[205],ry[205],p[405],pre[405];
long long d[405],ans,sum;
bool vis[405];
char op[10];
struct Edge
{
	int to,next,d;
	long long v;
}w[100005];
struct node
{
	int x,y;
	long long v;
}a[100005];
struct que
{
	int op,x,v;
}b[100005];
void add(int x,int y,int d,long long v)
{
	w[++cnt]=(Edge){y,h[x],d,v};
	h[x]=cnt;
	w[++cnt]=(Edge){x,h[y],0,-v};
	h[y]=cnt;
}
bool Spfa()
{
	memset(d,-0x3f,sizeof(d));
	d[s]=0;p[s]=0x3f3f3f3f;p[t]=0;
	queue<int> q;
	q.push(s);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=h[u];i;i=w[i].next)
		{
			int to=w[i].to;
			if(w[i].d&&d[to]<d[u]+w[i].v)
			{
				d[to]=d[u]+w[i].v;
				p[to]=min(p[u],w[i].d);pre[to]=i;
				if(!vis[to]) q.push(to),vis[to]=1;
			}
		}
	}
	return p[t];
}
void Solve()
{
	sum+=p[t]*d[t];
	int now=t;
	while(now!=s)
	{
		w[pre[now]].d-=p[t];
		w[pre[now]^1].d+=p[t];
		now=w[pre[now]^1].to;
	}
}
void EK()
{
	sum=0;
	while(Spfa()) Solve();
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),a[i].v=read();
	m=read();
	for(int i=1;i<=m;i++)
	{
		scanf("%s",op);
		if(op[0]=='L') b[i].op=1;
		else if(op[0]=='R') b[i].op=2;
		else if(op[0]=='D') b[i].op=3;
		else b[i].op=4;
		b[i].x=read(),b[i].v=read();
	}
	for(int k=1;k<=n;k++)
	{
		memset(h,0,sizeof(h));cnt=1;
		s=0,t=2*k+2*n+1;
		for(int i=1;i<=k;i++) add(s,i,1,0),add(i+2*n+k,t,1,0);
		memset(lx,0,sizeof(lx));memset(rx,0x3f,sizeof(rx));
		memset(ly,0,sizeof(ly));memset(ry,0x3f,sizeof(ry));
		for(int i=1;i<=m;i++)
		{
			if(b[i].op==1) for(int j=b[i].v+1;j<=k;j++) lx[j]=max(lx[j],b[i].x+1);
			else if(b[i].op==2) for(int j=1;j<=k-b[i].v;j++) rx[j]=min(rx[j],b[i].x-1);
			else if(b[i].op==3) for(int j=b[i].v+1;j<=k;j++) ly[j]=max(ly[j],b[i].x+1);
			else for(int j=1;j<=k-b[i].v;j++) ry[j]=min(ry[j],b[i].x-1);
		}
		for(int i=1;i<=n;i++) add(i+k,i+n+k,1,a[i].v);
		for(int i=1;i<=k;i++)
		for(int j=1;j<=n;j++) if(lx[i]<=a[j].x&&a[j].x<=rx[i]) add(i,j+k,1,0);
		for(int i=1;i<=k;i++)
		for(int j=1;j<=n;j++) if(ly[i]<=a[j].y&&a[j].y<=ry[i]) add(j+k+n,2*n+i+k,1,0);
		EK();
		ans=max(ans,sum);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main()
{
int xx,yy;
xx = yy = 0;
int n;
scanf("%d",&n);
int valid=1;
int x,y,tt,t;
tt=0;
int i;
for(i=1; i<=n; i++)
{
scanf("%d%d%d",&t,&x,&y);
int ff = abs(x-xx);
int gg = abs(y-yy);
if(ff +  gg > t - tt)valid = 0;
else if( (t-tt-ff-gg)%2)valid = 0;
}
if(valid)printf("Yes\n");
else printf("No\n");
return 0;
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<int> A(N, 0);
  map<int, int> cnt;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  ll ans = 0;
  for (auto m : cnt) {
    ll tmp = cnt[m.first];
    ans += (tmp * (tmp - 1)) / 2;
  }
  for (int i = 0; i < N; i++) {
    ll tmp = cnt[A[i]];
    ll ans_i = ans - (tmp * (tmp - 1)) / 2;
    if (cnt[A[i]] > 2) ans_i += ((tmp - 1) * (tmp - 2)) / 2;
    cout << ans_i << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 8320
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (a>b) {
            System.out.println("a > b");
        } else if (a<b) {
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26172
from collections import defaultdict
import sys
d = defaultdict(set)
N=int(input())
for i in range(1,N+1):
    #print(i)
    j=str(i)
    d[(int(j[0]),int(j[-1]))].add(i)

ans=0
for i in range(1,10):
    ans += len(d[i,i])**2
for i in range(1,10):
    for j in range(i+1,10):
        ans+= len(d[i,j])*len(d[j,i])*2
print(ans)

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    bool ok = false;
    for(int i=1;i<=1000;++i){
        if(a <= k*i and b >= k*i){
            ok = true;
            break;
        }
    }
    if(ok)cout << "OK" << endl;
    else cout  << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N, K;
    in(N); in(K);
    int d;
    vector<bool> has(N, false);
    rep(i, K) {
        in(d);
        rep(i, d) {
            int tmp;
            in(tmp);
            has[tmp-1] = true;
        }
    }

    int cnt = 0;
    rep(i, N) {
        if (!has[i]) cnt++;
    }
    out(cnt);

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, A;
  cin >> N >> A;

  ll M = 10001;
  ll center = (M - 1) / 2;
  vll dp(M);

  rep(i, N) {
    ll x;
    cin >> x;
    ll diff = x - A;
    vll next = dp;
    next[center + diff]++;
    rep(j, M) {
      if (dp[j] == 0) continue;
      next[j + diff] += dp[j];
    }
    dp = next;
  }

  COUT(dp[center]);
  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      if (x % 3 != 0 && x % 5 != 0) {
        ans = false;
      }
    }
  }
  cout << (ans ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
N = int(input())
l=[list(map(int,input().split())) for i in range(N)]
l_after=sorted(((i+j,i,j) for i,j in l),reverse=True)
print(sum(b for a,b,c in l_after[::2])-sum(c for a,b,c in l_after[1::2]))

Measured memory_bytes: 37848
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x.at(i); }

int main() {

    int n = 6;
    CINS(int, a, n);

    string result = ":(";
    if (a.at(4) - a.at(0) <= a.at(5)) {
        result = "Yay!";
    }

    cout << result;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	int ans;
	bool exist = false;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j < (100 / 7); j++) {
			ans = 4 * i + 7 * j;
			if (ans == N) exist = true;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[1002][1002];
int n,m,b[1002][1002],s[1002][1002];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=m;j++){
	    	cin>>a[i][j];
	    	if(a[i][j]=='#')
	    	b[i][j]=1;
		}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			s[i][j]=b[i-1][j-1]+b[i-1][j]+b[i-1][j+1]
			+b[i][j-1]+b[i][j+1]
			+b[i+1][j-1]+b[i+1][j]+b[i+1][j+1];
			if(b[i][j]==1)cout<<'#';
			else cout<<s[i][j];
		}
		cout<<endl;
	}
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int p,q,a,n;

int rec(int x,int y,int now,int dep){
  
  if(x*p==q*y)return 1;
  if(dep==0)return 0;

  int sum=0;
  for(int z=now;z*x<=a;z++){
    if(y/x+1/z<=p/q)sum+=rec(z*x,z*y+x,z,dep-1);
  }
  return sum;
}

int main(void){
  
  while(cin >> p >> q >> a >> n,p|q|a|n){
    cout << rec(1,0,1,n) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"

ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ll l, r, d;
	cin >> l >> r >> d;
	cout << (r / d) - (l / d) + (l % d == 0 ? 1 : 0) << "\n";
}

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

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

    vector<int> L(N);

    for(int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }

    int count = 1;
    int length = 0;

    for(int i = 0; i < N; i++)
    {
        length += L.at(i);
        if(length <= X)count++;
        else break;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>




int main(){
  int i;
  int s,t;
  int count=0;
  int key,left,right,mid;

  scanf("%d",&s);
  int S[s];
  for(i=0;i<s;i++)scanf("%d",&S[i]);


  scanf("%d",&t);
  int T[t];
  for(i=0;i<t;i++)scanf("%d",&T[i]);


  for(i=0;i<t;i++){

    left=0;
    right=s;

    key=T[i];
    while(left<right){
      mid=(left+right)/2;
      if(S[mid]==key){
	//printf("%d",key);
	count++;
	break;
      }
      else if(key<S[mid])right=mid;
      else left = mid+1;
    }
  }

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

Measured memory_bytes: 1184