akhauriyash/Code-Regression huggingface dataset:
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, A, B, C int
  NextInt(&N, &A, &B, &C)
  S := make([]string, N)
  for i := range S { S[i] = NextLine() }
  T := make([]string, N)
  ans := "Yes"
  for i, s := range S {
    if s == "AB" {
      if A == 0 && B == 0 {
        ans = "No"
        break
      }
      if A < B {
        A++
        B--
        T[i] = "A"
      } else if B < A {
        A--
        B++
        T[i] = "B"
      } else if i == N - 1 || S[i + 1] != "BC" {
        A++
        B--
        T[i] = "A"
      } else {
        A--
        B++
        T[i] = "B"
      }
    } else if s == "AC" {
      if A == 0 && C == 0 {
        ans = "No"
        break
      }
      if A < C {
        A++
        C--
        T[i] = "A"
      } else if C < A {
        A--
        C++
        T[i] = "C"
      } else if i == N - 1 || S[i + 1] != "BC" {
        A++
        C--
        T[i] = "A"
      } else {
        A--
        C++
        T[i] = "C"
      }
    } else {
      if B == 0 && C == 0 {
        ans = "No"
        break
      }
      if B < C {
        B++
        C--
        T[i] = "B"
      } else if C < B {
        B--
        C++
        T[i] = "C"
      } else if i == N - 1 || S[i + 1] != "AC" {
        B++
        C--
        T[i] = "B"
      } else {
        B--
        C++
        T[i] = "C"
      }
    }
  }
  Write(ans)
  if ans == "No" { return }
  for _, t := range T { Write(t) }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 8676
#include<bits/stdc++.h>
using namespace std;
#define MAX (int)1e+5+1
typedef long long ll;

int N, M;
pair<int, int> AB[MAX];
priority_queue<int> Q;

int main() {
    cin >> N >> M;
    for (int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        AB[i] = make_pair(a, b);
    }

    ll ans = 0;
    sort(AB, AB+N);
    int index = 0;

    for (int i=0; i<M; i++) {
        for (; index<N; index++) {
            if (AB[index].first==(i+1)) Q.push(AB[index].second);
            else break;
        }
        if (!Q.empty()) {
            ans += Q.top();
            Q.pop();
        }
    }

    printf("%lld\n", ans);

    return 0;
}

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

#define sz(x) (int)((x).size())
#define xx first
#define yy second

const int N = 1e4 + 1;
const int D = 1e2 + 1;
const int mod = 1e9 + 7;

int add(int x, int y, int m) {
    return ((x + y) % m + m) % m;
}
int mul(int x, int y, int m) {
    return (x * y) % mod;
}

string k, S = "0123456789";
int x, memo[2][D][N];

int dp(int match, int rem, int i) {
    if (i == sz(k))
        return !rem ? 1 : 0;
    if (memo[match][rem][i] != -1)
        return memo[match][rem][i];
    int ans = 0;
    for (int d = 0; d <= (match ? (k[i] - '0') : 9); d++) {
        int nmatch = match & (d == (k[i] - '0'));
        int nrem = add(rem, d, x);
        ans = add(ans, dp(nmatch, nrem, i + 1), mod);
    }
    return memo[match][rem][i] = ans;
}

void solve() {
    cin >> k >> x;
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < x; j++)
            fill(memo[i][j], memo[i][j] + N, -1);
    int ans = dp(1, 0, 0);
    ans = add(ans, -1, mod);
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << sqrt(pow(x2-x1, 2)+pow(y2-y1, 2));
	return 0;
}

Measured memory_bytes: 3280
// problem: "https://atcoder.jp/contests/abc153/tasks/abc153_d"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll numMoves(ll H)
{
    if(!H)
        return 0;

    return 2*numMoves(H/2) + 1;
}

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

    cout<<numMoves(h);      // define

    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n, k = na()
ans = 0
for i in range(n):
    r = 0
    j = i + 1
    while j < k:
        j = j * 2
        r += 1
    ans += (1/n) * (1/2) ** r



