akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def LF(): return list(map(float, input().split()))
def LC(): return [c for c in input().split()]
def LLI(n): return [LI() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]

def array2d(N, M, initial=0):
    return [[initial]*M for _ in range(N)]

def copy2d(orig, N, M):
    ret = array2d(N, M)
    for i in range(N):
        for j in range(M):
            ret[i][j] = orig[i][j]
    return ret


INF = float("inf")
MOD = 10**9 + 7


def main():
    S = input()
    if S == "RRR":
        print(3)
    elif S == "RRS" or S == "SRR":
        print(2)
    elif S == "RSR":
        print(1)
    else:
        print(S.count("R"))
    return


if __name__ == '__main__':
    main()


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

#define NIL -1

class Node {
public:
	int iParent_;
	int iLeftChild_;
	int iRightChild_;
	int iDepth_;
	int iHeight_;
};

class Tree {
public:
	Tree(int iNum) :iMaxNodeNum_(iNum) {
		for (int i = 0; i < iNum; i++) {
			noNode_[i].iParent_ = NIL;
			noNode_[i].iLeftChild_ = NIL;
			noNode_[i].iRightChild_ = NIL;
			noNode_[i].iHeight_ = NIL;
		}
	}

	int searchRootIndex() {
		for (int i = 0; i < iMaxNodeNum_; i++)
			if (noNode_[i].iParent_ == NIL) return i;
	}

	void setNodeValue() {
		for (int iCurNo_i = 0; iCurNo_i < iMaxNodeNum_; iCurNo_i++) {
			int iNo, iChiL, iChiR;
			cin >> iNo >> iChiL >> iChiR;
			noNode_[iNo].iLeftChild_ = iChiL;
			noNode_[iNo].iRightChild_ = iChiR;

			noNode_[iChiL].iParent_ = iNo;
			noNode_[iChiR].iParent_ = iNo;
		}

		int iRoInx = searchRootIndex();
		setDepth(iRoInx, /*depth =*/0);
		setHeight(iRoInx,/*depth =*/0);
	}

	void setDepth(int iNum, int iDep) {
		noNode_[iNum].iDepth_ = iDep;
		if (noNode_[iNum].iRightChild_ != NIL)
			setDepth(noNode_[iNum].iRightChild_, iDep + 1);
		if (noNode_[iNum].iLeftChild_ != NIL)
			setDepth(noNode_[iNum].iLeftChild_, iDep + 1);
	}

	int setHeight(int iNum, int iHeight) {
		int iLH = 0, iRH = 0;
		if (noNode_[iNum].iRightChild_ != NIL)
			iRH = setHeight(noNode_[iNum].iRightChild_, iHeight) + 1;
		if (noNode_[iNum].iLeftChild_ != NIL)
			iLH = setHeight(noNode_[iNum].iLeftChild_, iHeight) + 1;

		noNode_[iNum].iHeight_ = iRH > iLH ? iRH : iLH;
		return noNode_[iNum].iHeight_;
	}

	void print() {
		for (int iNodeNum_i = 0; iNodeNum_i < iMaxNodeNum_; iNodeNum_i++) {
			Node iCurNode = noNode_[iNodeNum_i]; //??¬????????°

			//?????????????±????
			string type = "internal node";
			if (iCurNode.iParent_ == NIL) type = "root";
			else if (iCurNode.iLeftChild_ == NIL && iCurNode.iRightChild_ == NIL) type = "leaf";

			//????????????????????°
			int iChildNum = 0;
			if (iCurNode.iLeftChild_ != NIL) iChildNum++;
			if (iCurNode.iRightChild_ != NIL) iChildNum++;

			//???????????????
			int iSiblingNodeNum = -1;
			if (noNode_[iNodeNum_i].iParent_ != NIL) {
				Node iParNode = noNode_[noNode_[iNodeNum_i].iParent_]; //??¬????????°
				   //?????????????????????NIL??????????????????????????¨????????????
				if (iParNode.iLeftChild_ != iNodeNum_i && iParNode.iLeftChild_ != NIL) iSiblingNodeNum = iParNode.iLeftChild_;
				else if (iParNode.iRightChild_ != iNodeNum_i && iParNode.iRightChild_ != NIL) iSiblingNodeNum = iParNode.iRightChild_;
			}

			//??????
			cout << "node " << iNodeNum_i << ": ";
			cout << "parent = " << iCurNode.iParent_ << ", ";
			cout << "sibling = " << iSiblingNodeNum << ", ";
			cout << "degree = " << iChildNum << ", ";
			cout << "depth = " << iCurNode.iDepth_ << ", ";
			cout << "height = " << iCurNode.iHeight_ << ", ";
			cout << type << endl;
		}
	}
private:
	static const int kMax_Node = 25;
	Node noNode_[kMax_Node];
	int iMaxNodeNum_;
};

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

	//????????????NULL?????\?????????
	Tree trNodeTree(iNodeNum);

	//???????????§??\????????????
	trNodeTree.setNodeValue();

	//??????
	trNodeTree.print();
	return 0;
}

