akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N;
    cin>>N;
    vector<pair<int, int>> P(N);
    rep(i,N){
        cin>>P[i].first>>P[i].second;
    }
    int a[N];
    rep(i,N)a[i]=i;
    double sum=0;
    do{
        rep(i,N-1){
            double c,b;
            c = pow(P[a[i+1]].first - P[a[i]].first, 2);
            b = pow(P[a[i+1]].second - P[a[i]].second, 2);
            sum+=pow(c+b, 0.5);
        }
    }while(next_permutation(a, a+N));
    int n=1;
    for(int i=1; i<N+1; i++)n*=i;
    cout<<fixed<<setprecision(10)<<sum/n<<endl;
    return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  map<int,int> ma;
  int n,k;
  cin>>n>>k;
  rep(i,n){
    int d;
    cin>>d;
    ma[d]++;
  }
  vector<int> v;
  for(auto &p : ma) v.pb(p.se);

  sort(all(v));

  int res = 0;
  int cnt = ma.size() - k;
  int i = 0;
  while(cnt>0){
    res += v[i];
    i++;
    cnt--;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    for(ll i = A; i <= B; i++){
        if(i < A + K)
            cout << i << endl;
        else if(i > B - K)
            cout << i << endl;
    }
    return 0;
}

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

int n;
deque<int> q;

int main() {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        if ((n - i) & 1) q.push_back(x);
        else q.push_front(x);
    }
    while (!q.empty()) {
        printf("%d ", q.front()), q.pop_front();
    }
    return 0;
}

Measured memory_bytes: 2944
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()

	if a >= 10 || b >= 10 {
		fmt.Println("-1")
		return
	}
	fmt.Println(a * b)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


double diff(double ax,double ay,double bx,double by){
    double diffX = ax-bx;
    double diffY = ay-by;
    return sqrt(diffX*diffX+ diffY*diffY);
}

void func(long long A, long long B, long long H, long long M){

    double h = -H*PI/6.0 -(M/60.0)*PI*6.0 + PI/2.0;
    double m = -M*PI/30.0 + PI/2.0;

    double diffA = min(360.0-abs( (H*30+M/60.0*30)-M*6),abs((H*30+M/60.0*30) - M*6));

    diffA = diffA/360.0*(2*PI);

    cout<<setprecision(15);
    cout<<sqrt(A*A+B*B-2*A*B*cos(diffA))<<endl;

    /*
    LOG4(ax,ay,bx,by);
    cout<<setprecision(15);
    cout<<diff(ax,ay,bx,by)<<endl;
    */

}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    func(A, B, H, M);
    return 0;
}


Measured memory_bytes: 4268
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int sum = 0;
    char[] C = N.toCharArray();
    for(char c : C) {
      sum += Character.getNumericValue(c);
    }
    String ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 40800
def main():
    n ,m, x = map(int, input().split())
    c, a = [0 for i in range(n)], [[0 for i in range(m)] for j in range(n)]
    for i in range(n):
        c[i], *a[i] = [int(i) for i in input().split()]
    ans = solve(n, m, x, c, a)
    print(ans)


def solve(n, m, x, c, a):
    INF = 10 ** 9
    ans = INF
    for bits in range(2 ** n):
        cost, skill = 0, [0 for i in range(m)]
        #print(f'{bits=}')
        for i in range(n):
            bit = bits >> i & 1
            #print(f'{bit=}')
            if bit:
                cost += c[i]
                for j in range(m):
                    skill[j] += a[i][j]
        #print(skill)
        if judge(skill, x):
            ans = min(ans, cost)
    return -1 if ans == INF else ans

def judge(skill, x):
    for i in skill:
        if i < x:
            return False
    return True

if __name__ == '__main__':
    main()