print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			double[] vs = Console.ReadLine().Split().Select(double.Parse).ToArray();
			double a = vs[0];
			double b = vs[1];
			double x = vs[2] / a;
			double c, ans;
			if (a * b / 2 < x) {
				c = 2 * x / a - b;
				ans = Math.Atan((b - c) / a) * 180 / Math.PI;
			} else {
				c = 2 * x / b;
				ans = Math.Atan(b / c) * 180 / Math.PI;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#abc093d
import math

q=int(raw_input())
res=[]
for i in xrange(q):
 a,b=map(int,raw_input().split())
 m=a*b
 x=int(math.sqrt(m-1))
 while x**2>=m:
  x-=1
 y=x*2
 if x*(x+1)>=m:
  y-=1
 if max(a,b)<=x:
  res-=1
 if min(a,b)<=x:
  y-=1
 res.append(y)
for i in xrange(q):
 print res[i]


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,d;
    cin >> n >> d;
    matrix mat(n,Vi(d));
    rp(i,n){
        rp(j,d){
            cin >> mat[i][j];
        }
    }
    int ctr=0;
    rp(i,n-1){
        repi(j,i+1,n){
            ll dist=0;
            rp(k,d){
                dist+=(mat[i][k]-mat[j][k])*(mat[i][k]-mat[j][k]);
            }
            bool ok=false;
            rp(i,1000){
                if(i*i==dist) {
                    ok=true;
                    break;
                }
                if(i*i>dist){
                    break;
                }
            }
            if(ok) ctr++;
        }
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 301
  
int dp[MAX][MAX];
int arr[MAX][MAX];
  
void init(int N,int M){
    for(int i = 0 ; i <= N ; i++){
	for(int j = 0 ; j <= M ; j++){
	    dp[i][j] = 0;
	    arr[i][j] = MAX;
	}
    }
}
 
string getStr(string &L,string &R,int l,int r){
    for(int i = 0 ; i < l ; i++){
	for(int j = 0 ; j < r ; j++){
	    if(L[i] == R[j]){
		dp[i+1][j+1] = dp[i][j]+1;
		arr[i+1][j+1] = 0;
	    }else{
		if(dp[i][j+1] < dp[i+1][j]){
		    dp[i+1][j+1] = dp[i+1][j];
		    arr[i+1][j+1] = -1;
		}else{
		    dp[i+1][j+1] = dp[i][j+1];
		    arr[i+1][j+1] = 1;
		}
	    }
	}
    }
    string res;
    for(int i = l, j = r ; i > 0 && j > 0 ; ){
	if(!arr[i][j]){
	    res += L[i-1];
	    i--; j--;
	}else if(arr[i][j] == 1){
	    i--;
	}else{
	    j--;
	}
    }
    reverse(res.begin(),res.end());
    return res;
}
 
int main(){
    string str;
    while(cin >> str, str != "#END"){
	int len = str.size(),res = 0;
	string res_str;
	for(int i = 1 ; i < len ; i++){
	    string L = str.substr(0,i);
	    string R = str.substr(i);
	    int l = L.size(),r = R.size();
	    init(l,r);
	    string repS = getStr(L,R,l,r);
	    l = repS.size();
	    if(res < l){
		res = l;
		res_str = repS;
	    }
	}
	cout << res_str << endl;
    }
    return 0;
}

Measured memory_bytes: 3848
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#define int long long
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
signed main()
{
	int n=read();
	int a=read();
	for(int i=2;i<=n;i++){
		int x=read();
		a=a/gcd(a,x)*x;
	}
	writeln(a);
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    int n, m; scanf("%d%d", &n, &m);
    auto a = vectors(n, m, int());
    repeat (y, n) {
        repeat (x, m) {
            scanf("%d", &a[y][x]);
            -- a[y][x];
        }
    }
    vector<int> cnt(m);
    repeat (y, n) {
        cnt[a[y][0]] += 1;
    }
    int result = *whole(max_element, cnt);
    int k = m;
    vector<int> ix(n);
    while (true) {
        repeat (x, m) {
            if (cnt[x] >= result) {
                cnt[x] = -1;
                k -= 1;
            }
        }
        if (k == 0) break;
        repeat (y, n) {
            if (cnt[a[y][ix[y]]] == -1) {
                while (cnt[a[y][ix[y]]] == -1) ++ ix[y];
                assert (ix[y] < m);
                cnt[a[y][ix[y]]] += 1;
            }
        }
        setmin(result, *whole(max_element, cnt));
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 640
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, deque<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    deque<int> vs0(n); cin >> vs0;
    int ans = 0;
    for(int l = 0; l <= k; l++){
        for(int r = 0; r <= k; r++){
            if(l + r > k){ continue; }
            auto vs = vs0;
            vector<int> ns;
            for(int i = 0; i < l; i++){
                if(vs.empty()){ break; }
                ns.push_back(vs.front());
                vs.pop_front();
            }
            for(int i = 0; i < r; i++){
                if(vs.empty()){ break; }
                ns.push_back(vs.back());
                vs.pop_back();
            }
            sort(ns.rbegin(), ns.rend());
            for(int i = 0; i < k - r - l; i++){
                if(ns.empty() || ns.back() >= 0){ break; }
                ns.pop_back();
            }
            ans = max(ans, accumulate(ns.begin(), ns.end(), 0));
            printde(l, r, ans);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int cnt = 0;
vector<int> tmp;
vector<int> insert(vector<int> a, int n, int g){
  for(int i=g; i<n; i++){
    int v = a[i];
    int j = i - g;
    while( j >= 0 && a[j] > v ){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
  return a;
}
vector<int> shell(vector<int> a, int n){
  int m = n;
  while( m != 0 ){
    tmp.push_back(m);
    a = insert(a, n, m);
    m /= 2;
  }
  return a;
}


int main(void) {
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  s = shell(s, n);
  cout << tmp.size() << endl;
  for(int i=0; i<tmp.size()-1; i++) cout << tmp[i] << " ";
  cout << tmp[tmp.size()-1] << endl;
  cout << cnt << endl;
  for(int i=0; i<n; i++) cout << s[i] << endl;
  return 0;
}





// EOF

Measured memory_bytes: 18548
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 1000+5 ;
const int INF = INT_MAX ;
const int M = 200005; 
int main ( ){
fast_io();
ll n , a ,  b ;
cin >> n >>a >> b ;

ll x = ( n / (a+ b)   ) ;
ll res = a * x ;
res += min ( n -(a+b)*x   , a ) ;
cout << res ;
 
  

return 0 ;
 
}


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

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

  if (N[0] == N[1] && N[0] == N[2]) {
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[1] == N[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long h = sc.nextLong();
		long w = sc.nextLong();
		int n = sc.nextInt();
		
		// 計算
		long[] result = new long[10];
		result[0] = (long)(h-2)*(w-2);
		HashMap<Long, Integer> hm = new HashMap<Long, Integer>();
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt()-1;
		    int b = sc.nextInt()-1;
		    int[] dx = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; // 9
		    int[] dy = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; // 9
		    for(int k = 0; k < dx.length; k++){
		        int ni = a + dx[k];
		        int nj = b + dy[k];
		        if(0 <= ni && ni < h && 0 <= nj && nj < w){
		            if(0 < ni && ni < h-1 && 0 < nj && nj < w-1){
		                long key = (long)ni*w + nj;
		                hm.put(key, hm.getOrDefault(key, 0)+1);
		            }
		        }
		    }
		}
		for(Integer val : hm.values()){
		    result[val]++;
		    result[0]--;
		}
		// 出力
		for(long res : result){
		    System.out.println(res);
		}
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 121980
/* 
 * Author: aps
 * Time: 29-06-2019 17:41:49
**/
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const ll inf = 1e18;
const ll mod = 1e9+7;

inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    
    vi a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(all(a));

    cout << a[n/2] - a[(n/2)-1] << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	private void doit(){
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [][] data = new int[n + 1][4];
			for(int i = 0; i <= n; i++){
				for(int j = 0; j < 4; j++){
					data[i][j] = sc.nextInt();
				}
			}
			boolean NA = true;
			for(int i = 0; i < n; i++){
				int nowC = 4 * data[i][1] + 9 * data[i][2] + 4 * data[i][3];
				if(data[i][1] <= data[n][0] && data[i][2] <= data[n][1] && data[i][3] <= data[n][2] && nowC <= data[n][3]){
					NA = false;
					System.out.println(data[i][0]);
				}
			}
			if(NA) System.out.println("NA");
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 64572
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Double D = sc.nextDouble();
        Double[][] X = new Double[N][2];

        for(int i=0; i<N*2; i++){
            if(i%2 == 0){
                X[i/2][0] = sc.nextDouble();
            }else{
                X[i/2][1] = sc.nextDouble();
            }
        }
        sc.close();
        int ans = 0;
        for(int i=0; i<N; i++){
            if(Math.sqrt(X[i][0]*X[i][0]+(X[i][1]*X[i][1])) <= D){
                ans ++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 85856
#include <stdio.h>

int main(void)
{
        int N,K,X,Y,sum;
        scanf("%d%d%d%d",&N,&K,&X,&Y);
                if(N <= K)
                        {sum = N*X;}
                else
                        {sum = K*X + (N-K)*Y;}
        printf("%d\n",sum);
        return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        long[] A = new long[N];
        long Sum = 1;
        int hantei = 1;
        boolean hnt = true;
        long S = (long)Math.pow(10,18);
        
        for(int i=0; i<N; i++){
            A[i] = scanner.nextLong();
            if(A[i]==0){
                hantei = 0;
            }
        }
        
        for(int i=0; i<N; i++){
            if(A[i]<=S/Sum){
                Sum *= A[i];
            }else{
                hnt = false;
                break;
            }
        }
        
        
        if(hantei==0){
            System.out.println(0);
        }else if(hnt){
            System.out.println(Sum);
        }else{
            System.out.println(-1);
        }

    }
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  string s,t;
  cin>>s>>t;
  int ans=t.size();
  int n=s.size();
  int m=t.size();
  rep(i,n){
    if(i+m-1<n){
      int memo=0;
      rep(j,m){
        if(s[i+j]!=t[j]) memo++;
      }
      chmin(ans,memo);
    }
  }
  cout<<ans<<endl;
  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
  int repeat = 1;
  // cin >> repeat;
  while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp

./a.out

*/

Measured memory_bytes: 7816
N = int(input())
p = list(map(int, input().split()))
c = 0
pre = 0
for i in range(N):
    if i + 1 == p[i]:
        if pre == 1:
            pre = 0
        else:
            c += 1
            pre = 1
    else:
        pre = 0
print(c)


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

const int MAX=250000000;
bool exist[MAX];

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

    int Q; cin>>Q;
    string table="ACGT";
    auto get=[&](string s)
    {
        int res=0,pow5=1;
        for(int i=0;i<s.size();i++){
            for(int j=0;j<4;j++) if(s[i]==table[j]) res+=(j+1)*pow5;
            pow5*=5;
        }
        return res;
    };
    while(Q--){
        string q,s; cin>>q>>s;
        if(q=="insert") exist[get(s)]=true;
        else cout<<(exist[get(s)]? "yes":"no")<<endl;
    }
    return 0;    
}


Measured memory_bytes: 8372
#include <iostream>
#include <cmath>
#include <complex>
#include <cstdio>
using namespace std;

int main(){
  int n=0;
  double x,y;
  complex<double> v[20];
  while(scanf("%lf,%lf",&x,&y)>0){
    v[n]=complex<double>(x,y);
    n++;
  }

  double s=0.0;
  for(int i=1;(i+1)<n;i++){
    s+=abs((conj(v[i]-v[0])*(v[i+1]-v[0])).imag())/2.0;
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3304
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

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

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	a, b, c := make([]int, n), make([]int, n), make([]int, n)
	d, e, f := make([]int, m), make([]int, m), make([]int, m)
	x := map[int]int{}
	y := map[int]int{}
	for i := 0; i < n; i++ {
		a[i], b[i], c[i] = scanInt(), scanInt(), scanInt()
		x[a[i]], x[b[i]], y[c[i]] = 0, 0, 0
	}
	for i := 0; i < m; i++ {
		d[i], e[i], f[i] = scanInt(), scanInt(), scanInt()
		x[d[i]], y[e[i]], y[f[i]] = 0, 0, 0
	}
	x[0], y[0] = 0, 0

	xs := []int{}
	ys := []int{}
	for i := range x {
		xs = append(xs, i)
	}
	for i := range y {
		ys = append(ys, i)
	}
	sort.Ints(xs)
	sort.Ints(ys)

	for i := 0; i < len(xs); i++ {
		x[xs[i]] = i
	}
	for i := 0; i < len(ys); i++ {
		y[ys[i]] = i
	}

	h, w := len(xs)*2, len(ys)*2
	g := make([][]bool, h)
	done := make([][]bool, h)
	for i := 0; i < h; i++ {
		g[i] = make([]bool, w)
		done[i] = make([]bool, w)
	}

	for i := 0; i < n; i++ {
		aa, bb, cc := x[a[i]]*2, x[b[i]]*2, y[c[i]]*2
		for j := aa; j <= bb; j++ {
			g[j][cc] = true
		}
	}

	for i := 0; i < m; i++ {
		dd, ee, ff := x[d[i]]*2, y[e[i]]*2, y[f[i]]*2
		for j := ee; j <= ff; j++ {
			g[dd][j] = true
		}
	}

	q := []pair{pair{x[0] * 2, y[0] * 2}}
	done[x[0]*2][y[0]*2] = true
	for len(q) != 0 {
		xx, yy := q[0].a, q[0].b
		q = q[1:]
		for i := 0; i < 4; i++ {
			nx, ny := xx+dx[i], yy+dy[i]
			if nx < 0 || nx >= h || ny < 0 || ny >= w {
				continue
			}
			if g[nx][ny] || done[nx][ny] {
				continue
			}
			done[nx][ny] = true
			q = append(q, pair{nx, ny})
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if !done[i][j] {
				continue
			}
			if i == 0 || i == h-1 || j == 0 || j == w-1 {
				fmt.Fprintln(wr, "INF")
				return
			}
			if i%2 == 0 || j%2 == 0 {
				continue
			}
			ans += (xs[i/2+1] - xs[i/2]) * (ys[j/2+1] - ys[j/2])
		}
	}
	fmt.Fprintln(wr, ans)

}

type pair struct{ a, b int }

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


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;

ll fast_pow(ll a,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)	ans = ans*a%MOD;
		a = a*a %MOD;
		n >>= 1;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	map<pair<ll,ll>,int>one;
	map<pair<ll,ll>,int>four;
	set<pair<ll,ll> >list;
	int n;
	scanf("%d",&n);
	ll ans = 1,ant = 0;
	ll a,b;
	for(register int _ = 0;_ < n;_++)
	{
		scanf("%lld%lld",&a,&b);
		ll ab_gcd = __gcd(abs(a),abs(b));
		if(!a&&!b)
		{
			ant++;continue;
		}
		if(a >= 0 && b > 0 || a <= 0 && b < 0)
		{
			if(a != 0)
			{
				a = abs(a)/ab_gcd;b = abs(b)/ab_gcd;
			}else{
				a = 0;b = 1;
			}
			one[{a,b}]++;
		}else{
			if(b!=0)
			{
				a = abs(a)/ab_gcd;b = abs(b)/ab_gcd;
			}else{
				a = 1,b = 0;
			}
			four[{b,a}]++;
		}
	}
	for(map<pair<ll,ll>,int>::iterator it = one.begin();it != one.end();it++)
		list.insert(it->first);
	for(map<pair<ll,ll>,int>::iterator it = four.begin();it != four.end();it++)
		list.insert(it->first);
	for(set<pair<ll,ll> >::iterator it = list.begin();it != list.end();it++)
		ans = ans*(fast_pow(2,one[*it])+fast_pow(2,four[*it])-1+MOD)%MOD;
	printf("%lld\n",(ans + ant - 1 + MOD)%MOD);
	return 0;
}

Measured memory_bytes: 41176
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, k - q);
    while(q--){
        int a;
        cin >> a;
        a--;
        p[a]++;
    }
    rep(i, 0, n){
        if(p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

int dp[20][2];
vector<int> vec;

int solve(int cd,int less)
{
	if(cd==17)
	{
		return 0;
	}
	if(dp[cd][less]!=-1)
	{
		return dp[cd][less];
	}
	int ref=vec[cd];
	int ans=0;
	if(less)
	{
		ans=max(ans,9+solve(cd+1,less));
	}
	else
	{
		for(int i=0;i<ref;i++)
		{
			ans=max(ans,i+solve(cd+1,1));
		}
		ans=max(ans,ref+solve(cd+1,0));
	}
	dp[cd][less]=ans;
	return ans;
}

int main()
{
	scanf("%lld",&n);
	for(int i=0;i<=16;i++)
	{
		vec.push_back(n%10);
		n/=10;
	}
	reverse(vec.begin(),vec.end());
	memset(dp,-1,sizeof dp);
	printf("%d\n",solve(0,0));
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(all(c)); c.erase(unique(all(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 


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

    int N, K;
    cin >> N >> K;

    vector<ll> x(N); cin >> x;
    
    ll ans = LLONG_MAX;

    rep(i, N-K+1) {
        int l = i;
        int r = i+K-1;
        if (x[r] <= 0) {
            chmin(ans, -x[l]);
        } else if (x[l] >= 0) {
            chmin(ans, x[r]);
        } else {
            chmin(ans, -x[l] + x[r] - x[l]);
            chmin(ans, x[r] + x[r] - x[l]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli dp[10001] = {};


int main(void) {

	lli h, n;
	cin >> h >> n;

	for (int i = 0; i <= 10000; i++) {
		dp[i] = inf;
	}

	dp[0] = 0;

	for (int k = 0; k < n; k++) {
		lli a, b;
		cin >> a >> b;
		for (int i = 0; i <= 10000; i++) {
			if (i + a <= 10000)
				dp[i + a] = min(dp[i + a], b + dp[i]);
		}
	}

	lli answer = inf;
	for (int i = h; i <= 10000; i++) {
		answer = min(answer,dp[i]);
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 384
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << '\n';
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x;
  cin >> x;
  Pr(x >= 30);
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
	int n,i,count=0;
	int l[1001];
	int r[1001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&l[i],&r[i]);
		count+=r[i]-l[i]+1;
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, c, t;
long long a[MX], x, o, ans, u;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld", a+i);
		x ^= a[i];
		o |= a[i];
	}
	ans += x;
	rep(i,n) a[i] &= ~x;
	o &= ~x;
	for(int i = 60; i >= 0; i--) if(o>>i&1){
		for(c = t; c < n && ~a[c]>>i&1; c++);
		if(c != n){
			swap(a[c], a[t]);
			rep(j,n) if(j != t && a[j]>>i&1) a[j] ^= a[t];
			t++;
		}
	}
	rep(i,n) u ^= a[i];
	printf("%lld\n", ans + u*2);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A);
	vector<int> b(B);
	for (int i = 0; i < A; i++)cin >> a[i];
	for (int i = 0; i < B; i++)cin >> b[i];
	int minA = *min_element(a.begin(), a.end());
	int minB = *min_element(b.begin(), b.end());
	int ans = minA+minB;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c; x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
map<pair<ll,ll>,int>mm;
const int maxn = 200005;
ll a[maxn]={0},b[maxn]={0};
ll getnum(int c){
    ll ans = 1 ;
    ll d = 2;
    while(c){
        if(c%2) ans = ans*d%mod;
        d=d*d%mod;
        c/=2;
    }
    return (ans + 1000000006 )%mod;
}
int main()
{
//    cout << __gcd(100,-100)<<endl;
//    cout << __gcd(-100,-100)<<endl;
//    cout << __gcd(-100,100)<<endl;
    int n;
    cin >> n;
    ll ans = 0 ;
    for(int i=0;i<n;i++){
        cin >>a[i]>>b[i];
        if(a[i]==b[i]&&a[i]==0)
            ans++;
        else if(a[i]!=0&&b[i]!=0){
            if(a[i]<0){
                a[i]*=-1;
                b[i]*=-1;
            }
            ll gcd = __gcd(a[i],abs(b[i]));
            a[i]=a[i]/gcd;
            b[i]=b[i]/gcd;
            mm[make_pair(a[i],b[i])]++;
        }
        else{
            if(a[i]) a[i]=1;
            if(b[i]) b[i]=1;
            mm[make_pair(a[i],b[i])]++;
        }
    }

    ll temp = 1 ;
    for(int i=0;i<n;i++){
        //cout << i << endl;
        if(a[i]==b[i]&&a[i]==0)
            continue;
        if(mm[make_pair(a[i],b[i])]){
            if(mm[make_pair(-b[i],a[i])]+mm[make_pair(b[i],-a[i])]){
                ll d = (getnum(mm[make_pair(a[i],b[i])])+getnum(mm[make_pair(-b[i],a[i])]+mm[make_pair(b[i],-a[i])])+1) %mod;
                mm[make_pair(a[i],b[i])]=0;
                mm[make_pair(-b[i],a[i])]=0;
                mm[make_pair(b[i],-a[i])]=0;
                temp = temp *d % mod;
            }
            else
                temp = temp *2 % mod;
        }
    }
    cout << (temp + ans + 1000000006)%mod;
    return 0;
}


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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    int hotel[13][11];
    memset(hotel, 0, sizeof(hotel));
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        hotel[(b - 1) * 3 + f][r] += v;
    }
    for (int i = 1; i < 13; i++)
    {
        if (i == 4 || i == 7 || i == 10)
        {
            cout << "####################" << endl;
        }
        for (int j = 1; j < 11; j++)
        {
            cout << " " << hotel[i][j];
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3232
n = int(input())
s = list(input())

dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] +1
        
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans = max(ans,min(dp[i][j],j-i))

print(ans)

Measured memory_bytes: 231688
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
  ll H, N;
  cin >> H >> N;

  ll cnt = 0;
  for (ll i = 0; i < N; i++) {
    ll a;
    cin >> a;
    cnt += a;
  }
  if (cnt >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = sc.nextInt();
        int v = sc.nextInt();
        int b = sc.nextInt();
        int w = sc.nextInt();
        int t = sc.nextInt();
        int dis = (int)Math.abs(a - b);
        long speed = v - w;
        if((long)(t * speed) >= dis)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 35784
using System;

namespace AOJ.ITP
{
    public class Grading
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int mid = int.Parse(input[0]);
                int fin = int.Parse(input[1]);
                int re = int.Parse(input[2]);
                if (mid == -1 && fin == -1 && re == -1) { break; }

                if (mid == -1 || fin == -1) { Console.WriteLine("F"); }
                else
                {
                    int sum = mid + fin;
                    if (sum >= 80) { Console.WriteLine("A"); }
                    else if (sum >= 65) { Console.WriteLine("B"); }
                    else if (sum >= 50) { Console.WriteLine("C"); }
                    else if (sum >= 30)
                    {
                        if (re >= 50) { Console.WriteLine("C"); }
                        else { Console.WriteLine("D"); }
                    }
                    else { Console.WriteLine("F"); }
                }
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dh[] = {1, -1, 0, 0};
const int dw[] = {0, 0, 1, -1};

int g;

void dfs(int h, int w, vector<vector<bool> >& b) {
	stack<P> s;
	s.push(P(h, w));
	while (!s.empty()) {
		int ch, cw;
		tie(ch, cw) = s.top();
		s.pop();
		if (b[ch][cw]) continue;
		b[ch][cw] = true;
		for (int i = 0; i < 4; i++) {
			int nh = ch + dh[i], nw = cw + dw[i];
			if (nh < 0 || nh >= g || nw < 0 || nw >= 7) continue;
			if (b[nh][nw]) continue;
			s.push(P(nh, nw));
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	int m, q;
	cin >> n >> m >> q;
	vector<bool> memo(m, false);
	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;
		memo[a] = true;
	}

	g = m / __gcd(m, 7);

	vector< vector<bool> > b(g, vector<bool>(7, false));
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < 7; j++) {
			int x = 7 * i + j;
			b[i][j] = memo[x % m];
		}
	}
	
	int cnt1 = 0;
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < 7; j++) {
			if (!b[i][j]) {
				dfs(i, j, b);
				cnt1++;
			}
		}
	}

	g *= 2;
	b.resize(g, vector<bool>(7, false));
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < 7; j++) {
			int x = 7 * i + j;
			b[i][j] = memo[x % m];
		}
	}
	
	int cnt2 = 0;
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < 7; j++) {
			if (!b[i][j]) {
				dfs(i, j, b);
				cnt2++;
			}
		}
	}

	if (m % 7 == 0) {
		cout << (cnt2 - cnt1) * (7 * n / m) + (cnt1 * 2 - cnt2) << endl;
	} else {
		cout << (cnt2 - cnt1) * (n / m) + (cnt1 * 2 - cnt2) << endl;
	}

	return 0;
}

Measured memory_bytes: 18296
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,a,b;
    cin >>a>>b;
    ans=(a+b)%24;

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
d=[]
A=[]
Ans=[]

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

for n in range(K):
    d=int(input())
    S= list(map(int,input().split()))
    for s in S:
        A.append(s)

for n1 in range(1,N+1):
    if n1 not in A:
        Ans.append(n1)

print(len(Ans))


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int x; cin >> x;
    if(x==0){
        out(1);
    }
    else{
        out(0);
    }
}

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

using namespace std;

int main(){
  int k, t, a[109];
  cin >> k >> t;
  for(int i=0;i<t;i++)cin >> a[i];
  int ans=0;
  for(int i=0;i<t;i++){
    int rest=max(a[i]-(k+1)/2, 0);
    if(rest==1)ans++;
    else if(rest>1){
      ans += 1+2*(rest-1);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3592
s = input()
a_index = 0
z_index = 0
for i in range(len(s)):
    if s[i] == 'A':
        a_index = i
        break
for i in range(len(s) - 1, 0, -1):
    if s[i] == 'Z':
        z_index = i
        break
print(z_index - a_index + 1)

Measured memory_bytes: 3516