Measured memory_bytes: 3164
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n, j = 1000; cin >> n;
  int x = n%j;
  if(x) x = j-x;
  cout << x << '\n';
}

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

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}    
  

Measured memory_bytes: 3656
import java.util.Scanner;

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] B = new int[N + 1];
        B[0] = B[N] = Integer.MAX_VALUE;
        for (int i = 1; i < N; i++) {
            B[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < B.length - 1; i++) {
            int limit = Math.min(B[i], B[i + 1]);
            sum += limit;
        }
        System.out.println(sum);
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

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

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int n1,n2,res=1000;
	n1=s.length();
	n2=t.length();
	for(int i=0;i<=n1-n2;i++){
		//cout<<"IN the loop\n";
		int j=0,count=0;
		while(j < n2){
			//printf("%d ",i+j);
			if(s[i+j]!=t[j])
				count++;
			j++;
		}
		//printf("\n");
		res=min(res,count);
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e3 + 10;
int n, x, y;
int ans[maxn];
int main()
{
	scanf("%d%d%d", &n, &x, &y);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
		{
			int ret;
			if(j <= x || i >= y) ret = j - i;
			else if(i <= x && j >= y) ret = x - i + j - y + 1;
			else if(i >= x && j <= y) ret = min(j - i, (y - x + 1) - (j - i));
			else if(i <= x && j <= y) ret = x - i + min(j - x, (y - x + 1) - (j - x));
			else if(i >= x && j >= y) ret = j - y + min(y - i, (y - x + 1) - (y - i));
			else { while(1);}
			ans[ret]++;
		}
	for(int i = 1; i < n; ++i)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 256
from array import array

ar = array('I', [
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
    1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
])

print(ar[int(input()) - 1])


Measured memory_bytes: 2940
<?php
fscanf(STDIN, '%d', $N);
$A = array_filter(explode(' ', trim(fgets(STDIN))), 'solved');
function solved($x) {
    $x = intval($x);
    
    return $x % 2 === 0 && ($x % 3 !== 0 && $x % 5 !== 0);
}
echo $A ? 'DENIED' : 'APPROVED';


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
#define mp make_pair
using namespace std;

int main(){

int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int k;
cin>>k;

cout<<a[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
    int n,*num;
    cin >> n;
    num = new int[n];
    
    for(int ii=n-1;ii >= 0;ii--){
        cin >> num[ii];
    }
    
    for(int ii=0;ii<n;ii++){
        cout << num[ii];
        if(ii < n - 1){
            cout << " ";
        }
    }
    
    cout << endl;
    return 0;
}
               

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int H, W;
    cin >> H >> W;
    char s[H][W];
    bool can = true;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                if (i > 0 && s[i-1][j] == '#') continue;
                if (i < H-1 && s[i+1][j] == '#') continue;
                if (j < W-1 && s[i][j+1] == '#') continue;
                if (j > 0 && s[i][j-1] == '#') continue; 
                can = false;
            }
        }
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)
		cin >> s[i];

	sort(s.begin(), s.end());

	int max = 1;
	int current = 1;
	string cur = s[0];
	vector<int> ind;
	for (int i = 1; i < n; i++) {
		if (s[i] == cur)
			current++;
		else {
			if(current > max){
				ind.clear();
				ind.emplace_back(i - 1);
				max = current;
			}
			else if (current == max){
				ind.emplace_back(i - 1);
			}
			current = 1;
			cur = s[i];
		}
	}

	if (current > max) {
		ind.clear();
		ind.emplace_back(n - 1);
		max = current;
	}
	else if (current == max) {
		ind.emplace_back(n - 1);
	}

	for (int i = 0; i < ind.size(); i++) {
		cout << s[ind[i]] << endl;
	}

	return 0;
}


Measured memory_bytes: 15224
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string str;
	cin >> str;
	int sz = 2019, zer = 0;
	vector<int> frq(sz);
	ll ans = 0;
	for(auto el: str) {
		el -= '0';
		vector<int> nw(sz);
		for(int i = 0; i < sz; i++)
			nw[((sz + i - zer)* 10 + zer)% sz] = frq[i];
		frq = nw;
		frq[(zer ) % sz]++;
		zer = (sz + zer - el) % sz;
		ans += frq[zer];
	}
	cout << ans << '\n';
}



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

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL);
  return x;
}