Measured memory_bytes: 68612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest
{
    class Program
    {
        static int Main(string[] args)
        {
            int MAX = 200;

            char text_split = ' ';

            for (int i = 0; i < MAX; i++)
            {
                string read = Console.ReadLine();

                if (read == null) break;
                else
                {
                    string[] words = read.Split(text_split);

                    if( words[1] == null) break;
                    
                    int a_num = int.Parse(words[0]);
                    int b_num = int.Parse(words[1]);

                    //出力
                    int ab = a_num + b_num;
                    int count = 1;
                    while (ab >= 10)
                    {
                        ab /= 10;
                        count++;
                    }
                    Console.WriteLine("{0}", count);
                }
            }

            //Console.ReadKey();
            return 0;
        }

    }
}

Measured memory_bytes: 5636
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;


int main(){
	int n;
	cin >> n;
	
	int a[100];
	for (int i =0; i<n; i++) cin >> a[i];
	
	int sum = 0; 
	for (int i = 0; i<n; i++)
	{
		int current = a[i];
		for (int j = i+1; j<n; j++)
		{
			sum = sum + (current * a[j]);
		}
		
		
	}
	
	cout <<sum<<endl;
	
	
		
}



Measured memory_bytes: 256
N = int(input())
High = list(map(int, input().split()))
ans = 0
num = -1
now = float('inf')
for i in High:
    if now >= i:
        num += 1
        now = i
    else:
        ans = max(ans, num)
        num = 0
        now = i
ans = max(ans, num)
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  string a,b,c ;
  cin >> a >> b >> c ;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b. begin(), ::toupper);
  transform(c.begin(), c.end(), c. begin(), ::toupper);
  cout << a[0] << b[0] << c[0] << endl;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
	int b[n-1],a[n];
	rep(i,0,n-1){
		cin>>b[i];
	}
	rep(i,1,n-1){
		a[i]=min(b[i],b[i-1]);	
	}
	a[0]=b[0];
	a[n-1]=b[n-2];
	int sum=0;
	rep(i,0,n)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll N, K;
    cin >> N >> K;
    ll MOD = pow(10, 9) + 7;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll cnt = 0;
        for (int j = i + 1; j < N; j++) {
            if (A[i] > A[j])
                cnt++;
        }
        ll seq = ((1 + K) * K / 2) % MOD;
        sum += (cnt * seq % MOD);
        sum %= MOD;
    }

    for (int i = 1; i < N; i++) {
        ll cnt = 0;
        for (int j = i - 1; j > -1; j--) {
            if (A[i] > A[j])
                cnt++;
        }

        ll seq = (K * (K - 1) / 2) % MOD;
        sum += (cnt * seq % MOD);
        sum %= MOD;
    }

    sum %= MOD;

    cout << sum << endl;
}

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

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

   int n;
  cin >> n;
  vi a(n), ans(n);
  rep(i, n){
    cin >> a[i];
    ans[a[i]-1]=i+1;
  }
 
  rep(i, n)cout << ans[i] << " ";
  cout << "\n";

  return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
	lli n,k;
	cin>>n>>k;
	lli arr[n];fr(i,n)cin>>arr[i];
	sort(arr,arr+n);
	lli dp[k+1];
	dp[0]=0;
	rep(i,1,k){
		dp[i]=0;
		fr(j,n){
			if(i-arr[j]>=0&&dp[i-arr[j]]==0){
				dp[i]=1;break;
			}
		}
	}	
	if(dp[k]){
		cout<<"First\n";
	}else{
		cout<<"Second\n";
	}
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 1024
using System;

public static class Solution
{
  private static char[][] s_grid;
  private static int s_rows;
  private static int s_columns;
  private static int[,] s_memo;

  public static void Main()
  {
    int[] rc = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    s_rows = rc[0];
    s_columns = rc[1];
    s_grid = new char[s_rows][];
    s_memo = new int[s_rows, s_columns];
    for (int i = 0; i < s_rows; i++)
    {
      s_grid[i] = Console.ReadLine().ToCharArray();
      for (int j = 0; j < s_columns; j++) s_memo[i, j] = -1;
    }
    Console.WriteLine(CountWaysUntilEnd(0, 0));
  }

