akhauriyash/Code-Regression huggingface dataset:
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int A, B;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
    }

    void solve(PrintWriter out) {
        if (A * B % 2 != 0) {
            out.println("Yes");
        } else if (A * B * 3 % 2 != 0) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
def kaibun(s):
    if len(s) == 2:
        if s[0] == s[1]:
            return 1
        else:
            return 0
    else:
        h = int(len(s) / 2)
        for a, b in zip(s[:h], reversed(s[h+1:])):
            if a != b: return 0
        return 1

line = input()
n = len(line)
mae = int((n-1)/2)
usiro = int((n+3)/2)-1
kaibun1 = line[0:mae]
kaibun2 = line[usiro:]

if kaibun(line) == 1 and kaibun(kaibun1) == 1 and kaibun(kaibun2) == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
const int maxs = 103;
const int MAXS = 1500;
int a[maxs];
int fact[maxs];
int dp[maxs][maxs][MAXS];
int n,k;


void pre()
{
    fact[0] = fact[1] = 1;
    
    for(int i = 2;i < maxs;++i)
        fact[i] = (i * fact[i - 1]) % mod;
}

int go(int pos,int start,int XOR)
{
    if(pos == n + 1)
    {
        if(XOR == k && start == 0)
            return 1LL;
        else
            return 0LL;
    }
    if(start == 0)
    {
        if(XOR == k)
            return 1LL;
        else
            return 0LL;
    }
    
    if(dp[pos][start][XOR] != -1)
        return dp[pos][start][XOR];
    
    int ans = 0;
    
    ans = (ans % mod + go(pos + 1,start - 1,XOR ^ a[pos]) % mod) % mod;
    ans = (ans % mod + go(pos + 1,start,XOR) % mod) % mod;
    
    return dp[pos][start][XOR] = ans;
}


signed main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    pre();
    
    memset(dp,-1,sizeof dp);
    
    cin >> n >> k;
    
    for(int i = 1;i <= n;++i)
        cin >> a[i];
    
    int ans = 0;
        
   for(int i = 1;i <= n;++i)
   {
       int res = (go(1,i,0) % mod * fact[i] % mod) % mod;
       ans = (ans % mod + res % mod) % mod;
   }
   
   cout << ans << '\n';
}


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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int len_s = s.length();
    int len_t = t.length();
    vector < vector <int> > dp((len_s+1), vector<int>(len_t+1) );
    for(int i = 0;i <= len_s;i++)
    {
        for(int j = 0;j <= len_t;j++)
        {
            if(i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if(s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string ans;
    int i = len_s; int j = len_t;
    while(i != 0 && j != 0)
    {
        if(s[i - 1] == t[j - 1])
        {
            ans += s[i - 1];
            i--;
            j--;
        }
        else if(dp[i - 1][j] > dp[i][j - 1])i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;


const double pi = 3.14159265359;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	pair<int,int> hm;
	if( m2 > k%60){
		hm = mp((h2 - k/60),(m2 - k%60));	
	}
	else{
		hm = mp((h2 - k/60 - 1),(m2 + 60 - k%60));	
	}
	ll ans;
	if( hm.S > m1%60){
		ans = (hm.first - h1)*60 + (hm.second - m1%60);
	}
	else{
		ans = (hm.first - h1 - 1)*60 + (hm.second + 60 - m1%60);	
	}
	cout<<ans<<nl;
	return 0;
}



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


int main(){
  int N, M;
  cin >> N >> M;
  int sum=0;
  for(int ii=0; ii<M; ii++){
    int a;
    cin >> a;
    sum+=a;
  }
  cout << (N-sum>=0?N-sum:-1) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
double res = 0;
  
  cin >> a;
  
  if(a%2==0){
    res = 0.5;
     cout << res << endl;
  }
  else {
    res = ((double)a+1)/2/(double)a;
    cout << res << endl;
  }
  
}

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

int main() {
    string s, sl, sr;
    cin >> s;

    string ss;
    for (int i=0; i<s.size(); i++) {
        if (s.at(i) != 'x') {
            ss += s.at(i);
        }
    }

    int ans=0;

    for (int i=0; i<ss.size()/2; i++) {
        sl += ss.at(i);
        sr += ss.at(ss.size()-1-i);
    }
    if (sl == sr) {
        int r=s.size()-1, l=0;
        while (l<=r) {
            if (s.at(l) == s.at(r)) {
                l++;
                r--;
            } else if (s.at(l) == 'x') {
                ans++;
                l++;
            } else {
                ans++;
                r--;
            }
        }
    } else ans = -1;
    

    cout << ans << endl;
}

Measured memory_bytes: 640
while(True):
  A, B = map(int, input().split())
  if (A == 0 and B ==0):
    break
  vert = []
  hori = []

  hist = {}

  for i in range(B - 1):
    vert.append(list(map(int, input().split())))
    hori.append(list(map(int, input().split())))

  vert.append(list(map(int, input().split())))

  next_pos = [{"x": 0, "y": 0, "step": 0}]
  hist['0::0'] = 0
  while(True):
    if (len(next_pos) == 0):
      pos = {}
      pos["step"] = 0
      break
    pos = next_pos.pop(0)
    
    if (pos["x"] == A - 1 and pos["y"] == B - 1):
      pos["step"] += 1
      break

    # 右方向への移動
    if (f'{pos["x"] + 1}::{pos["y"]}' not in hist and pos["x"] < A - 1 and pos["y"] < B and vert[pos["y"]][pos["x"]] == 0):
      next_pos.append({"x": pos["x"] + 1, "y": pos["y"], "step": pos["step"] + 1})
      hist[f'{pos["x"] + 1}::{pos["y"]}'] = 0

    # 下方向への移動
    if (f'{pos["x"]}::{pos["y"] + 1}' not in hist and pos["x"] < A and pos["y"] < B - 1 and hori[pos["y"]][pos["x"]] == 0):
      next_pos.append({"x": pos["x"], "y": pos["y"] + 1, "step": pos["step"] + 1})
      hist[f'{pos["x"]}::{pos["y"] + 1}'] = 0

    # 左方向への移動
    if (f'{pos["x"] - 1}::{pos["y"]}' not in hist and pos["x"] - 1 >= 0 and pos["y"] < B and vert[pos["y"]][pos["x"] - 1] == 0):
      next_pos.append({"x": pos["x"] - 1, "y": pos["y"], "step": pos["step"] + 1})
      hist[f'{pos["x"] - 1}::{pos["y"]}'] = 0

    # 上方向への移動
    if (f'{pos["x"]}::{pos["y"] - 1}' not in hist and pos["x"] < A and pos["y"] - 1 >= 0 and hori[pos["y"] - 1][pos["x"]] == 0):
      next_pos.append({"x": pos["x"], "y": pos["y"] - 1, "step": pos["step"] + 1})
      hist[f'{pos["x"]}::{pos["y"] - 1}'] = 0

  print(pos["step"])



Measured memory_bytes: 5768
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


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


def main():
    n = input_int()
    x_cur, y_cur, t_cur = 0, 0, 0
    for _ in range(n):
        t, x, y = input_int_list()
        dx = abs(x - x_cur)
        dy = abs(y - y_cur)
        dt = t - t_cur
        if dx + dy > dt:
            print("No")
            return
        if dt % 2 != (dx + dy) % 2:
            print("No")
            return
        else:
            x_cur, y_cur, t_cur = x, y, t
    print("Yes")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 73496
#include "bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
//#define int long long
//#define error freopen("error.txt","w",stderr);
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long int
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
#define mod 1000000007
#define N 1000000000
int in(){
int n;cin>>n; 
return n;}
void _do_(){
	int k=in();
	ll ans=0;
	rep(i,1,k+1)
	rep(j,1,k+1)
	rep(m,1,k+1)
	ans+=__gcd(i,__gcd(j,m));
	cout<<ans<<endl;


}
signed main(){
fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}

Measured memory_bytes: 3656
#define REP(i,n) for (int i=0;i<(n);i++)
#include <iostream>
using namespace std;

int main(){
        int c[100] = {};
        int a,b;
        while(cin>>a>>b){
                c[a-1]++;
                c[b-1]++;
                if(a==0&&b==0){
                        bool e = 1;
                        for(int i=2;i<100;i++){
                                if(c[i] % 2 != 0) e = 0;
                        }
                        if(c[0] % 2 != 0 && c[1] % 2 != 0 && e) cout << "OK" << endl;
                        else cout << "NG" << endl;
                        REP(i,100){
                                c[i] = 0;
                        }
                }
        }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000000000000
using P = pair<int,int>;
 
int main() {
  ll n;
  cin >> n;
  vll A(n);
  rep(i,n){
    cin >> A[i];
  }
  vll front(n);
  vll back(n);
  front[0] = A[0];
  rep1(i,n){
    front[i] = front[i-1] + A[i];
  }
  back[n-1] = A[n-1];
  for(int i = n-2;i >= 0;i--){
    back[i] = back[i+1] + A[i];
  }
  ll ans = INF;
  rep(i,n-1){
    ans = min(ans,abs(front[i] - back[i+1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

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

	// 15まで無理やり埋める
	for (size_t i = S.size(); i < 15; i++) {
		S.push_back('o');
	}

	const ll count = count_if(ALL(S), [](auto c) {return c == 'o'; });
	const string ans = count >= 8 ? "YES" : "NO";

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


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

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    int high = x, lowe = x;
    while (binary_search(vec.begin(), vec.end(), high)) {
        ++high;
    }
    while (binary_search(vec.begin(), vec.end(), lowe)) {
        --lowe;
    }
    cout << (high - x < x - lowe ? high : lowe) << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
//#include<iostream>
//#include<cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+10;
void io(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	io();
	int n,a,b;cin>>n;
	ll ans=0;cin>>b;
	ll anss=0;
	for(int i=1;i<n;i++){
		cin>>a;
		if(b>=a)ans++;
		else ans=0;
		if(ans>anss)anss=ans;
		b=a; 
	}
	cout<<anss<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_142
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int x = n / 2;
            if (n % 2 == 1) x++;
            WriteLine(1.0 * x / n);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
	int sm,sn,s[5],i,tmp;
	char a[6]="ABCDE";
	while(cin>>sm>>sn,sm+sn){
		s[0]=sm+sn;
		int ss[5]={};
		for(i=1;i<5;i++){
			cin>>sm>>sn;
			s[i]=sm+sn;
		}
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				if(i!=j&&s[i]>s[j])ss[i]++;
			}
			if(ss[i]==4)cout<<a[i]<<' '<<s[i]<<endl;
		}
	}
}

Measured memory_bytes: 1160
use std::io;
use std::cmp;
use std::str::FromStr;

fn main() {
    let mut line = String::new();

    io::stdin().read_line(&mut line).unwrap();
    let first_line_words: Vec<&str> = line.trim().split(" ").collect();
    let x = i32::from_str(first_line_words[2]).unwrap();
    let y = i32::from_str(first_line_words[3]).unwrap();

    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let xs = line.trim().split(" ").map(|x| i32::from_str(x).unwrap()).collect::<Vec<_>>();

    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let ys = line.trim().split(" ").map(|x| i32::from_str(x).unwrap()).collect::<Vec<_>>();

    if xs.into_iter().fold(x, |max, x| cmp::max(x, max) ) < ys.into_iter().fold(y, |min, y| cmp::min(y, min)) {
        println!("No War");
    } else {
        println!("War");
    }
}

Measured memory_bytes: 4352
// AtCoder Beginner Contest 110 - Problem D: Factorization (https://abc110.contest.atcoder.jp/tasks/abc110_d)
#include <bits/stdc++.h>

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)

using namespace std;

using ll = long long;

const int MAX { 200010 };
const ll MOD { 1000000007 };

map<int, int> factorization(ll M)
{
    map<int, int> fs;

    for (ll p = 2; p * p <= M; ++p)
    {
        int k = 0;

        while (M % p == 0)
        {
            M /= p;
            ++k;
        }

        if (k)
            fs[p] = k;
   }

    if (M > 1)
        fs[M] = 1;

    return fs;
}

ll fs[MAX], inv[MAX];

ll mod_pow(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll combinations(ll N, ll M)
{
    if (M > N)
        return 0;

    ll ans = (fs[N] * inv[M]) % MOD;
    ans = (ans * inv[N - M]) % MOD;

    return ans;
}

void solve(ll N, ll M)
{
    auto fs = factorization(M);

    ll ans = 1;

    for (const auto& f : fs)
    {
        int p, k;
        tie(p, k) = f;

        ans = (ans * combinations(k + N - 1, k)) % MOD; 
    }

    cout << ans << endl;
}

void precomp()
{
    fs[0] = inv[0] = 1;
    
    REP(i, 1, MAX - 1)
        fs[i] = (fs[i - 1] * i) % MOD;

    REP(i, 1, MAX - 1)
        inv[i] = mod_pow(fs[i], MOD - 2);
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    int N, M;
    cin >> N >> M;

    solve(N, M);

    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    while (cin >> n >> m) {
        vector<PII> J(n);
        FOR(i,0,n) {
            int a,b; cin >> a >> b; J[i] = PII(m-a,b);
        }
        sort(ALL(J));
        multiset<int> S;
        int now = 0;
        FOR(i,0,n) {
            const int start = J[i].first;
            const int value = J[i].second;
            if (start < 0)
                continue;
            if (start < now) {
                if (S.size() && *S.begin() < value) {
                    S.erase(S.begin());
                    S.insert(value);
                }
            }
            else {
                S.insert(value);
                now++;
            }
        }
        int ans = 0;
        FOR_ALL(x,S)
            ans += *x;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <queue>
#include <thread>
#include<bits/extc++.h>

using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")

#define ll long long

#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %c%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %c%d: %lld\n", ch, cs, x)
#define pcsyn(ch, cs, st) printf("Case %c%d: %s\n", ch, cs, (st) ? "Yes" : "No")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)
#define plld(x, y) printf("%lld %lld\n", x, y)

#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define pb(x) push_back(x)

inline long long max(long long x, long long y) { return x > y ? x : y; }

inline long long min(long long x, long long y) { return x > y ? y : x; }

long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }

int main(){
    long long d,t,s;
    gllt(d, t, s);
    puts((t * s >= d) ? "Yes" : "No");
}

Measured memory_bytes: 3676
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>

using namespace std;
const int N = 20;

int read(void)
{
	int s = 0, w = 0; char c = getchar();
	while (c < '0' or c > '9') w |= c == '-', c = getchar();
	while (c >= '0' and c <= '9') s = s*10+c-48, c = getchar();
	return w ? -s : s;
}

int n, m, sum = 0;
int f[1<<N][N], S[1<<N], val[N][N], in[1<<N];

vector <int> a[N];

int main(void)
{
	n = read(), m = read();
	memset(f,-1,sizeof f);
	for (int i=1,x,y,v;i<=m;++i)
	{
		x = read()-1, y = read()-1, v = read();
		val[x][y] = val[y][x] = v;
		sum += v;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i=0;i<1<<n;++i)
	    for (int j=0;j<n;++j)
			if (((i>>j) & 1) == 0 and in[i|(1<<j)] == 0) {
	        	int cnt = S[i];
	        	for (int k=0;k<a[j].size();++k)
	        	    if ((i >> a[j][k]) & 1) cnt += val[j][a[j][k]];
	        	S[i|(1<<j)] = cnt;
	        }
	f[1][0] = 0;
	for (int i=0;i<1<<n;++i)
	    for (int j=0;j<n;++j) if (((i >> j) & 1) and f[i][j] != -1)
	    {
	    	if (f[i][j] == -1) continue;
	    	for (int k=0;k<n;++k) if (((i >> k) & 1) == 0 && val[j][k]) 
	    	    f[i|(1<<k)][k] = max(f[i|(1<<k)][k],f[i][j]+val[j][k]);
	    	int t = (1<<j) | (((1<<n)-1)^i);
	    	for (int k=t;k;k=(k-1)&t) 
	    		if ((k >> j) & 1) f[i|k][j] = max(f[i|k][j],f[i][j]+S[k]);
	    }  
	cout<<(sum - f[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 84224
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    N, M = map(int, input().split())
    H = [0] + [int(x) for x in input().split()]
    graph = [[] for _ in [0] * (N + 1)]
    for i in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
    
    res = N
    for i in range(1, N + 1):
        if graph[i]:
            for j in graph[i]:
                if H[j] >= H[i]:
                    res -= 1
                    break
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30112
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Map<Long, Integer> cntMap = new HashMap<>();
        long N = sc.nextLong();
        if(N == 1){
            System.out.println("0");
            return;
        }
        long lim = (long) (Math.sqrt(N)+3);
        for(long i=2;i<=lim;i++){
            if(N % i == 0){
                while(N % i == 0) {
                    N /= i;
                    cntMap.putIfAbsent(i, 0);
                    cntMap.put(i, cntMap.get(i) + 1);
                }
            }
        }
        if(N != 1){
            cntMap.put(N, 1);
        }
        int cnt=0;
        for(int size:cntMap.values()){
            int s = size;
            int now = 1;
            while(s >= now) {
                s -= now;
                now++;
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

int main() {
    int k;
    cin >> k;
    vector<int> seen(k, 0);
    deque<P> dq;
    dq.emplace_back(1, 1);
    while (dq.size()) {
        int cost = dq.front().first, num = dq.front().second;
        dq.pop_front();
        if (num % k == 0) {
            cout << cost << endl;
            return 0;
        }
        if (seen[num]) continue;
        seen[num] = 1;
        dq.emplace_front(cost, (num * 10) % k);
        dq.emplace_back(cost + 1, (num + 1) % k);
    }
}

Measured memory_bytes: 4588
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL P = ((1LL << 30) + 1);
//const LL P = 10;
const LL N = 1234567891;
const LL N2 = 1000000009;

LL a[2000005],b[2000005],c[2000005],d[2000005];
LL pc[2000005],pd[2000005],pwr[2000005],pc2[2000005],pd2[2000005],pwr2[2000005];
LL n,m;

LL judge(LL l,LL r){
	return (pc[n - 1] == (pd[r] - (pd[l - 1] * pwr[r - l + 1] % N) + N) % N) && (pc2[n - 1] == (pd2[r] - (pd2[l - 1] * pwr2[r - l + 1] % N2) + N2) % N2);
}

int main(){
	ios::sync_with_stdio(false);
	pwr[0] = 1; for(LL i = 1;i <= 200000;i ++) pwr[i] = (pwr[i - 1] * P) % N;
	pwr2[0] = 1; for(LL i = 1;i <= 200000;i ++) pwr2[i] = (pwr2[i - 1] * P) % N2;
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++) cin >> b[i];
	for(LL i = n + 1;i <= (n << 1);i ++) b[i] = b[i - n];
	
	for(LL i = 1;i < n;i ++) c[i] = a[i] ^ a[i + 1];
	for(LL i = 1;i < (n << 1);i ++) d[i] = b[i] ^ b[i + 1];
	
	for(LL i = 1;i < n;i ++) pc[i] = (pc[i - 1] * P + c[i]) % N;
	for(LL i = 1;i < (n << 1);i ++) pd[i] = (pd[i - 1] * P + d[i]) % N;
	for(LL i = 1;i < n;i ++) pc2[i] = (pc2[i - 1] * P + c[i]) % N2;
	for(LL i = 1;i < (n << 1);i ++) pd2[i] = (pd2[i - 1] * P + d[i]) % N2;
	
	for(LL i = n + 1;i >= 2;i --){
		if(judge(i,i + n - 2))
			cout << (n + 1 - i) << ' ' << (a[n + 2 - i] ^ b[1]) << endl;
	}
	return 0;
} 

Measured memory_bytes: 45952
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    vector<ll> aa(n);
    rep (i, 0, n) cin >> aa[i];

    a = accumulate(aa.begin(), aa.end(), 0LL);

    vector<ll> bb;

    rep (i, 0, n) {
        double gg = (double)(a / 4.0);
        gg /= m;
        if (double(aa[i]) >= gg) bb.emplace_back(aa[i]);
    }

    if (bb.size() >= m) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;



    
    return 0;
}


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

long long lcm(long long a,long long b)
{
    return (a*(__gcd(a,b))*b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     string s;
     long long n,i,j=0,cnt=0;
     cin>>n;
     cin>>s;
     for(i=0;i<n;i++)
     {
        if(s[i]=='R')
        {
            cnt++;
        }
     }
    for(i=0;i<cnt;i++)
    {
        if(s[i]=='W')
        {
            j++;
        }
    }
    cout<<j<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long int
double distance(int x1, int y1, int x2, int y2) 
{ 
    // Calculating distance 
    return sqrt(pow(x2 - x1, 2) +  
                pow(y2 - y1, 2) * 1.0); 
} 
int factorial(int n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
}

signed main()
{
	int n;
	cin>>n;
	int t=n;
	vector<pair<double,double>> p;
	while(t--)
	{
		double x,y;
		cin>>x>>y;
	    	p.push_back(make_pair(x,y));

	}
	double t_distance=0;
	for(int i=0;i<p.size();i++)
	{
	     for(int j=i+1;j<p.size();j++)
		t_distance+=distance(p[i].first,p[i].second,p[j].first,p[j].second);
	}
	double answer=factorial(n-1)*2*t_distance/factorial(n);
	
	cout<<setprecision(10)<<answer<<endl;

	return 0;

}

Measured memory_bytes: 256
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }

    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let dx = [-1, 0, 1, 0];
    let dy = [0, -1, 0, 1];
    let mut printer = ContestPrinter::new();
    let (h, w) = readl!(usize, usize);
    let mut s = Vec::new();
    for _ in 0..h {
        s.push(readl!(String).into_bytes());
    }
    let sum = s.iter().fold(0, |sum, v| {
        v.iter().fold(sum, |sum, &x| {
            if x == '.' as u8 {
                sum+1
            } else {
                sum
            }
        })
    });
    let s = s;

    // debug!(s);
    let check = |x, y| 0 <= x && x < h as i32 && 0 <= y && y < w as i32;
    let mut qu = std::collections::VecDeque::new();
    let mut used = vec![vec![false; w]; h];
    qu.push_back((0, 0, 0));
    while let Some((v, x, y)) = qu.pop_front() {
        if used[x][y] {
            continue;
        }
        used[x][y] = true;
        if x == h-1 && y == w-1 {
            // debug!(v);
            printer.println(sum-v-1);
            return;
        }
        for k in 0..4 {
            let nx = x as i32 +dx[k];
            let ny = y as i32 +dy[k];
            if check(nx, ny) {
                if s[nx as usize][ny as usize] == '.' as u8 {
                    qu.push_back((v+1, nx as usize, ny as usize));
                }
            }
        }
    }
    printer.println(-1);
}


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

A.sort(reverse=True)
ans = 0
if N >= 2:
    ans += A[0]

if N >= 3:
    idx = 1
    for i in range(N-2):
        ans += A[idx]
        if i % 2 == 1:
            idx += 1

print(ans)

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

int main() {
  string N;
  int a = 0;
  cin >> N;
  for (int i = 0; i < N.length() ; i++) {
    a += (int)(N[i] - '0');
  }
  if (stoi(N) % a == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d;
    cin >>a >>b >>c;
    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    if(b>c){
        d = b;
        b = c;
        c = d;
    }
    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    if (x > y) {
        ll tmp = x;
        x = y;
        y = tmp;
    }

    if (y % x == 0)
        return x;
    else 
        return gcd(x, y%x);
}

int main() {
    ll a, b;    cin >> a >> b;
    ll g = gcd(a, b);
    ll ans = a * b / g;
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s, t;
  int a, b;
  string u;

  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if(u == s){
    a--;
  }
  else{
    b--;
  }

  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
F_S = [list(map(int,input().split())) for _ in range(N)]

cnt = 0
for f,s in F_S:
  if cnt >= 3:
    break
  if f == s:
    cnt += 1
  else:
    cnt = 0
if cnt >= 3:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9164
n, k=input().split()
a=input().split()
a=list(map(int,a))
a=list(map(lambda x: x-1,a))
n=int(n)
k=int(k)
cycle=0
step=0
now=0
ini=0
now2=n
count=[0]*n
count[0]=1

while k>0:
  now=a[now]
  k+=-1
  if count[now]==1:
    ini=now
    while now2!=ini:
      if cycle==0:
        now2=ini
      now2=a[now2]
      cycle+=1
    else:
      k=k%cycle
      for j in range(k):
        now=a[now]
      break
  count[now]=1



       

print(now+1)

Measured memory_bytes: 32244
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

li dp(int sum, vector<int>& v, int pos, vector<vector<vector<li>>> &mem, int need) {
  if (pos == v.size()) {
    if (sum == 0 && need == 0) return 1;
    else return 0;
  }
  if (sum == 0 && need == 0) return 1;
  if (sum < 0) return 0;
  if (need < 0) return 0;
  if (mem[pos][sum][need] != -1) return mem[pos][sum][need];
  return mem[pos][sum][need] = dp(sum - v[pos], v, pos + 1, mem, need - 1) + dp(sum, v, pos + 1, mem, need);
}

void _main(int tc) {
  int n, a;
  cin >> n >> a;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  vector<vector<vector<li>>> mem(51, vector<vector<li>>(50 * 50 + 1, vector<li>(51, -1)));

  li ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp(i * a, v, 0, mem, i);
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 56192
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val block = readLine()!!.split(" ").map { it.toInt() }
    var current = 1
    var ans = 0
    for(i in (0 until n)) {
        if(block[i] == current) {
            current++
        } else {
            ans++
        }
    }
    if(current == 1) {
        println(-1)
    } else {
        println(ans)
    }
}


Measured memory_bytes: 83056
#include <iostream>
#include <cassert>

int main()
{
  char b;
  std::cin >> b;
  assert(b == 'A' or b == 'C' or  b == 'G' or b == 'T');

  if (b == 'A')
    std::cout << 'T' << std::endl;
  else if (b == 'C')
    std::cout << 'G' << std::endl;
  else if (b == 'G')
    std::cout << 'C' << std::endl;
  else if (b == 'T')
    std::cout << 'A' << std::endl;
  else
    assert(false);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//{
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
};
//{
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);
//}

int N;
vector<lint> A;
char s[205];
map<int, lint> baza;

bool komb(lint x) {
	FORD(i,63,0) {
		if (x&(1LL<<i)) {
			if (baza.find(i) != baza.end()) {
				x^=baza[i];
			} else{
				return false;
			}
		}
	}
	return true;
}

void dodaj(lint x) {
	if (komb(x)) return;
	FORD(i,63,0) {
		if (x&(1LL<<i)) {
			if (baza.find(i) != baza.end()) {
				x ^= baza[i];
			} else {
				baza[i] = x;
				return;
			}
		}
	}

}

void solve() {
	read(N);
	A.clear();
	baza.clear();
	FOR(i,0,N) {
		lint u; scanf("%lld", &u);
		A.pb(u);
	}
	scanf("%s", s);
	FORD(i,N-1,0) {
		if (s[i]=='0') {
			dodaj(A[i]);
		} else {
			if (komb(A[i])) {
				continue;
			} else {
					printf("1\n");
					return;
				}
			}
		}	
	printf("0\n");
}

int main() {
	make(z);
	while (z--) {
		solve();
	}
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll a, b, c;
	ll N, Y;
	ll x = -1, y = -1, z = -1;
	cin >> N >> Y;
	for (a = 0; a <= N; a++) {
		for (b = 0; b <= N - a; b++) {
			c = N - a - b;
			if (Y == 10000 * a + 5000 * b+1000 * c)
				x = a, y = b, z = c;
		}
	}
	
	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int best = 4280;
        int k;
        int n = 0;
        int w = scan.nextInt();

        while (w != -1) {
            if (w > 30) {
                n = 0;
                n += 1150 + 125 * 10 + 140 * 10 + 160 * (w - 30);

            } else if (w > 20 && w <= 30) {
                n = 0;
                n += 1150 + 125 * 10 + 140 * (w - 20);

            } else if (w > 10 && w <= 20) {
                n = 0;
                n += 1150 + 125 * (w - 10);

            } else if (w <= 10) {
                n = 0;
                n += 1150;
            }

            k = best - n;
            System.out.println(k);
            w = scan.nextInt();
        }
    }
}



Measured memory_bytes: 26232
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int s[100005];
int ss[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[0]=a[n+1]=0;
    int ans=0,cnt=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
    {
        ans+=abs(a[i]-a[i-1]);
        s[i]=ans;
    }
    for(int i=n;i>=1;i--)
    {
        cnt+=abs(a[i+1]-a[i]);
        ss[i]=cnt;
    }
    for(int i=1;i<=n;i++)
        printf("%d\n",s[i-1]+ss[i+1]+abs(a[i+1]-a[i-1]));
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort(v.begin(), v.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed

int main(){
    string s;
    cin >> s;
    for(int i=0; i < s.len; i+=2){
        cout << s.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

int main()
{
    int n,t,m0,m,xp[10],yp[10],x[10],y[10],i,k,j,xp0,yp0,l,same,samen;
	
	while(0<=scanf("%d",&n)){
		
		if(n==0){
			break;
		}
		
		for(i=0;i<10;i++){
			xp[i]=0;
			yp[i]=0;
			x[i]=0;
			y[i]=0;
		}
		
		scanf("%d",&m0);
		for(i=0;i<m0;i++){
			scanf("%d%d",&xp[i],&yp[i]);
		}
		
		xp0=xp[0];
		yp0=yp[0];
		
		samen=0;
		
		for(i=0;i<m0;i++){
			
			xp[i]=xp[i]-xp0;
			yp[i]=yp[i]-yp0;
		}
			
			
		
		for(i=1;i<=n;i++){
			
			scanf("%d",&m);
			
			for(k=0;k<10;k++){
				x[k]=0;
				y[k]=0;
			}
			
			for(k=0;k<m;k++){
				scanf("%d%d",&x[k],&y[k]);
			}
			
			if(m!=m0){
				continue;
			}
			
			for(k=0;k<2;k++){
				xp0=x[0];
				yp0=y[0];
			
				for(j=0;j<m;j++){
					x[j]-=xp0;
					y[j]-=yp0;
				}
				for(l=0;l<4;l++){
					same=0;
					
					for(j=0;j<m;j++){
						if(x[j]==xp[j] && y[j]==yp[j]){
							++same;
						}
						if (same==m){
							printf("%d\n",i);
						}
					}
					
					for(j=0;j<10;j++){
						t=-y[j];
						y[j]=x[j];
						x[j]=t;
					}
					
				}
				
				for(l=0;l<=(m-1)/2;l++){
					j=x[l];
					x[l]=x[m-1-l];
					x[m-1-l]=j;
					j=y[l];
					y[l]=y[m-1-l];
					y[m-1-l]=j;
				}
			}
		}
		printf("+++++\n");
	}
	
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;
const int MAXN = 500005;

int n, m, k;
int a, b, c, d, e, f;
string s, t, r;
char c1, c2, c3;

int A[MAXN];
int B[MAXN];

int main() {
	cin >>s;
  	for (int i=0 ; i<s.size() ; i++) s[i] = 'x';
	cout <<s<<endl;
	return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int h,w; cin >> h >> w;
    int n = 26;
    char f[h][w]; 
    rep(i,h) rep(j,w) cin >> f[i][j];
    int cnt[n];
    rep(i,n) cnt[i] = 0;
    rep(i,h) rep(j,w) cnt[f[i][j]-'a']++;
    bool ans = true;
    int a = (h/2) * (w/2),c = (h%2) * (w%2);
    int b = ((h*w) - a * 4 - c)/2;
    rep(i,n){
        while(cnt[i] >= 4 && a > 0){
            cnt[i] -= 4;
            a--;
        }
    }
    rep(i,n){
        while(cnt[i] >= 2 && b > 0){
            cnt[i] -= 2;
            b--;
        }
    }
    rep(i,n){
        while(cnt[i] >= 1 && c > 0){
            cnt[i] -= 1;
            c--;
        }
    }
    if(a == 0 && b == 0 && c == 0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256