using P = pair<int, int>;

int n;
vector<P> res;

bool solve();

int main() {
  cin >> n;
  if (solve()) {
    cout << "Yes" << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
  } else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  int len = (n + 1) / 4 * 4, id = -1;
  if (n < 3 || (n % 4 == 0 && popcount(len) == 1)) return 0;
  vector<int> v(1, len - 1);
  for (int i = len - 2, now = 0; i >= 1; --i) {
    if (now < 0 && i != 1 && i != 3)
      v.push_back(i);
    else if (now >= 0) {
      now ^= i;
      v.push_back(i);
      if (now == len) {
        id = i;
        now = -1;
        v.push_back(1);
        v.push_back(3);
      }
    }
  }
  for (int i = 1; i < len - 1; ++i) res.emplace_back(v[i - 1], v[i]);
  res.emplace_back(v[len - 2], v[0] + n);
  for (int i = 1; i < len - 1; ++i) res.emplace_back(v[i - 1] + n, v[i] + n);
  if (popcount(len) == 1) {
    if (n % 4 == 1) {
      res.emplace_back(n - 1, n);
      res.emplace_back(2 * n - 1, 2 * n);
      res.emplace_back(1, n - 1);
      res.emplace_back(n + 1, 2 * n);
    }
    if (n % 4 == 2) {
      res.emplace_back(2, len + n);
      res.emplace_back(2 + n, len + 2);
      res.emplace_back(len + 2, len);
      res.emplace_back(len + 2, len + 1);
      res.emplace_back(1 + n, len + 1 + n);
      res.emplace_back(len + 1 + n, len + 2 + n);
    }
  } else {
    if ((n + 1) % 4 > 0) {
      res.emplace_back(len - 2, len);
      res.emplace_back(id, len + n);
    }
    if ((n + 1) % 4 > 1) {
      res.emplace_back(len - 2, len + 1);
      res.emplace_back(1, len + 1 + n);
    }
    if ((n + 1) % 4 > 2) {
      res.emplace_back(len - 2, len + 2);
      res.emplace_back(3, len + 2 + n);
    }
  }
  return 1;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i;
	cin>>n;
	int a[n+1];
	REP(i,1,n) cin>>a[i];
	int ans=0;
	REP(i,1,n){
		if(i&1&&a[i]&1) ans++;
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
 
#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
 
typedef pair<ll, ll> P;
 
const int MAX = 2000005;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
int x, y;
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
vector<bool> isUsed(100001, false);
 
int main(){
    COMinit();
    int n;
    cin >> n;
    vector<int> a(n+1);
    int left, right;
    int value;
 
    REP(i, n+1) {
        cin >> a[i];
        if(isUsed[a[i]]) {
            value = a[i];
            break;
        }
        isUsed[a[i]] = true;
    }
 
    REP(i, n+1) {
        if(a[i] == value) {
            left = i+1;
            break;
        }
    }
 
    REPN(i, left, n+1) {
        if(a[i] == value) {
            right = i+1;
            break;
        }
    }
    
    //cout << right << " " << left << endl;
 
    REPN(i, 1, n+2) {
        ll tmp = COM(n+1, i) - COM(n-(right-left), i-1);
        tmp += MOD;
        tmp %= MOD;     
        cout << tmp << endl;
    }
 
    
    return 0;
}

Measured memory_bytes: 48512
#include <stdio.h>

int main(void)
{
	int ball[10], N, B, C, tmp,i, j;

	scanf("%d", &N);
	for (i = 0; i<N; i++) {
		scanf("%d %d %d %d %d %d %d %d %d %d",
			&ball[0], &ball[1], &ball[2], &ball[3], &ball[4],
			&ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);
		B = 11; C = 11;
		for (j = 9; j >= 0; j--) {
			if (B>ball[j]) B = ball[j];
			else if (C>ball[j]) C = ball[j];
			else break;
			if (B>C) { tmp = B; B = C; C = tmp; }
		}
		if (j == -1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a = I()
    b = I()
    if a > b:
        return 'GREATER'
    if a < b:
        return 'LESS'

    return 'EQUAL'

print(main())


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

using namespace std;
using ll = long long;
template <class Type>
struct KMP
{
    vector<Type> s, w;
    KMP(vector<Type> s, vector<Type> w):s(s),w(w){}
    vector<int> T;//次の照合位置

    void KMP_table(){
        int j = 2;
        int k = 0;
        T.push_back(-1);
        T.push_back(0);
        while (j <= w.size())
        {
            if (w[j-1] == w[k]){
                T.push_back(k+1); j++; k++;
            }
            else if (k > 0)k = T[k];
            else {
                T.push_back(0); j++;
            }
        }
    }
    //wと一致するsの部分文字列の先頭のインデックスを全て求める
    vector<Type> kmp_search() {
        int m = 0;//s内の照合開始位置
        int i = 0;//w内の現在位置
        vector<Type> ReturnValue;//返り値
        while (m+i < s.size()) {
            if (w[i] == s[m+i]) {
                i++;
                if (i == w.size()) {
                    ReturnValue.push_back(m);
                    m = m+i-T[i];
                    if (i > 0)i = T[i];
                }
            }
            else{
                m = m+i-T[i];
                if (i > 0)i = T[i];
            }
        }
        return ReturnValue;
    }
};

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a, b, c, d, x;
    for (int i = 0; i < N; i++) {
        int ai; cin >> ai;
        a.push_back(ai);
    }
    for (int i = 0; i < N; i++) {
        int bi; cin >> bi;
        b.push_back(bi);
    }
    for (int i = 0; i < N; i++){
        x.push_back(b[0] ^ a[i]);
    }
    for (int i = 0; i < N; i++){
        c.push_back(a[i] ^ a[(i+1) % N]);
        d.push_back(b[i] ^ b[(i+1) % N]);
    }
    for (int i = 0; i < N-1; i++){
        c.push_back(c[i]);
    }
    KMP<int> kmp = KMP<int>(c, d);
    kmp.KMP_table();
    vector<int> ans = kmp.kmp_search();
    for (int i : ans)cout << i << " " << x[i] << endl;
}

Measured memory_bytes: 13436
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a=0,b=0;
  	string s;
  	cin >>s;
  	for(int n=1;n<=s.size();n++){
      	if(a==0&&s[n]==s[n-1]) a++,n++;
      else a=0;
      	b++;
    }
  	cout <<b<<'\n';
  	return (0);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int N,flag=0;
      string S;
      cin >> N >> S;
      if (N%2==1) flag = 1;
      else{
        for (int i = 0; i < N/2; i++)
        {
          if (S[i] != S[N/2 + i])
          {
            flag = 1;
            break;
          }
        }

      }            
      if (flag == 0) cout << "Yes";
      else cout << "No";

     }

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
  int a[N];
  int i,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i--;i>=0;i--){
    printf("%d",a[i]);
    if(i)putchar(' ');
    else putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll n,k;
    cin>>n>>k;
    ll x,y,i,ans=0,z;
    for(i=0;i<n;i++){
        cin>>x>>y;
        z=sqrt(x*x + y*y);
        if(z<k) ans++;
        else if(z==k && z*z==(x*x + y*y)) ans++;
    }
    cout<<ans<<endl;
  
return 0;
    
 }  

Measured memory_bytes: 3696
n, m = gets.split.map(&:to_i)
goods = gets.split.map(&:to_i)
votes = goods.inject(:+)
popular_goods = []

def judge(target, sum, m)
  if target >= sum.to_f / (4 * m)
    1
  else
    0
  end
end

goods.each do |good|
  popular_goods.push(judge(good, votes, m))
end

if popular_goods.inject(:+) >= m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
def main():
    S = input()
    N = len(S)

    minimum_t = 100000000
    pre_letter = S[0]

    for idx in range(1, N):
        if S[idx] != pre_letter:
            minimum_t = min(max(idx, N-idx), minimum_t)
            pre_letter = S[idx]
        else:
            continue

    if minimum_t == 100000000:
        print(N)
    else:
        print(minimum_t)

main()


Measured memory_bytes: 3188
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define MAXN 50001
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
#define int ll
const int inf = 0x3f3f3f3f;
int n,m;
struct po
{
	int x,y,id;
}a[1000001],b[1000001];
int maxx=-999999,vis[1000001],pos,maxl=-9999999,minr=9999999,maxr=-9999999,minl=99999999;
int ans;
inline bool cmp(po a,po b)
{
	return a.y==b.y?a.x<b.x:a.y<b.y;
}
inline bool cmp1(po a,po b)
{
	return a.x==b.x?a.y>b.y:a.x>b.x;
}
main() 
{
    cin>>n;
    for(re int i=1;i<=n;i++){
    	cin>>a[i].x>>a[i].y;
    	b[i].x=a[i].x;b[i].y=a[i].y;
    	b[i].id=a[i].id=i;
    	maxl=max(maxl,a[i].x);
    	maxr=max(maxr,a[i].y);
    	minl=min(maxr,a[i].x);
    	minr=min(minr,a[i].y);
    }
    sort(a+1,a+n+1,cmp);
    sort(b+1,b+n+1,cmp1);
    if(maxl>=0&&maxl<=minr){
    	cout<<maxl*2;
    	return 0;
	}
	if(maxr<=0&&maxl<=minr){
		cout<<abs(maxl*2);
		return 0;
	}
    if(minr>=0&&maxl<=0) {
    	cout<<0;
    	return 0;
	}
	int i=1,j=1,l=1,lasti=1,lastj=1;
    ans=abs(b[j].x);pos=b[j].x;
    while(1){
		if(l==1){
			if(b[j].x<=a[lasti].y) break;
			ans+=abs(b[j].x-pos);
    		pos=b[j].x;
    		lastj=j;
    		vis[b[j].id]=1;
    		j++;
    		while(vis[b[j].id]) j++;
		}else{
			if(b[lastj].x<=a[i].y) break;
			ans+=abs(a[i].y-pos);
			pos=a[i].y;
			vis[a[i].id]=1;
			lasti=i;
			i++;
			while(vis[a[i].id]) i++;
		}
		l^=1;
	}
	ans+=abs(pos-0);
	maxx=ans;
	memset(vis,0,sizeof(vis));
	i=1,j=1,l=0,lasti=1,lastj=1;
	ans=abs(a[i].y);pos=a[i].y;
	while(1){
		if(l==1){
			if(b[j].x<=a[lasti].y) break;
			ans+=abs(b[j].x-pos);
    		pos=b[j].x;
    		lastj=j;
    		vis[b[j].id]=1;
    		j++;
    		while(vis[b[j].id]) j++;
		}else{
			if(b[lastj].x<=a[i].y) break;
			ans+=abs(a[i].y-pos);
			pos=a[i].y;
			vis[a[i].id]=1;
			lasti=i;
			i++;
			while(vis[a[i].id]) i++;
		}
		l^=1;
	}
	ans+=abs(pos-0);
	maxx=max(maxx,ans);
	cout<<maxx;
    return 0;
}
/*
2
-100 -50 
-20 -10
*/

Measured memory_bytes: 14592
use std::collections::*;
use std::*;
// template {{{
macro_rules ! get {($ ($ t : tt ) ,*; $ n : expr ) => {{let stdin = std :: io :: stdin () ; let ret = std :: io :: BufRead :: lines (stdin . lock () ) . take ($ n ) . map (| line | {let line = line . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } ) . collect ::< Vec < _ >> () ; ret } } ; ($ ($ t : tt ) ,* ) => {{let mut line = String :: new () ; std :: io :: stdin () . read_line (& mut line ) . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } } ; }
macro_rules ! _get {($ it : ident ; [char ] ) => {_get ! ($ it ; String ) . chars () . collect ::< Vec < _ >> () } ; ($ it : ident ; [u8 ] ) => {_get ! ($ it ; String ) . bytes () . collect ::< Vec < _ >> () } ; ($ it : ident ; usize1 ) => {$ it . next () . unwrap () . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 } ; ($ it : ident ; [usize1 ] ) => {$ it . map (| s | s . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 ) . collect ::< Vec < _ >> () } ; ($ it : ident ; [$ t : ty ] ) => {$ it . map (| s | s . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) ) . collect ::< Vec < _ >> () } ; ($ it : ident ; $ t : ty ) => {$ it . next () . unwrap () . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) } ; ($ it : ident ; $ ($ t : tt ) ,+ ) => {($ (_get ! ($ it ; $ t ) ) ,* ) } ; }
// }}}