  // ONLY RIGHT AND DOWN.
  private static int CountWaysUntilEnd(int fromRow, int fromColumn)
  {
    if (fromRow == s_rows - 1 && fromColumn == s_columns - 1)
    {
      // already at end.
      return 1;
    }
    if (s_memo[fromRow, fromColumn] != -1) return s_memo[fromRow, fromColumn];
    int right = 0;
    int down = 0;
    // If I can go down.
    if (fromRow < s_rows - 1 && s_grid[fromRow + 1][fromColumn] == '.')
    {
      down = CountWaysUntilEnd(fromRow + 1, fromColumn);
    }

    // If I can go right.
    if (fromColumn < s_columns - 1 && s_grid[fromRow][fromColumn + 1] == '.')
    {
      right = CountWaysUntilEnd(fromRow, fromColumn + 1);
    }

    return s_memo[fromRow, fromColumn] = ((down + right) % 1000000007);
  }
}

Measured memory_bytes: 36072
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7

N = int(input())
HN = list(map(int, input().split()))

ans = 0
cur = 0
for i in range(N - 1):
    if HN[i + 1] <= HN[i]:
        cur += 1
    else:
        ans = max(ans, cur)
        cur = 0
ans = max(ans, cur)

print(ans)


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

int main() {
    int X;
    cin >> X;
    while (true) {
        bool flag = true;
        for (int i = 2; i < pow(X, 0.5); i++) {
            if (X % i == 0) {
                flag = false;
                break;
            }
        }
        if (flag == true) {
            cout << X << endl;
            break;
        }
        X++;
    }
    return 0;
}

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

int main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);

  if (a*b>c*d) {
    printf("%d\n",a*b);
  } else {
    printf("%d\n",c*d);
  }
  return 0;
}


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

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

	int taste_pi=0;

	if (L > 0) 
		taste_pi = (N * (N + 1) / 2 + L * N - N) - (L);
	else if (L <= 0 && L + N > 0) 
		taste_pi = (N * (N + 1) / 2 + L * N - N);
	else if (L + N <= 0)
		taste_pi = (N * (N + 1) / 2 + L * N - N) - (L + N - 1);

	cout << taste_pi << endl;

	return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const arr = [...input];
let result = [];
arr.forEach(item => {
  if(/[a-z]/.test(item)){
    result.push(item.toUpperCase());
  } else if(/[A-Z]/.test(item)) {
    result.push(item.toLowerCase());
  } else {
    result.push(item);
  }
})
console.log(result.join("").trim());


Measured memory_bytes: 16344
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b == c || b+c == a || c+a == b) cout << "Yes" << endl;
    else cout << "No" << endl;    
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000
#define INFTY 2000000000

int L[(MAX/2)+2],R[(MAX/2)+2],count;

void merge(int A[],int n,int left,int mid,int right){

  int i,j,k,n1,n2;
  
  n1 = mid - left;
  n2 = right - mid;
 
  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++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
  
      j = j + 1;
    }

  }
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,n, left, mid);
    mergeSort(A,n, mid, right);
    merge(A,n, left, mid, right);
  }
}

int main(){

  int A[MAX], n, i;
 scanf("%d",&n);

 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i] >= INFTY) return 1;
  }

  mergeSort(A,n,0,n);

  for(i=0;i<n;i++){
    if(i >= 1) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

  printf("%d\n",count);

  return 0;
  
}



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



