akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define mod 1000000007

template<typename T>
T fastexpo(T x, T y)
{
	T res = 1;
	while(y > 0)
	{
		if(y&1) res *= x;
		x *= x;
		y >>= 1;
	}
	return res;
}

template<typename T>
T modpower(T x, T y, T m=mod)
{
	x %= m;
	T res = 1;
	while(y > 0)
	{
		if(y&1) res = (res*x)%m;
		x = (x*x)%m;
		y >>= 1;
	}
	return res;
}


int main()
{
	FASTIO
	int n, k, d, a;
	cin >> n >> k;
	vi snukes(n,0);
	rep(i,0,k)
	{
		cin >> d;
		rep(j,0,d)
		{
			cin >> a;
			snukes[a-1] = 1;
		}
	}
	cout << count(snukes.begin(), snukes.end(), 0) << "\n";
	return 0;
}

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

#define MAX_N 3000
typedef long long int ll;

int n;
ll a[MAX_N];

ll dp[MAX_N + 1][MAX_N + 1];

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

  for(int i = 0; i <= n; ++i) {
    dp[i][i] = 0;
  }
  for(int len = 1; len <= n; ++len) {
    for(int i = 0; i + len <= n; ++i) {
      int j = i + len;
      if((n - len) % 2 == 0) {
        dp[i][j] = std::max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
      } else {
        dp[i][j] = std::min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
      }
    }
  }

  std::cout << dp[0][n] << std::endl;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n;
	cin>>n;
	cout<<n*2/__gcd(2,n);
}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int arr[10], i, j;
	
	for(i=0;i<10;i++)
	scanf("%d", &arr[i]);
	
	for(i=0;i<10;i++){
		for(j=9;i<j;j--){
			int temp;
			if(arr[j-1]<arr[j]){
				temp=arr[j-1];
				arr[j-1]=arr[j];
				arr[j]=temp;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n", arr[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])ans++;
	}
	cout << ans;
}

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

int gcd(int a,int b){
    int r = a % b;
    cout << r << endl;
    if (r == 0)return b;
    return gcd(b,r);
}

int main(){
    int a,b;
    string ans = "Negative";
    cin >> a >> b;
    if(a+b == 0)ans = "Zero";
    else if(a >= 0)ans = "Positive";
    else if(b < 0){
        if ((abs(b-a) + 1) % 2 == 0)ans = "Positive";
    }
    else{
        if(abs(a) % 2 == 0)ans = "Positive";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
S=input()
L=deque()
for s in S:
    if s=='S':
        L.append('S')
    else:
        if len(L)==0 or L[-1]=='T':
            L.append('T')
        elif L[-1]=='S':
            L.pop()
    #print(L)
print(len(L))

Measured memory_bytes: 41820
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    k = int(stdin.readline().rstrip())
    s = str(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if len(s) <= k:
        print(s)
    else:
        print(s[0:k] + "...")

main()


Measured memory_bytes: 9180
N,A,B = map(int,input().split())
X = list(map(int,input().split()))

Ans = 0
for i in range(1,N):
    if (X[i]-X[i-1])*A >= B:
        Ans += B
    else:
        Ans += (X[i]-X[i-1])*A

print(Ans)

Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

int string_continuous_number(string s){int res = 1 , tmpn = 1;char tmpc = s[0];FOR(i,1,s.size()){if(s[i]==tmpc){tmpn++;}else{tmpn=1; tmpc=s[i];}chmax(res,tmpn);}return res;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    int ans = string_continuous_number(s);
    Yn(ans>=3);

    return 0;
}

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

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    if (a == b) {
        std::cout << c << std::endl;
    } else if (b == c) {
        std::cout << a << std::endl;
    } else {
        std::cout << b << std::endl;
    }
}


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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)
#define Cor(i,l,r) for (int i = l; i >= r; --i)

const int MD = 1000000007;

int iPow(int x, int y) {
	int ret = 1;
	for (int j = y; j; j >>= 1) {
		if (j & 1) {
			ret = (long long)ret * x % MD;
		}
		x = (long long)x * x % MD;
	}
	return ret;
}

int n, A[111111], B[111111];
int main() {
	cin >> n;
	For(i,1,n) scanf("%d", &A[i]);
	For(i,1,n) scanf("%d", &B[i]);
	int peak = 0;
	For(i,1,n) peak = max(peak, max(A[i], B[i]));
	int l = -1, r = -1;
	For(i,1,n) {
		if (A[i] == peak && l == -1) {
			l = i;
		}
		if (B[i] == peak) {
			r = i;
		}
	}
	
	if (l == -1 || r == -1 || l > r) {
		puts("0");
		return 0;
	}
		
	int ans = 1;
	if (l + 1 < r) ans = iPow(peak, r - l - 1);
	For(i,1,l - 1) {
		int t = i;
		while (t < l && A[t + 1] == A[t]) ++t;
		ans = (long long)ans * iPow(A[i], t - i) % MD;
		i = t;
	}
	Cor(i,n,r + 1) {
		int t = i;
		while (t > r && B[t - 1] == B[t]) --t;
		ans = (long long)ans * iPow(B[i], i - t) % MD;
		i = t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll a, b, m;
    cin >> a >> b >> m;
    ll aa[a], bb[b], x[m], y[m], cc[m];
    rp(i, 0, a) cin >> aa[i];
    rp(i, 0, b) cin >> bb[i];
    rp(i, 0, m) cin >> x[i] >> y[i] >> cc[i];
    ll ans = inf;
    rp(i, 0, m)
    {
        ans = min(ans, aa[x[i] - 1] + bb[y[i] - 1] - cc[i]);
    }
    sort(aa, aa + a);
    sort(bb, bb + b);
    ans = min(ans, aa[0] + bb[0]);
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q,a[1000009],x;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    long long jum=0;
    for(int i=1; i<=n; i++){
    	for(int j=i+1; j<=n; j++){
    		jum+=lower_bound(a+j+1,a+n+1,a[i]+a[j])-a-j-1;
    	}
    }
    cout << jum << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := SScan(n)
	ab, a, b, c := 0, 0, 0, 0
	for _, v := range s {
		for i := 0; i < len(v)-1; i++ {
			if v[i:i+2] == "AB" {
				ab++
			}
		}
		if string(v[0]) == "B" {
			b++
		}
		if string(v[len(v)-1]) == "A" {
			a++
		}
		if string(v[0]) == "B" && string(v[len(v)-1]) == "A" {
			c++
		}
	}
	ans := ab + smaller(a, b)
	if a == c && b == c && c != 0 {
		ans--
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2012
while True:
    h = int(input())
    if h == 0:
        break
    else:
        stones_list = []
        for i in range(h):
            stones = list(map(int, input().split()))
            stones_list.append(stones)
        flag = 0
        point = 0
        while True:
            for i in range(h):
                cnt = 1
                num = stones_list[i][0]
                for j in range(1, 5):
                    if num == stones_list[i][j] and num != 0:
                        cnt += 1
                        if cnt >= 3 and j == 4:
                            point += num * cnt
                            flag = 1
                            for k in range(5-cnt, 5):
                                stones_list[i][k] = 0
                    else:
                        if cnt >= 3:
                            point += num * cnt
                            flag = 1
                            for k in range(j-cnt, j):
                                stones_list[i][k] = 0
                        num = stones_list[i][j]
                        cnt = 1
            for i in range(h-1, -1, -1):
                for j in range(5):
                    for k in range(i, h-1):
                        if stones_list[k+1][j] == 0:
                            stones_list[k+1][j] = stones_list[k][j]
                            stones_list[k][j] = 0
                        else:
                            break
            if flag == 0:
                print(point)
                break
            else:
                flag = 0



Measured memory_bytes: 5628
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int a,b,c,n;

int main(){
	while(1){
		cin>>a>>b>>c;
		if(!a&&!b&&!c) return 0;
		cin>>n;
		vvi A(3);
		vi ans(a+b+c,-1);
		set<int> st;
		int x,y,z,t;
		for(int i=0;i<n;i++){
			cin>>x>>y>>z>>t;
			if(!t){
				A[0].push_back(x);
				A[1].push_back(y);
				A[2].push_back(z);
			}
			else{
				ans[x-1]=1;
				ans[y-1]=1;
				ans[z-1]=1;
				st.insert(x);
				st.insert(y);
				st.insert(z);
			}
		}
		for(int i=0;i<A[0].size();i++){
			vi tmp;
			for(int j=0;j<3;j++){
				if(st.find(A[j][i])==st.end()) tmp.push_back(A[j][i]);
			}
			if(tmp.size()!=1){
				for(int i=0;i<tmp.size();i++){
					if(ans[tmp[i]-1]!=0) ans[tmp[i]-1]=2;
				}
			}
			else ans[tmp[0]-1]=0;
		}
		for(auto i=ans.begin();i!=ans.end();i++){
			if(*i==-1) cout<<2<<endl;
			else cout<<*i<<endl;
		}
	}
}

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;


class Main {
	final static int SIZE = 10;
	final static int OUT = 3;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] heights = new int[SIZE];
		
		for(int i = 0; i < SIZE; i++){
			heights[i] = in.nextInt();
		}
		
		Arrays.sort(heights);
		
		for(int i = 0; i < OUT; i++){
			System.out.println("" + heights[SIZE - 1 - i]);
		}
	}

}

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

int main() {
	int A,B,C,D,P;
	cin >> A >> B >> C >> D >> P;
	int X=P*A;
	int Y=B+(P-C)*D;
	int S=P-C;
	if (S<=0){
		Y=B;
	}
	if(X<Y){
		cout << X << endl;
	}
	else cout << Y << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long

void foo(int n, double p1[2], double p2[2]){
	if(!n) return ;
	double th = M_PI * 60.0 / 180.0;
	double s[2] = {(p1[0]*2+p2[0])/3.0,(p1[1]*2+p2[1])/3.0}, t[2] = {(p1[0]+p2[0]*2)/3.0,(p1[1]+p2[1]*2)/3.0};
	double u[2] = {(t[0]-s[0])*cos(th) - (t[1]-s[1])*sin(th)+s[0], (t[0]-s[0])*sin(th) + (t[1]-s[1])*cos(th)+s[1]};
	foo(n-1,p1, s);
	printf("%.8f %.8f\n", s[0], s[1]);
	foo(n-1,s,u);
	printf("%.8f %.8f\n", u[0], u[1]);
	foo(n-1,u,t);
	printf("%.8f %.8f\n", t[0], t[1]);
	foo(n-1,t,p2);
}

signed main(){
	int n;
	double p1[2]={}, p2[2] ={100,0};
	cin>>n;
	printf("%.8f %.8f\n", p1[0], p1[1]);
	foo(n,p1,p2);
	printf("%.8f %.8f\n", p2[0], p2[1]);
	return 0;
}



Measured memory_bytes: 3156
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
sum_a = 0
for i in range(n):
    sum_a += A[i]
    temp = sum_a
    for j in range(i,n):
        temp += B[j]
    ans = max(ans,temp)

print(ans)

Measured memory_bytes: 9100
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const arr = input.split('\n')[1].split(' ');
for(let i = 0, len = arr.length; i < len / 2; i++){
	const init = arr[i]
	arr[i] = arr[len - (i + 1)];
	arr[len - (i + 1)] = init;
}
console.log(arr.join(' '));


Measured memory_bytes: 15344
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N, Q = read.nn()
local edges = {}
for i=1,N do
    edges[i] = {}
end
local insert = table.insert
for i=1,N-1 do
    local a, b = read.nn()
    insert(edges[a], b)
    insert(edges[b], a)
end
local q = {}
for i=1,N do
    q[i] = 0
end
for i=1,Q do
    local p, x = read.nn()
    q[p] = q[p] + x
end

local C = {}
for i=1,N do
    C[i] = 0
end
local function dfs_cps(node, prev, accum, cont)
    accum = accum + q[node]
    C[node] = accum
    local adjs = edges[node]
    local function make_cont(j)
        return function()
            local next = adjs[j]
            if next then
                if next ~= prev then
                    return dfs_cps(next, node, accum, make_cont(j+1))
                else
                    return make_cont(j+1)()
                end
            else
                return cont()
            end
        end
    end
    return make_cont(1)()
end
dfs_cps(1, -1, 0, function()
    print(table.concat(C, ' '))
end)

Measured memory_bytes: 227832
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;

int main(){
	while(true){
		int N, M;
		cin >> N >> M;
		if(N == 0 && M == 0){ break; }
		int r;
		cin >> r;
		vector< vector<pii> > logs(M + 1);
		for(int i = 0; i < r; ++i){
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			logs[m].push_back(pii(t, s * 2 - 1));
		}
		int q;
		cin >> q;
		for(int i = 0; i < q; ++i){
			int ts, te, m;
			cin >> ts >> te >> m;
			vector<int> integral(1300);
			for(int j = 0; j < logs[m].size(); ++j){
				integral[logs[m][j].first] += logs[m][j].second;
			}
			for(int j = 0, s = 0; j < 1300; ++j){
				s += integral[j];
				integral[j] = s;
			}
			int answer = 0;
			for(int j = ts; j < te; ++j){
				answer += min(integral[j], 1);
			}
			cout << answer << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1480
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, m, x; cin>>n>>m>>x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0; i<n; i++){
        cin>>c[i];
        for(int j=0; j<m; j++) cin>>a[i][j];
    }

    ll mi = INF;
    for(int bit=0; bit<(1<<n); bit++){
        ll ans = 0;
        vector<int> sum(m, 0);
        for(int i=0; i<n; i++){
            if(bit & (1 << i)){
                ans += c[i];
                for(int j=0; j<m; j++) sum[j] += a[i][j];
            }
        }

        bool valid = true;
        for(int i=0; i<m; i++){
            if(sum[i] < x) valid = false;
        }

        if(valid) chmin(mi, ans);
    }

    cout << (mi == INF ? -1 : mi) << endl;

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, z = 0;
    cin >> n;
    while (n--) cin >> a, z += __builtin_ctz(a);
    cout << z;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

template<int N, typename T, T M>
struct factorial_mod
{
	T mod[N + 1];
	T inv_mod[N + 1];

	constexpr factorial_mod() : mod(), inv_mod()
	{
		mod[0] = 1;
		for (int i = 0; i < N; ++i)
		{
			mod[i + 1] = (mod[i] * (i + 1)) % M;
		}
		inv_mod[N] = power(mod[N], M - 2);
		for (int i = N - 1; i >= 0; --i)
		{
			inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
		}
	}

	constexpr T power(T a, T b) const
	{
		T r = 1;
		while (b > 0)
		{
			if ((b & 1) != 0) r = (r * a) % M;
			a = (a * a) % M;
			b >>= 1;
		}
		return r;
	}

	constexpr T comb(T n, T r) const
	{
		if (r < 0 || r > n || n < 0) return 0;
		return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
	}

	constexpr T H(T n, T r) const
	{
		return comb(n + r - 1, r);
	}
};

constexpr long long MOD = 1000000007;
constexpr factorial_mod<500000, long long, MOD> fmod;

int main()
{
	long long n, k;
	scanf("%lld%lld", &n, &k);
	long long zeromax = std::min(n, k);
	long long ans = 0;
	for (long long i = 1; i <= zeromax; ++i)
	{
		long long room = n - i;
		long long nn = n - room;
		ans = (ans + fmod.comb(n, room) * fmod.H(room, nn)) % MOD;
	}
	if (k >= 2)
	{
		ans = (ans + 1) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
from collections import defaultdict

N, M = map(int, input().split())
H = list(map(int, input().split()))
L = [list(map(int, input().split())) for _ in range(M)]

a = [0] * N
d = defaultdict(int)
for i, v in enumerate(L):
    if (H[v[0] - 1] > H[v[1] - 1]):
        d[v[0]] += 1
        a[v[0] - 1] += 1
        a[v[1] - 1] += 1
    elif(H[v[0] - 1] < H[v[1] - 1]):
        d[v[1]] += 1
        a[v[0] - 1] += 1
        a[v[1] - 1] += 1
    else:
        a[v[0] - 1] += 1
        a[v[1] - 1] += 1
        continue
# print(a)
count = 0
for i, v in enumerate(a):
    if (v == 0):
        count += 1

for i, k in d.items():
    if (a[i - 1] == k):
        count += 1
print(count)


Measured memory_bytes: 37352
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/01/20 21:30:49
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k; cin >> k;
  vector<int> A(k); for (auto& a:A) cin >> a;
  long long ans_a, ans_b;
  auto solve = [&]() {
    long long l = 2;
    long long h = 2;
    for (int i = k-1; i >= 0; i--) {
      auto a = A[i];
      if (a == 1)
        continue;
      if (l/a == h/A[i] and l%a > 0)
        return false;
      if (l%a)
        l += a - l%a;
      h = h/a*a + a-1;
    }
    ans_a = l;
    ans_b = h;
    return true;
  };
  if (solve()) {
    cout << ans_a << " " << ans_b << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>

int main()
{
  char s[100000];
  scanf("%s", s);
  int count=0;

  for(int i=0;i<strlen(s);i++){
    if(s[i]=='0'&&s[i+1]=='0'){
      s[i+1]='1';
      count++;
    }
    else if(s[i]=='1'&&s[i+1]=='1'){
      s[i+1]='0';
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long T,a,b,c,d,ans;
	for(cin>>T;T--&&cin>>a>>b>>c>>d;cout<<(ans?"Yes\n":"No\n")){
		ans = 1, a-=b*max(0ll,(a-c-1)/b);
		if(a<b || d<b) ans = 0;
		
		if(d>b){
			if(c>=b-1 || d%b==0) continue;
			__int128 diff=__gcd(d,b);
			__int128 low = (c+b-a)/diff+1;
			if(a+diff*low-b<b) 
				ans = 0;
		}
	}
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;

char res[101][101];

bool solve(int i,int j,char t){
  if(res[i][j]!='X'){
    return res[i][j] == t;
  }
  bool ret;
  if(t=='A'){
    ret = false;
    REP(k,1,i/2+1) ret |= solve(i-2*k,j+k,'B');
    REP(k,1,j/2+1) ret |= solve(i+k,j-2*k,'B');
    if(ret) res[i][j] = 'A';
    else res[i][j] = 'B';
  }else{
    ret = true;
    REP(k,1,i/2+1) ret &= solve(i-2*k,j+k,'A');
    REP(k,1,j/2+1) ret &= solve(i+k,j-2*k,'A');
    if(ret) res[i][j] = 'B';
    else res[i][j] = 'A';
  }
  return ret;
}

int main(){
  ll X,Y; cin >> X >> Y;
  // rep(i,100) rep(j,100) res[i][j] = 'X';
  // res[0][0] = res[0][1] = res[1][0] = res[1][1] = 'B';
  // rep(i,10){
  //   rep(j,10){
  //     cout << (solve(i,j,'A') ? 'A' : 'B') << " ";
  //   }
  //   cout << "" << endl;
  // }
  if(abs(X-Y)>1) cout << "Alice" << endl;
  else cout << "Brown" << endl;
  return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define f first
#define s second
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    ld p;
    vector<vector<ld>> dp(n, vector<ld> (n+1, 0.0));
    cin >> p;
    dp[0][0] = 1-p;
    dp[0][1] = p;
    REP(i, 1, n) {
        cin >> p;
        REP(j, 0, n) {
            dp[i][j+1] += p * dp[i-1][j];
            dp[i][j] += (1.0 - p) * dp[i-1][j];
        }
    }
    ld ans = 0;
    REP(i, n/2 + 1, n+1)
        ans += dp[n-1][i];
    cout << fixed << setprecision(64) << ans << endl;
}


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

using namespace std;

#define NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO 1

int Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 11];
int Nubedyon(int n, int l, int r);

int main(void){
	int HogeHogePiypPiyo, Piyo;
	cin >> HogeHogePiypPiyo;
	for (int Nubesko = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Nubesko < HogeHogePiypPiyo; Nubesko++){
		for (int Dyon = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Dyon < NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10; Dyon++){
			cin >> Hoge[Dyon];
		}
		Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10] = 0;
		Piyo = Nubedyon(NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1);
		if (Piyo == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}
	}
	return NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
}

int Nubedyon(int n, int l, int r){
	int ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
	if (n == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10){
		ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO;
	}
	if (l < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, Hoge[n], r);
	}
	if (r < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, l, Hoge[n]);
	}

	return ans;
}

Measured memory_bytes: 1156
N = int(input())
V = input().split()
V = [int(v) for v in V]
C = input().split()
C = [int(c) for c in C]
VC = [0] * N
for n in range(N):
    VC[n] = V[n] - C[n]
    if VC[n] < 0:
        VC[n] = 0
S = sum(VC)
print(S)

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

#define ll long long


int main() {
    int h,w;
    cin>>h>>w;

    vector<string> s(h);
    vector<vector<ll>> u(h,vector<ll>(w,0));
    vector<vector<ll>> d(h,vector<ll>(w,0));
    vector<vector<ll>> l(h,vector<ll>(w,0));
    vector<vector<ll>> r(h,vector<ll>(w,0));




    for(int i=0;i<h;i++){
        cin>>s.at(i);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==0&&s.at(i).at(j)=='.'){
                l.at(i).at(j) = 1;
                continue;
            }
            if(s.at(i).at(j)!='#'){
                l.at(i).at(j) = l.at(i).at(j-1) +1;
            }else{
                l.at(i).at(j) = 0;
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==0&&s.at(i).at((w-1)-j)=='.'){
                r.at(i).at((w-1)-j) = 1;
                continue;
            }
            if(s.at(i).at((w-1)-j)!='#'){
                r.at(i).at(w-j-1) = r.at(i).at(w-j) +1;
            }else{
                r.at(i).at(w-j-1) = 0;
            }
        }
    }

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(j==0&&s.at(j).at(i)=='.'){
                u.at(j).at(i) = 1;
                continue;
            }
            if(s.at(j).at(i)!='#'){
                u.at(j).at(i) = u.at(j-1).at(i) +1;
            }else{
                u.at(j).at(i) = 0;
            }
        }
    }

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(j==0&&s.at(h-1-j).at(i)=='.'){
                d.at(h-1-j).at(i) = 1;
                continue;
            }
            if(s.at(h-1-j).at(i)!='#'){
                d.at(h-1-j).at(i) = d.at(h-j).at(i) +1;
            }else{
                d.at(h-1-j).at(i) = 0;
            }
        }
    }

    ll sum = 0,a;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            a = u.at(i).at(j) + l.at(i).at(j) + r.at(i).at(j) + d.at(i).at(j)-3;
            if(sum<a){
                sum = a;
            }
        }
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 131712
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n) {
		vvl v(m);
		vl s(m);
		REP(i, m) {
			int a; cin >> a;
			s[i] = a;
			int k; cin >> k;
			v[i].resize(k);
			REP(j, v[i].size()) {
				cin >> v[i][j];
				v[i][j]--;
			}
		}
		vl l(n, 0), r(n, 0);
		REP(i, m) {
			if (v[i].size() == 1)l[v[i][0]] += s[i];
			REP(j, v[i].size())r[v[i][j]] += s[i];
		}
		ll ans = 0;
		REP(i, n) {
			REP(j, n) {
				if (i == j)continue;
				chmax(ans, r[i] - l[j] + 1);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3824
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

min_sum = sum(B)
additionals = []

for i in range(1, len(A)):
    if A[i]-A[i-1] == 1:
        j = A[i-1]-1
        additionals.append(C[j])

sum_additionals = sum(additionals)

sum = min_sum + sum_additionals

print(sum)


Measured memory_bytes: 38256
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
mod = p = 10 ** 9 + 7

fact = [1]
fact_inv = [1]
for i in range(10**5+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
 
 
def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod    

A_max = 0
A_min = 0
for i in range(N-K+1):
    A_max = (A_max + (A[(K-1)+i] * mod_comb_k((K+i-1),i,p))) % p   
    A_min = (A_min + (A[-1*(K+i)] * mod_comb_k((K+i-1),i,p))) % p
    #print(A_max,A_min,cmb((K+i),i,p))
ans = (A_max - A_min)
if ans < 0:
    ans = p + ans
ans %= p
print(ans)

Measured memory_bytes: 70312
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

Vec< int > makeKMPfail(const string& S) {
	int n = S.size();	
	Vec< int > fail(n+1, 0);
	int j = fail[0] = -1;
	for_(i,1,n+1) {
		while (j >= 0 && S[j] != S[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
	return fail;
}

bool cyclic(const string& S, const string& T) {
	string x = S + S;
	Vec< int > t_fail = makeKMPfail(T);
	int N = x.size(), m = T.size();
	for (int i=0, k=0; i < N; ++i) {
		while (k >= 0 && T[k] != x[i]) k = t_fail[k];
		if (++k >= m) return true;
	}
	return false;
}

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	
	///
	Vec< int > s_fail = makeKMPfail(s);
	Vec< int > t_fail = makeKMPfail(t);
	int sp = n - s_fail[n], tp = m - t_fail[m];
	if (n % sp == 0 && m % tp == 0) {
		if (sp == tp && cyclic(s.substr(0, sp), t.substr(0, tp))) {
			puts("-1");
			return 0;
		}
	}
//	cerr << "sp " << sp << endl;
//	cerr << "tp " << tp << endl;
	
	///
	string x = s;
	while (x.size() < t.size()) x += x;
	for_(i,0,5) x += x;
	int N = x.size();
//	cerr << x << endl;
//	cerr << t << endl;
	
	Vec< bool > match(N+1, false);
	for (int i=0, k=0; i < N; ++i) {
		while (k >= 0 && t[k] != x[i]) k = t_fail[k];
		if (++k >= m) {
			match[i] = true;
			k = t_fail[k];
		}
	}
	
	int ans = 0;
	for_(i,1,N+1) {
		if (match[i]) {
			int j = i, cnt = 0;
			while (j <= N && match[j]) {
				match[j] = false;
				j += m;
				++cnt;
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 41804
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];vector<int>dp(k+1,-1);
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(k<a[0])
    {
        cout<<"Seconds";
        return;
    }
    for(int i=0;i<n;i++)
        dp[a[i]] = 1;
    for(int i=0;i<=k;i++)
    {
        int breaking=0;
        if(i<a[0] && dp[i]==-1)
            dp[i]=2;
        else if(dp[i]==-1)
        {
            for(int j=0;j<n;j++)
            {
                if((i-a[j])>=0)
                {
                    if(dp[(i-a[j])]==2)
                    {
                        dp[i] = 1;
                        breaking=1;
                        break;
                    }
                }
            }
            if(breaking==0)
                dp[i]=2;

        }

    }
    // run(dp);
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";


}
int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    solve();
    
        
    
    
    return 0; 
} 

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
void printCase(int cs){
  cout << "Case #" << cs<<": ";
}
int n, k, c;
string s;
int mxL[N],mxR[N];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n >> k >> c;
  cin >> s;
  int mx = 0, prv = c;
  f(i,0,n){
    mxL[i]=mx;
    if(s[i] == 'o'&&prv>=c){
      prv=0;
      mx++;
    } else prv++;
  }
  mx =0, prv = c;
  f(i,0,n){
    mxR[n-1-i]=mx;
    if(s[n-1-i] == 'o'&&prv>=c){
      prv=0;
      mx++;
    } else prv++;
  }

  f(i,0,n){
    if(mxL[i]+mxR[i]<k)cout<<i+1<<'\n';
  }


  return 0;
}


Measured memory_bytes: 3332
#include<stdio.h>

int main(void)
{
  int N, A;
  int tmp;
  
  scanf("%d",&N);
  scanf("%d",&A);
  
  tmp = N % 500;

  if(tmp <= A)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
A, B = map(int, input().split())
a = []
b = []
import random

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True


for i in range(1, int(A**(1/2))+1):
    if A % i == 0:
        a.append(i)
        a.append(A//i)
for i in range(1, int(B**(1/2))+1):
    if B % i == 0:
        b.append(i)
        b.append(B//i)

a = set(a)
b = set(b)
a = a & b

ans = 0
for i in a:
    if is_prime(i):
        ans += 1
print(ans+1)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N,M; vi x; vs y; int AC[100050]; int WA[100050];
void input()
{
    cin>>N>>M;
    rep(i,M){
        int a; string s;
        cin>>a>>s;
        x.emplace_back(a); y.emplace_back(s);
    }
    return;
}

void solve()
{
    int ans=0,pena=0;
    rep(i,100050) AC[i]=WA[i]=0;
    // The pena ansewer is the num of penalties which Takahashi will revise correctly.  
    rep(i,M){
        if(AC[x[i]]!=0) continue;
        if(y[i]=="AC") {
            ++AC[x[i]];
            ++ans;
            pena+=WA[x[i]];
        } else if(y[i]=="WA") {
            ++WA[x[i]];
        }
    }
    cout<<ans<<" "<<pena<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 6892
#include <stdio.h>
#define N 500000
#define INFTY 1000000000
int A[N],cnt=0;
void merge(int,int,int);
void mergeSort(int,int);
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
   printf("%d\n",A[n-1]);
   printf("%d\n",cnt);
  return 0;
}
void merge(int left,int mid,int right){
  int i,j,k;
  int n1 = mid-left;
  int n2 = right-mid;
  int L[n1+1], R[n2+1];
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
     cnt++;
    if (L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else {
      A[k]=R[j];
      j=j+1;
    }
  }
}
void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
   
    mid=(left+right)/2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
      }

}
					 



Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define ll long long
#define nl '\n'
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 1e6;
const int DIST_MAX = 2147483647;


int main(){
    AC
    int h, w, k;
    int x1, y1, x2, y2;
    cin>>h>>w>>k;
    cin>>x1>>y1>>x2>>y2;
    x1--; y1--; x2--; y2--;

    char grid[h+5][w+5];
    int dist[h+5][w+5];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin>>c;
            grid[i][j] = c;
            dist[i][j] = DIST_MAX;
        }
    }

    vector<ar<int,2>> dir = {{1,0},{-1,0},{0,1},{0,-1}};
    dist[x1][y1] = 0;
    queue<ar<int,2>> Q;
    Q.push({x1, y1});
    while(!Q.empty()){
        auto cur = Q.front();
        Q.pop();
        int cx = cur[0];
        int cy = cur[1];
        for(auto d : dir){
            int dx = cx;
            int dy = cy;
            int cur_dist = dist[cx][cy]+1;
            for(int m=1; m<=k; m++){
                dx += d[0];
                dy += d[1];
                //cout<<dx<<" "<<dy<<"---------"<<endl;
                if(dx<0 || dx>=h || dy<0 || dy>=w || grid[dx][dy]=='@' || cur_dist>dist[dx][dy]) break;
                if(cur_dist < dist[dx][dy]){
                    dist[dx][dy] = cur_dist;
                    Q.push({dx, dy});
                }
            }
        }
    }

    cout<<(dist[x2][y2]==DIST_MAX ? -1 : dist[x2][y2])<<endl;
}

Measured memory_bytes: 9044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<20)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

vector<P> g[1234];
priority_queue< P, vector<P>, greater<P> > pq;
double xs,ys,xt,yt,x[1234],y[1234],r[1234];

double distfromitoj(int i,int j){
	return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
void makeedge(int i, int j){
	double dist;
	dist = max(distfromitoj(i,j)-r[i]-r[j],0.0);
	g[i].push_back(P(dist,j));
	g[j].push_back(P(dist,i));
}

int main(void){
	int n,i,j,p,e;
	double d[1234],c;
	P tmp;
	fill(d,d+1234,(1e20));
	cin >> xs >> ys >> xt >> yt;
	cin >> n;
	x[n+1] = xs; y[n+1] = ys; r[n+1] = 0.0;
	x[n] = xt; y[n] = yt; r[n+1] = 0.0;
	makeedge(n,n+1);
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i] >> r[i];
		makeedge(i,n+1);
		makeedge(i,n);
	}
	for(i=0; i<n; ++i){
		for(j=(i+1); j<n; ++j){
			makeedge(i,j);
		}
	}
	d[n+1] = 0.0;
	pq.push(P(d[n+1],n+1));
	while(!pq.empty()){
		tmp = pq.top();
		pq.pop();
		p = tmp.second;
		for(i=(g[p].l_ength()-1); i>=0; --i){
			c = g[p][i].first;
			e = g[p][i].second;
			if(d[e] > d[p] + c){
				d[e] = d[p] + c;
				pq.push(P(d[e],e));
			}
		}
	}
	printf("%.10f\n",d[n]);
	return 0;
}


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

int main(){
  int n;
  while(cin>>n,n){ 
    int a[10000];
    double s=0;
    for(int i=0;i<n;i++)cin>>a[i],s+=a[i];
    int ans=0;
    for(int i=0;i<n;i++)ans+=s/n>=a[i];
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3124
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)

N, C = map(int, input().split())
D = []
col = []

for c in range(C):
    Drow = list(map(int, input().split()))
    D.append(Drow)
for i in range(N):
    crow = list(map(int, input().split()))
    crow = list(map(lambda x: x-1,
                    crow))
    col.append(crow)

#
count = [[0]*C for m in range(3)]

for i in range(N):
    for j in range(N):
        m = (i + j) % 3
        count[m][col[i][j]] += 1

def iwakan(y):
    res = 0
    for m in range(3):
        for c in range(C):
            res += D[c][y[m]] * count[m][c]
    return res

iwakan_list = []
for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if (c3 == c1) or (c3 == c2):
                continue
            y = [c1, c2, c3]
            debug(y, iwakan(y))
            iwakan_list.append(iwakan(y))

print(min(iwakan_list))


Measured memory_bytes: 72924
#include <bits/stdc++.h>
#define vec vector
#define ALL(v) v.begin(), v.end()
#define ll long long
using namespace std;
int main()
{
    int n;
    cin >> n;
    vec<int> a, b, c;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        a.push_back(t);
    }

    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        b.push_back(t);
    }
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        c.push_back(t);
    }
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    ll ans = 0;
    for (auto j : b)
    {
        auto i = lower_bound(ALL(a), j) - a.begin();
        auto k = c.end() - upper_bound(ALL(c), j);
        ans += i * k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1784