fn main() {
    let n = get!(i32);
    let mut ans = 0;
    for a in 1..n {
        for b in 1..=(n / a) {
            let c = n - a * b;
            if c > 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  string s;
  cin >> s;
  REP(i,sz(s)) {
    if (s[i] == 'C') {
      for (int j = i+1; j < sz(s); j++) {
        if (s[j] == 'F') {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    vector<ll> a(n+1,0);    
    for(int i=0;i<n;i++)    
        cin>>a[i+1];
    ll ans = 0;
    ll suf = 0;
    for(int i=n-1;i>0;i--)
    {
        suf+=a[i+1];
        suf%=MOD;
        ans += (a[i]*1ll*suf)%MOD;
    }
    ans%=MOD;
    
    cout<<ans<<'\n';
    
    return 0;
}



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


int main()
{
	int A,B,C,D;
	int S, X;

	cin >> A >> B >> C >> D;
	
	S = A * B;
	X = C * D;
	if (S > X) {
		cout << S << endl;
	}
	else if (X > S) {
		cout << X << endl;
	}
	else
		cout << S << endl;

	return 0;
}

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

using namespace std;

bool solve(const std::vector<int>& as) { return true; }

int main() {
  int n;
  std::cin >> n;
  int odd = 0;
  int a;
  while (std::cin >> a) {
    odd += a % 2;
  }
  std::cout << (odd % 2 ? "NO" : "YES") << std::endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

N, M = map(int,input().split())

abList = []
for i in range(N):
    a,b = map(int,input().split())
    abList.append((a,b))

abList.sort(key=lambda x:x[0])

cost = 0
for a, b in abList:
    if M > b:
        cost += a*b
        M -= b
    else:
        cost += M*a
        break
print(cost)

Measured memory_bytes: 18184
/*input
5
1 2
2 3
1 4
4 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

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

vector<int> edge[maxn];
bool vis[maxn];
int dfs(int u){
	vis[u]=1;
	int ret=0;
	for(int v:edge[u]) if(!vis[v]){
		ret^=1+dfs(v);
	}
	return ret;
}

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n-1){
		int u,v;
		cin>>u>>v;
		u--;v--;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	if(dfs(0)) cout<<"Alice\n";
	else cout<<"Bob\n";

	return 0;
}


Measured memory_bytes: 15232
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 2e5 + 10;
int freq[N], p[N];
int n, m;

int par(int u) {
  return p[u] == u ? u : p[u] = par(p[u]);
}

void join(int u , int v) {
  p[par(u)] = par(v);
  return;
}

bool sameset(int u , int v) {
  return par(u) == par(v);
}

int main() {
  in(n); in(m);
  for (int i = 1 ; i <= n ; i++) p[i] = i;
  for (int i = 0, u, v ; i < m ; i++) {
    in(u); in(v);
    join(u , v);
  }
  for (int i = 1 ; i <= n ; i++) {
    freq[par(i)]++;
  }
  int sol = -1;
  for (int i = 1 ; i <= n ; i++) {
    sol = max(sol , freq[par(i)]);
  }
  printf("%d\n" , sol);
  return 0;
}

void in(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 10524
#include<iostream>

int main(void)
{
	int x;
	int min=10000;

	int sigma = 0; 
	int N, X; // ドーナツの種類

	std::cin >> N >> X;

	for(int i=0; i<N; i++)
	{
		std::cin >> x;
		sigma += x;
		if(min > x) min = x;
	}

	std::cout << N + (X - sigma)/min << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll dp[110000];
ll a[110000];
	

int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("/home/shubham/Desktop/codes/input.txt", "r", stdin);
	freopen("/home/shubham/Desktop/codes/output.txt", "w", stdout);
	#endif*/
	ll n;
	cin>>n;
	for (ll i=0; i<n; i++){
		cin>>a[i];
		dp[i] = mod;
	}
	dp[0] = 0;
	for(ll i=0; i<n; i++){
		if(i+1<n){
			dp[i+1] = min(dp[i+1], (dp[i]+abs(a[i]-a[i+1])));
		}
		if(i+2<n){
			dp[i+2] = min(dp[i+2], (dp[i]+abs(a[i]-a[i+2])));
		}
	}
	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1792
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    int n,m;
    int A[2021]= {0}; //1~2019とさいご
    int B[2021]= {0};
    cin >> n;
    REP(i,n){
        int x;
        cin>>x;
        B[i+1]= x; //ここに入ってる
        A[x]=1;
    } 
    A[2020]=1;
    cin >> m;
    REP(i,m){
        int x;
        cin >> x;
        // cout << A[B[x]] << endl;
        swap(A[B[x]],A[B[x]+1]);
        if(A[B[x]]==0) B[x]++;

  
    }
    REP(i,2020){
        if(A[i]==1){
            cout << i << endl;
        } 
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const int N = 100050;

int a[N], n, s[17], f[1 << 15], siz[1 << 15];
int XOR_S[1 << 15], ans, zt, rev[N];
int main()
{

	int i, j, k, h;
	scanf("%d", &n);
	for(i = 1; i < n; i ++){
		scanf("%d%d%d", &j, &k, &h);
		j ++, k ++, a[j] ^= h, a[k] ^= h;
	}
	for(i = 1; i <= n; i ++)
		s[a[i]] ++;
	for(i = 1; i <= 15; i ++){
		ans += s[i] >> 1, rev[1 << i - 1] = i;
		zt |= (s[i] & 1) << i - 1;
	}
	for(i = 1; i < 1 << 15; i ++){
		XOR_S[i] = XOR_S[i - (i & -i)] ^ rev[i & -i];
		siz[i] = siz[i - (i & -i)] + 1;
	}
	for(i = 1; i <= zt; i ++){
		f[i] = 1000000000;
		for(j = i; j; j = (j - 1) & i)
			if(XOR_S[j] == 0)
				f[i] = min(f[i], f[i - j] + siz[j] - 1);
	}
	printf("%d", f[zt] + ans);

	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

row,col = map(int, input().split())

cells = []

for r in range(row):
    temp_col = list(map(int, input().split()))
    temp_col.append(sum(temp_col))
    cells.append(temp_col)

cells.append([0] * (col + 1))
for c in range(col + 1):
    for r in range(row):
        cells[row][c] += cells[r][c]

for r in range(row+1):
    print(' '.join(map(str, cells[r])))

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int sum1=0;
    int sum2=0;
  for(int i=0;i<n;i=i+2){
  	sum1+=a[i];
  }
  for(int i=1;i<n;i=i+2){
  	sum2+=a[i];
  }
  
  cout << sum1-sum2 << endl;

}


Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <limits.h>
using namespace std;
 
int main() {
    int n,r;
    int min = INT_MAX, ans=INT_MIN;
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> r;
        if(r-min>ans) ans= r-min;
        if(r<min) min =r;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i, m) {
        int k;
        cin >> k;
        s[i].resize(k);
        rep(j, k) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(bit, 1 << n) {
        bool ok = 1;
        rep(i, m) {
            int cnt = 0;
            for (int x : s[i])
                if (bit & (1 << x)) cnt++;
            ok &= (cnt % 2 == p[i]);
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = collections.Counter(prime_factorize(n))
ans = 0
for p_num in c.values():
    i = 0
    tmp = 0
    while True:
        i += 1
        tmp += i
        if p_num < tmp:
            break
    ans += i - 1
print (ans)


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

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

    if(N % 2 == 0) cout << setprecision(10) << 1 / (double)2 << endl;
    else cout << setprecision(10) << ((N + 1) / (double)2) / (double)N << endl;

    return 0;
}

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

using namespace std;
#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	
;	vector<int>smallera(n, 0);//b[i]より小さいaの個数
	vector<int>smallerb(n, 0);//c[i]より小さいbの個数
	int itera = 0;
	rep(i, n) {
		if (i != 0)smallera[i] = smallera[i - 1];
		while (itera<=n-1 && b[i] > a[itera]) {
			smallera[i]++;
			itera++;
		}
	}
	int iterb = 0;
	rep(i, n) {
		if (i != 0)smallerb[i] = smallerb[i - 1];
		while (iterb<=n-1 && c[i] > b[iterb]) {
			smallerb[i]+=smallera[iterb];
			iterb++;
		}
	}
	int ret = 0;
	rep(i, n) {
		ret += smallerb[i];
	}
	print(ret);
}

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

typedef pair<long long, long long> data_t;

int main(){
  int n,m;
  cin>>n>>m;
  vector<data_t> data_array(n);
  int a,b;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    data_array[i].first=a;
    data_array[i].second=b;
  }
  sort(data_array.begin(),data_array.end());
  long long count=0,sum=0;
  for(int i=0;i<n;i++){
    count+=data_array[i].second;
    sum+=data_array[i].first*data_array[i].second;
    if(count>m){
      int dif=count-m;
      sum-=data_array[i].first*dif;
      break;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    if(s[0]=='9' or s[1]=='9') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include<algorithm>
#define ll long long
using namespace std;

int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> x(N + 1);
  for(ll i = 0; i < N; i++) cin >> x.at(i);
  x.at(N) = X;
  sort(x.begin(), x.end());
  ll gcddist = x.at(1) - x.at(0);
  for(ll i = 2; i < N + 1; i++) gcddist = __gcd(gcddist, x.at(i) - x.at(i - 1));
  cout << gcddist << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    ll a[100];

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

    ll alice = 0, bob = 0;
    for (int j = 0; j < N; ++j)
    {
        if (j % 2 == 0)
        {
            alice += a[j];
        }
        else
        {
            bob += a[j];
        }
    }
    cout << alice - bob << endl;

    return 0;
}

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

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

  res = s;
  for(int i=0;i<n;i++){
    if(d==0)break;
    if(s[i] == '0'){
      res[i] = '1';
      d--;
    }
  }

  for(int i=n-1;i>=0;i--){
    if(d==0)break;
    if(s[i] == '1'){
      res[i] = '0';
      d--;
    }
  }

  cout << res << endl;
}
    

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    char s;
    cin >> s;
    if('A' <= s and s < 'A' + 26)
        cout << "A" << en;
    else
        cout << "a" << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

int const N = 51;
pii edge[N][N];
pii c[N];
int const inf = 1e18;
int dist[N][3000];
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m, s;
    cin >> n >> m >> s;
    for(int i = 0; i < m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        edge[u][v] = {a, b};
        edge[v][u] = {a, b};
    }
    for(int i = 1; i <= n; ++i){
        cin >> c[i].first >> c[i].second;
        for(int j = 0; j <= 2510; j++){
            dist[i][j] = inf;
        }
    }
    s = min(s, 2500ll);
    dist[1][s] = 0;
    priority_queue<pair<pii, int>, vector<pair<pii, int>>, greater<pair<pii, int>>> q;
    q.push({{dist[1][s], s}, 1ll});
    while(q.size()){
        auto p = q.top();
        q.pop();
        int v = p.second;
        int s_left = p.first.second;
        int distance = p.first.first;
        if(s_left >= 2501) continue;
        if(dist[v][min(2501ll, c[v].first + s_left)] > distance + c[v].second) {
            dist[v][min(2501ll, c[v].first + s_left)] = distance + c[v].second;
            q.push({{distance + c[v].second, c[v].first + s_left}, v});
        }
        for(int i = 1; i <= n; i++) {
            if(edge[v][i].first > 0 && edge[v][i].second > 0){
                int costed = distance + edge[v][i].second;
                int reqd = s_left - edge[v][i].first;
                if(reqd < 0) continue;
                if(dist[i][reqd] > costed) {
                    dist[i][reqd] = costed;
                    q.push({{costed, reqd}, i});
                }
            }
        }
    }
    for(int i = 2; i <= n; i++){
        cout << *min_element(dist[i], dist[i] + 2509) << endl;
    }
    return 0;
}


Measured memory_bytes: 7464
from itertools import accumulate as ac
N,K=map(int,input().split())
n=int(N**0.5)
mod=10**9+7
list_a=[1]*n
list_b=[N//j-N//(j+1) for j in range(1,n)]+[(N//n-n)]
list_p=[p for p in list_b]
list_aa=list(ac(list_a))
list_bb=list(reversed(list(ac(reversed(list_b)))))

for i in range(K-1):
    temp=sum(list_a)
    list_a=[(temp+list_bb[j])%mod for j in range(n)]
    list_b=[(list_p[j]*list_aa[j])%mod for j in range(n)]
    list_aa=list(ac(list_a))
    list_bb=list(reversed(list(ac(reversed(list_b)))))
    
print((sum(list_a+list_b))%mod)

Measured memory_bytes: 11600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int a,b;
    cin >> a >> b;
    if(a >9||b>9){
        cout << -1 << endl;
    } else {
        cout << a*b << endl;
    }
    return 0;
}

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

int main() {
  long n,k,ans=0;
  cin >> n >> k;
  vector<long> p(n);
  for(long i=0;i<n;i++) cin >> p[i];
  sort(p.begin(),p.end());
  for(long i=0;i<k;i++) {
    ans+=p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int A,B,C,D,L,R;
    cin >> A >> B >> C >> D;
    L = A + B;
    R = C + D;
    if(L == R){
        cout << "Balanced" << endl;
    }else
    {
        if (L > R)
        {
            cout << "Left" << endl;
        }else
        {
            cout << "Right" << endl;
        }
        
        
    }
    return 0;
}

Measured memory_bytes: 3036
#include<iostream>
using namespace std;
int main() {
  string c;
  cin >> c;
  if(c == "a" || c == "e" || c == "i" || c == "o" || c == "u") {
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100005];
int dp[100005],vis[100005];
int dfs(int x)
{
  if(vis[x]==1)
  return dp[x];
  vis[x]=1;
  int j=0;
  for(auto i : v[x])
  {
    j=max(j,dfs(i)+1);
  }
  dp[x]=j;
  return j;

}
int main()
{
  int i,n,a,b,m;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
  }
  b=0;
  for(i=0;i<n;i++)
  {
    b=max(b,dfs(i));
  }
  cout<<b;
}


Measured memory_bytes: 8576