int main() {
    int a,b;
    cin>>a>>b;
    bool j=false;
    int ans=-1;
    rep(i,(b+1)*10){
        if(j){break;}
        if(i*8/100==a){
            if(i/10==b){
                j=true;
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
 
int main(){
  int n;
  cin>>n;
  
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=1ll*i*(n/i)*((n/i)+1)/2;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    LL N, D;
    cin >> N >> D;
    int ans = 0;
    while(N--) {
        LL x, y;
        cin >> x >> y;
        if(x * x + y * y <= D * D) {
            ++ans;
        }
    }
    
    cout << ans << "\n";
    
    
    return 0;
}


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

int main() {
	int n, x;
	cin >> n >> x;

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

	int d[200];
	d[0] = 0;
	for(int i = 0; i < n; i ++){
			d[i + 1] = d[i] + l[i];
	}

	int ans = 0;
	for(int i = 0; i < n + 1; i++){
		if(d[i] <= x){
			ans++; 	
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define scanl(a) scanf("%lld",&a)
#define scanii(a,b) scanf("%d%d",&a,&b)
#define scaniii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scanll(a,b) scanf("%lld%lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scani(a) scanf("%d",&a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define sqr(a) a*a
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define vsort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define UNIQUE(X) sort(all(X)) X.resize( unique( all(X)) - X.begin() )
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}
struct point{double x,y;point(){}point(double xx,double yy){x=xx;y=yy;}};
inline double Distance(point  a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6;
const ll mod=(ll)1e9+7;
int mat[20][20];
void floyd_warshal(int v)
{
for(int k=0;k<=v;k++)
    {
        for(int i=0;i<=v;i++)
        {
            for(int j=0;j<=v;j++)
            {
                if(mat[i][j]>mat[i][k]+mat[k][j])
                {
                    mat[i][j]=mat[i][k]+mat[k][j];
                }
            }
        }
    }
}
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef shaft
        freopen("in.txt","r",stdin);
        ///freopen("out.txt","w",stdout);
    #endif ///shaft
    int h , w;
    scanii(h , w);
    for(int i = 0 ; i <=9 ; i++)
        for(int j = 0 ; j <= 9 ; j++)scani(mat[i][j]);
    floyd_warshal(9);
    int ans = 0;
    for(int i = 1; i <= h ; i++){
        for(int j = 1 ; j <= w; j++){
            int x;
            scani(x);
            if(abs(x) == 1)continue;
            ans += mat[x][1];
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
int32_t main()
{
    IOS;
    int k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    int x, y, z, k;
    ll a[1000], b, c;
    vector<ll> v, w;
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++)cin>>a[i];
    for(int i=0;i<y;i++){
        cin>>b;
        for(int j=0;j<x;j++){
            v.push_back(b+a[j]);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(int i=0;i<z;i++){
        cin>>c;
        for(int j=0;j<min(k, x*y);j++){
            w.push_back(c+v[j]);
        }
    }
    sort(w.begin(), w.end(), greater<ll>());
    for(int i=0;i<k;i++){
        cout<<w[i]<<endl;
    }
	return 0;
}

Measured memory_bytes: 43268
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;
  cout<<s.substr(0,3)<<newl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
std::vector<P> ps;
std::vector<int> mx;
bool check[100100];
ll sum1[100100], sum2[100100];

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

    std::cin >> N >> K;

    ps.resize(N);

    for(int i=0;i<N;++i){
        int t, d;
        std::cin >> t >> d;

        ps[i] = std::make_tuple(d, t);
    }

    std::sort(ps.rbegin(), ps.rend());

    for(int i=0;i<N;++i){
        int t;
        std::tie(std::ignore, t) = ps[i];

        unless(check[t]){
            mx.emplace_back(i);
            check[t] = true;
        }
    }

    sum1[0] = fst(ps[0]);
    for(int i=1;i<N;++i){
        sum1[i] = sum1[i - 1] + fst(ps[i]);
    }

    int mx_x = mx.size();

    sum2[0] = fst(ps[mx[0]]);
    for(int i=1;i<mx_x;++i){
        sum2[i] = sum2[i - 1] + fst(ps[mx[i]]);
    }

    ll maxScore = 0;

    if(mx_x >= K){
        maxScore = sum2[K - 1] + 1ll * K * K;
    }

    for(int i=0;i<K;++i){
        int j = std::upper_bound(mx.begin(), mx.end(), i) - mx.begin();

        if((i + 1) + (mx_x - j) < K){
            continue;
        }

        ll x = j + K - (i + 1);
        ll score = sum1[i] + x * x;

        if(j > 0){
            score += sum2[x - 1] - sum2[j - 1];
        }else{
            score += sum2[x - 1];
        }

        maxScore = std::max(maxScore, score);
    }

    std::cout << maxScore << std::endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 3003;

int n;
int a[N];
long long dp[N][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j >= 0; j--) {
			if (i & 1) {
				dp[i][j] = min(dp[i + 1][j + 1] - a[j], dp[i + 1][j] - a[n - 1 - i + j]);
			} else {
				dp[i][j] = max(dp[i + 1][j + 1] + a[j], dp[i + 1][j] + a[n - 1 - i + j]);
			}
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 68992
S = input()
N = len(S)
for c in "abcdefghijklmnopqrstuvwxyz":
    if c not in S:
        print(S + c)
        exit()

for i in range(N - 1, -1, -1):
    cur = ord(S[i]) - ord("a")
    for diff in range(1, 26):
        if cur + diff >= 26:
            continue
        nxt_c = chr(cur + diff + ord("a"))
        if nxt_c in S[:i]:
            continue
        print(S[:i] + nxt_c)
        exit()
else:
    print(-1)


Measured memory_bytes: 9124
import java.util.*;
public class Main {
	int INF = 1 << 24;

	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [][] pass = new int[n][n];
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
			}
			int [] size = new int[n];
			
			for(int i = 0; i < n-1; i++){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int cost = sc.nextInt();
				pass[a][b] = cost;
				pass[b][a] = cost;
				size[a]++; size[b]++;
			}
			
			for(int i = 0; i < n; i++){
				if(i != 0 && size[i] == 1){
					for(int j = 0; j < n; j++){
						if(pass[i][j] != INF){
							pass[i][j] = INF;
							pass[j][i] = INF;
						}
					}
				}
			}
			
			int sum = 0;
			for(int i = 0; i < n; i++){
				for(int j = i+1; j < n; j++){
					if(pass[i][j] != INF){
						sum+= pass[i][j];
					}
					
				}
			}
			sum *= 2;
			
			for(int j = 0; j < n; j++){
				for(int i = 0; i < n; i++){
					for(int k = 0; k < n; k++){
						pass[i][k] = Math.min(pass[i][k], pass[i][j] + pass[j][k]);
					}
				}
			}
			int max = 0;
			for(int i = 0; i < n; i++){
				if(pass[0][i] == INF) continue;
				max = Math.max(max, pass[0][i]);
			}
			System.out.println(sum - max);
			
//			//deebug
//			for(int i = 0; i < n; i++){
//				for(int j = 0; j < n; j++){
//					if(pass[i][j] == INF){
//						System.out.print("INF ");
//					}
//					else{
//						System.out.print(pass[i][j] + " ");
//					}
//				}
//				System.out.println();
//			}
		}
	}


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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

class cumsum2{
private:
  ll m,n;
  vector<vector<ll>> S;
public:
  cumsum2(ll m,ll n):m(m),n(n),S(m+1,vector<ll>(n+1)){};
  void add(ll i,ll j,ll w){ S[i+1][j+1]+=w;};
  void cumulate(){ rep(i,m)rep(j,n) S[i+1][j+1]+=S[i][j+1]+S[i+1][j]-S[i][j];};
  ll sum(ll i0,ll j0,ll i1,ll j1){return S[i1][j1]-S[i0][j1]-S[i1][j0]+S[i0][j0];};
};

void solve(){
  ll n,k; cin>>n>>k;
  cumsum2 white(2*k,2*k), black(2*k,2*k);
  rep(_,n){
    ll x,y;
    char c;
    cin>>x>>y>>c;
    x%=2*k; y%=2*k;
    if(c=='W') white.add(x,y,1);
    else black.add(x,y,1);
  }
  white.cumulate();
  black.cumulate();

  ll ans=0;
  rep(i,k)rep(j,k){
    // white
    ll score=0;
    score+=white.sum(i+k,j+k,2*k,2*k);
    score+=white.sum(0,j+k,i,2*k);
    score+=white.sum(i,j,i+k,j+k);
    score+=white.sum(0,0,i,j);
    score+=white.sum(i+k,0,2*k,j);
    score+=black.sum(i,j+k,i+k,2*k);
    score+=black.sum(0,j,i,j+k);
    score+=black.sum(i+k,j,2*k,j+k);
    score+=black.sum(i,0,i+k,j);
    chmax(ans,score);
    // black
    score=0;
    score+=black.sum(i+k,j+k,2*k,2*k);
    score+=black.sum(0,j+k,i,2*k);
    score+=black.sum(i,j,i+k,j+k);
    score+=black.sum(0,0,i,j);
    score+=black.sum(i+k,0,2*k,j);
    score+=white.sum(i,j+k,i+k,2*k);
    score+=white.sum(0,j,i,j+k);
    score+=white.sum(i+k,j,2*k,j+k);
    score+=white.sum(i,0,i+k,j);
    chmax(ans,score);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 65024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		char[] S = scan.next().toCharArray();


		//演算
		int result = 0;

		for (int i = 0; i < 3; i++) {
			if (S[i] == 'R') {
				result++;
			}
		}

		if (result == 2 && S[1] == 'S') {
			result = 1;
		}

		//結果出力
			System.out.println(result);
	}
}


Measured memory_bytes: 35472
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  int A = 1;
  sort(v.begin(),v.end());
  for(int i=0;i<N-1;i++){
    if(v[i]==v[i+1]){
    }else{
      A++;
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M,K,C;
ll a,b,c,d;
string s;
ll p[200010];
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=1;i<N-1;i++){
        if(min(p[i+1],p[i-1])<p[i] && p[i]<max(p[i-1],p[i+1]))ans++;
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for(int i = 0; i < k; i++) {
            if(i % 2 == 0) {
                if(a % 2 != 0) a--;
                int giveA = a/2;
                b += giveA;
                a -= giveA;
            } else {
                if(b % 2 != 0) b--;
                int giveB = b/2;
                a += giveB;
                b -= giveB;
            }
        }
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 21716
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>
#include <iomanip>
#include<numeric>

using namespace std;

long long maxof(long long* N, int p){
    long long big = N[0];
    for(int i = 0; i < p; i++){
        if(big < N[i]){
            big = N[i];
        }
    }
    return big;
}

long long pow2(int a, int b){
    long long ans = 1;
    for(int i = 0; i <b; i++){
        ans *= a;
    }
    return ans;
}

long long lcm(long long a,long long b){
    long long r, x, tmp;
    x = a * b;
 
  /* 自然数 a > b を確認・入替 */
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}



int main(){
    long long A = 0;
    long long B = 0;
    cin >> A; cin >> B;
    cout << lcm(A, B);
    return 0;
}

Measured memory_bytes: 256
line = STDIN.gets
n = line.to_i

flag = false
 
0.upto(25) do |i|
  0.upto(15) do |j|
    if (n == 4*i + 7*j)
      flag = true
      break
    end
  end
end

if flag
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 3836
#include<stdio.h>
int gcd(int,int);
int main(){
  int x,y;
  
  scanf("%d%d",&x,&y);
  
  printf("%d\n",gcd(x,y));
  
  return 0;
}

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



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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////



bool anspro(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    string s;cin>>s;
    vl b;
    rrep(i,n-1,0){
        for(auto x:b){
            chmin(a[i],a[i]^x);
        }
        
        if(a[i]){
            if(s[i]=='1'){
                cout<<1<<endl;return 0;
            }
            b.pb(a[i]);
        }
    }
    cout<<0<<endl;
    return 0;
}

int main(){fastio
    ll q;cin>>q;
    while(q--){
        anspro();
    }
    
    return 0;
}


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

int main() {
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200) cout << s <<endl;
  else cout<<"red"<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
	cin >> n;

	string s1,s2;
	cin >> s1 >> s2;

	ll ans = 1LL;

	int prev = s1[0] == s2[0];
	for(int i = 0; i < s1.size(); ++i){
		if(i == 0 and s1[0] == s2[0]) {
			ans *= 3;
			ans %= MOD;
		}
		else if(i == 0 and s1[0] != s2[0]){
			ans *= 6;
			ans %= MOD;
			++i;
		}
		else if(prev and s1[i] == s2[i]){
			ans *= 2;
			ans %= MOD;
		}
		else if(prev and s1[i] != s2[i]){
			ans *= 2;
			ans %= MOD;
			++i;
		}
		else if(!prev and s1[i] == s2[i]){
			ans *= 1;
		}
		else if(!prev and s1[i] != s2[i]){
			ans *= 3;
			ans %= MOD;
			++i;
		}

		prev = s1[i] == s2[i];
	}


	ppp(ans);



    return 0;
}


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

int main(){
    string s;
    cin >> s;
    for (char i = 'a';i <= 'z';i++){
        if (s.find(i) == -1){
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int R,G,B,N; cin >> R >> G >> B >> N;

    int cnt = 0;
    for (int i = 0; i*R <= N; i++) {
        for (int j = 0; j*G <= N-i*R; j++) {
            if ((N-i*R-j*G)%B==0) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque
inf = 10**10
h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [["" for i in range(w)]for j in range(h)]
point = 0
for i in range(h):
    s = stdin.readline().rstrip()
    point += s.count(".")
    for j in range(w):
        li[i][j] = s[j]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
que = deque()
lin = [[inf for i in range(w)]for j in range(h)]
lin[0][0] = 0
que.append([0,0])
while que:
    k = que.popleft()
    x = k[0]
    y = k[1]
    for i,j in zip(dx,dy):
        nx = x + i
        ny = y + j
        if nx < 0 or nx >= h or ny < 0 or ny >= w:
            continue
        elif li[nx][ny] == "#" :
            continue
        elif lin[nx][ny] == inf:
            que.append([nx,ny])
            lin[nx][ny] = lin[x][y]+1
kotae = lin[h-1][w-1]
if kotae == inf:
    print(-1)
    exit()
print(point-kotae-1)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			try{
				String[] strA = insBR.readLine().split(" ");
				int[] intA = new int[strA.length];
				for(int i = 0;i < strA.length ;i++){
					intA[i] = Integer.parseInt(strA[i]);
				}
				int x = intA[0];
				int y = intA[1];
				if(x == 0 && y == 0){
					break;
				}
				if(intA[1] < intA[0]){
					x = intA[1];
					y = intA[0];
				}
				System.out.println(x + " " + y);

			}catch(IOException e){
				e.printStackTrace();
			}catch(NumberFormatException e){
				e.printStackTrace();
			}
		}
	}
}



Measured memory_bytes: 27164
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int>> is(26);
  rep(i,n) is[s[i]-'a'].push_back(i);
  rep(i,n) is[s[i]-'a'].push_back(i+n);
  ll ans = 0;
  int p = 0;
  rep(i,m) {
    int c = t[i] - 'a';
    if (is[c].size() == 0) {
      cout << -1 << endl;
      return(0);
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return(0);
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a,b,k,t;
    cin>>n>>m;
    map<ll,ll> mp,wa;
    ll ac=0,pe=0;
    string ok="AC";
    for(i=0;i<m;i++)
    {
        string s;
        cin>>a>>s;
        if(s==ok)
        {
            if(mp[a]==0)
            {
                ac++;
                pe+=wa[a];
                mp[a]++;
            }
        }
        else
        {
            if(mp[a]==0) wa[a]++;
        }
    }
    cout<<ac<<" "<<pe;
}

Measured memory_bytes: 15992
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10;
const ll MAX_D = 10;


int main(void){
    ll N, D;
    ll X[MAX_N][MAX_D];
    ll answer = 0;

    cin >> N >> D;
    rep(n, N) rep(d, D) cin >> X[n][d];
        
    rep(i, N - 1) For(j, i + 1, N){
        ll dist = 0;
        rep(d, D) dist += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
        For(k, 1, 130) if (dist == k * k) answer ++; 
    }

    cout << answer << endl;

    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h,n;
	cin >> h >> n;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;
	
	vector<long long> dp(h+10101,1LL<<55);
	dp[0]=0;
	for(int i=1;i<dp.size();i++){
		for(int j=0;j<n;j++){
			if((i-a[j].first)<0) continue;
			dp[i]=min(dp[i],dp[i-a[j].first]+a[j].second);
		}
	}
	
	long long res=1LL<<55;
	for(int i=h;i<dp.size();i++) res=min(res,dp[i]);
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 384