akhauriyash/Code-Regression huggingface dataset:
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

n=int(input())
s=input()
a=[0]*(n+1)
a[0]="S"
a[1]="S"
for i in range(1,n):
    if (a[i]=="S" and s[i]=="o") or (a[i]=="W" and s[i]=="x"):
        a[i+1]=a[i-1]
    else:
        if a[i-1]=="W":
            a[i+1]="S"
        else:
            a[i+1]="W"
if a[n]==a[0] and ((s[0]=="o" and a[1]==a[n-1] or s[0]=="x" and a[1]!=a[n-1])) :
    print("".join(a[:n]))
    exit()
a=[None]*(n+1)
a[0]="S"
a[1]="W"
for i in range(1,n):
    if (a[i]=="S" and s[i]=="o") or (a[i]=="W" and s[i]=="x"):
        a[i+1]=a[i-1]
    else:
        if a[i-1]=="W":
            a[i+1]="S"
        else:
            a[i+1]="W"
if a[n]==a[0] and ((s[0]=="o" and a[1]==a[n-1] or s[0]=="x" and a[1]!=a[n-1])):
    print("".join(a[:n]))
    exit()
    
a=[0]*(n+1)
a[0]="W"
a[1]="S"
for i in range(1,n):
    if (a[i]=="S" and s[i]=="o") or (a[i]=="W" and s[i]=="x"):
        a[i+1]=a[i-1]
    else:
        if a[i-1]=="W":
            a[i+1]="S"
        else:
            a[i+1]="W"
if a[n]==a[0] and ((s[0]=="o" and a[1]!=a[n-1] or s[0]=="x" and a[1]==a[n-1])):
    print("".join(a[:n]))
    exit()
a=[None]*(n+1)
a[0]="W"
a[1]="W"
for i in range(1,n):
    if (a[i]=="S" and s[i]=="o") or (a[i]=="W" and s[i]=="x"):
        a[i+1]=a[i-1]
    else:
        if a[i-1]=="W":
            a[i+1]="S"
        else:
            a[i+1]="W"

if a[n]==a[0] and ((s[0]=="o" and a[1]!=a[n-1] or s[0]=="x" and a[1]==a[n-1])):
    print("".join(a[:n]))
    exit()
print(-1)


Measured memory_bytes: 79964
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

int main(){
  while(1){
    cin >> n;
    if(!n)break;
    vs vec;
    rep(i,0,n){
      cin >> s;
      vec.pb(s);
    }
    m = -1;
    rep(i,0,vec.sz){
      t = "";
      l = 0;
      rep(j,i,vec.sz){
        t += vec[j];
        // cout << t << " " << t.sz << endl;
        if(t.sz == 5)l++;
        if(t.sz == 5+7)l++;
        if(t.sz == 5+7+5)l++;
        if(t.sz == 5+7+5+7)l++;
        if(t.sz == 5+7+5+7+7)l++;
        if(t.sz >= 31){
          if(l == 5){
            m = i + 1;
            break;
          }
        }
      }
      if(m != -1)break;
    }
    print(m);
  }
  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	string str;
	while(cin>>str){
		int l[12], j=0, sum=0;
		string s;
		for(int i=0; i<str.length(); i++){
			if(str[i]!=','){
				s+=str[i];
			}
			else{
				l[j]=stoi(s);
				j++;
				s="";
			}
		}
		l[j]=stoi(s);
		int v1=l[10], v2=l[11];
		for(j=0; j<10; j++)
			sum+=l[j];
		double s1=(double)v1*sum/(v1+v2);
		j=0;
		int long1=0;
		while(s1>=long1){
			long1+=l[j];
			j++;
		}		
		if(s1==long1-l[j])
			cout<<j-1<<endl;
		else
			cout<<j<<endl;

	}
	return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
int main(void){
    int i,n,a,min=1000000,max=-1000000;
    long long int sum=0;
    scanf("%d",&n);
    i=0;
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(max<a){
            max=a;
        }
        if(min>a){
            min=a;
        }
        sum+=a;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string a, b;
    cin >> a >> b;
    if (a.size() + 1 != b.size())
    {
        cout << "No" << endl;
        return 0;
    }
    REP(i, a.size())
    {
        if (a[i] != b[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define kokekoke int 
#define wannwann int 
using namespace std;


int main(){
    kokekoke N,a=0,b=0,c=0,tatea=0,tateb=0,tatec=0,count;
    int ansa=0,ansb=0,atate,btate,ctate;
    vector<wannwann> agyo;
    vector<wannwann> bgyo;
    vector<wannwann> cgyo;


    for(int i=0;i<3;i++){ 
        cin>>count;
        agyo.push_back(count);
    }
    for(int i=0;i<3;i++){ 
        cin>>count;
        bgyo.push_back(count);
    }
    for(int i=0;i<3;i++){ 
        cin>>count;
        cgyo.push_back(count);
    }

    a=agyo[0]-agyo[1];
    b=bgyo[0]-bgyo[1];
    c=cgyo[0]-cgyo[1];

    atate=agyo[1]-agyo[2];
    btate=bgyo[1]-bgyo[2];
    ctate=cgyo[1]-cgyo[2];

    if(atate==btate&&btate==ctate)ansa=1;
    if(a==b&&b==c)ansb=1;


    if(ansa==1&&ansb==1){
        cout<<"Yes"<<endl;
    }else{
    cout<<  "No"<<endl;
        
    }

}

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

using namespace std;

int main() {
	int i;
	int K, X;
	int start_min;
	int end_max;
	

	cin >> K >> X;

	start_min = X - (K - 1);
	end_max = X + (K - 1);

	if (start_min < -1000000) {
		start_min = -1000000;
	}
	if(end_max > 1000000){
		end_max = 1000000;
	}


	for (i = start_min; i < end_max; i++) {
		cout << i << " ";
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IArray
import Control.Monad

lowerBound:: (Integral i, Ix i, Ord e, IArray a e) => e -> a i e -> i
lowerBound x a =
    let (b,e) = bounds a in bsearch b (e + 1)
  where
    bsearch b e
      | e == b    = b
      | x <= a!p  = bsearch b p
      | otherwise = bsearch (p + 1) e
      where p = (b + e) `div` 2

main :: IO ()
main = do
    _ <- getLine
    l <- map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    let sl = listArray (0,length l - 1) $ sort l :: Array Int Int
    print $ sum
        [ let c = lowerBound ((sl!a)+(sl!b)) sl
           in c - (b+1)
          | a <- [0..length sl - 1], b <- [(a+1)..length sl - 1]
        ]


Measured memory_bytes: 1148
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//int a[] = {4,6,8,2};
		//int b[] = {4,6,3,2};
		
		Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	int[] a = new int[4];
        	int[] b = new int[4];
        	
	        a[0] = sc.nextInt();
	        a[1] = sc.nextInt();
	        a[2] = sc.nextInt();
	        a[3] = sc.nextInt();
	        b[0] = sc.nextInt();
	        b[1] = sc.nextInt();
	        b[2] = sc.nextInt();
	        b[3] = sc.nextInt();
			
			int Hit = 0;
			int Brow = 0;
			
			for (int i=0; i<4; i++){
				if (a[i] == b[i]){
					Hit += 1;
				}
				for(int j=0; j<4; j++){
					if(a[i] == b[j] && i != j){
						Brow +=1;
					}
				}
			}
			
			System.out.println(Hit + " " + Brow);
        }	
	}
}

Measured memory_bytes: 18272
#include <iostream>
#define inf 1000000007
using namespace	std;
int main(){

  long long m,n,r=1;

  cin>>m>>n;

  while(n!=1){
    if(n%2) r=(r*m)%inf;
    m=(m*m)%inf;
    n/=2;
  }

  cout<<(r*m)%inf<<endl;

  return 0;

}

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

#define pb push_back
#define sz(v) ((int)(v.size()))
#define all(v) v.begin(), v.end()
#define nie NULL
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef vector<pii> vpi;

const int inf(1e9);
const int maxN(3e5 + 10);
const ll mod(1e9 + 7);

template <typename T1>
inline void in(T1 &a1) { cin >> a1; }
template <typename T1, typename T2>
inline void in(T1 &a1, T2 &a2) { cin >> a1 >> a2; }
template <typename T1, typename T2, typename T3>
inline void in(T1 &a1, T2 &a2, T3 &a3) { cin >> a1 >> a2 >> a3; }

void _main();
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/*--------------------------------------*/
	_main(); return 0;
}

/*--------------------------------------------------------------*/

vi t, v, bd;

double sq(double x) {
	return x * x;
}

void _main() {
	int i, n; in(n);
	t.resize(n), v.resize(n);
	for (i = 0; i < n; i++) in(t[i]);
	for (i = 0; i < n; i++) in(v[i]);

	bd.resize(n + 1, inf);
	bd[0] = bd[n] = 0;
	for (i = 0; i < n; i++)
		bd[i] = min(bd[i], v[i]);
	for (i = 1; i < n; i++) {
		bd[i] = min({ bd[i],
			bd[i - 1] + t[i - 1],
			v[i - 1], v[i],
			bd[i + 1] + t[i]
		});
	}
	for (i = 1; i < n; i++) {
		bd[n - i] = min({ bd[n - i],
			bd[n - i + 1] + t[n - i],
			v[n - i - 1], v[n - i],
			bd[n - i - 1] + t[n - i - 1]
		});
	}

	double ans = 0;
	for (i = 0; i < n; i++) {
		double h = (bd[i] + bd[i + 1] + t[i]) * .5;
		h = min(h, (double)v[i]);
		ans += sq(h) - (sq(bd[i]) + sq(bd[i + 1])) * .5;
		ans += (t[i] + bd[i] + bd[i + 1] - 2 * h) * h;
	} printf("%.9lf\n", ans);
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;

string v[4] = {"AC", "WA", "TLE", "RE"}, s;
int cnt[4];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        for (int j = 0; j < 4; j++) {
            if (s==v[j]) {
                cnt[j]++;
            }
        }
    }
    for (int i = 0; i < 4; i++) {
        cout << v[i] << " x " << cnt[i] << '\n';
    }
}

Measured memory_bytes: 3660
#include<iostream>

using namespace std;

int main(void){
	int a,b,c,d;
	int max,min;
	
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	
	if(a<c){
		max=c;
	}else{
		max=a;
	}
	if(b>d){
		min=d;
	}else{
		min=b;
	}
	
	if(min-max>0){
		cout<<min-max<<endl;
	}else{
		cout<<0<<endl;
	}
	
	return 0;
}

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

int main(){
int N;
cin >> N;
int i = 0;
while(true){ 
     // cout << i << endl;
      if(N == i * i) {
           cout << i * i << endl;
           return 0;
      }
     else if(N < i * i){
           cout << (i - 1) * (i - 1)  << endl;
           return 0;
     }
     i++;
}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
int n;cin>>n;
int ans=0;
for(int i=1;i<=n;i++){
    int h;
    cin>>h;
if(i%2!=0){
    if(h%2!=0){
        ans++;
    }
}
}
cout<<ans<<endl;
 }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main ()
{
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    vector <vector <int>> dp(a + 1, vector <int>(b + 1));
    const int P = 998244353;
    dp[n][m] = 1;
    for (int i = 0; i < a + 1; ++i)
        for (int j = 0; j < b + 1; ++j)
        {
            if (i < n || j < m || i == n && j == m)
                continue;
            dp[i][j] = (dp[i - 1][j] * j % P + dp[i][j - 1] * i % P - dp[i - 1][j - 1] * (i - 1) * (j - 1) % P + P) % P;
        }

    /*for (auto val : dp)
    {
        for (auto val1 : val)
            cout << val1 << " ";
        cout << endl;
    }*/
    cout << dp.back().back() << endl;

}


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


int main(){

double a,b,h,m;
cin >> a >> b >> h >> m;
double pi = 3.14159265359;
double tl = m * pi / 30;
double ts = 30 * h + m / 2;
ts = ts * pi / 180;

double t = tl - ts;
if(t<0) t = ts-tl;

double ans = 0;
ans = a*a + b*b - 2*a*b *cos(t);
ans = sqrt(ans);


printf("%.10lf\n", ans);
}



Measured memory_bytes: 4228
n = gets.to_i

f = []

#f_{i,j,k} = f[i][2*j+k]
0.upto(n-1) do |i|
  f[i] = gets.split.map(&:to_i)
end

p = []

0.upto(n-1) do |i|
  p[i] = gets.split.map(&:to_i)
end

max = -Float::INFINITY

#自分の店の営業時間帯を10桁の2進数で表現する
#曜日jの時間帯kに自分の店が営業しているとき
#bの末尾から2j+k桁目が1とする
#b=0とならないことに注意
1.upto(2**10-1) do |b|
  tmp = 0
  0.upto(n-1) do |i|
    c = 0
    0.upto(4) do |j|
      0.upto(1) do |k|
        c += 1 if f[i][2*j+k] == 1 && b & (1 << 2*j+k) > 0
      end
    end
    tmp += p[i][c]
  end
  max = tmp if tmp > max
end

puts max


Measured memory_bytes: 3836
import java.io.PrintWriter;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int ans = 0;
        if(int1%2==0){
            ans = int1;
        }else{
            ans = int1*2;
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


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

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

int main() {
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}
const ll INF = 1e9;


int main()
{
    int n, k; cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++)cin >> a[i][j];
    atcoder::mcf_graph<int, ll> mf(2 * n + 2);
    int S = 2 * n, T = 2 * n + 1;
    mf.add_edge(S, T, n * k, INF);

    for(int i = 0; i < n; i++) {
        mf.add_edge(S, i, k, 0);
        mf.add_edge(i + n, T, k, 0);
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            mf.add_edge(i, j + n, 1, INF - a[i][j]);
        }
    }

    auto p = mf.flow(S, T, n * k);
    vector<atcoder::mcf_graph<int,ll>::edge> v = mf.edges();
    cout << n * k * INF - p.second << endl;

    for(auto e : v) {
        if(e.from == S || e.to == T)continue;
        if(e.flow == 1) {
            a[e.from][e.to - n] = -1;
        }
    }


    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)cout << (a[i][j] == -1 ? "X" : ".") << (j == n - 1 ? "\n" : "");
    }





}

Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		long target = 0;
		Scanner sc = new Scanner(System.in);
		target = sc.nextLong();

		long res = (long) Math.floor(target / 11) * 2;
		long l2 = target % 11;
		if (l2 > 6) {
			res += 2;
		} else if (l2 >= 1){
			res += 1;
		}
		
		System.out.println(res);
	}
}


Measured memory_bytes: 9804
n = int(input())
red = [list(map(int,input().split())) for _ in range(n)]
red.sort(key=lambda x:(x[1]))
blue = sorted(list(map(int,input().split())) for _ in range(n))
blue.sort(key=lambda x:(x[0],x[1]))
seen = [False]*n
for i in range(n):
    check = -1
    for j in range(n):
        if seen[j]:continue
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
            check = j
    if check != -1:seen[check] = True
print(seen.count(True))

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

struct UnionFind{
    vector<int> p;
    vector<int> r;

    UnionFind(int n){
        p.resize(n, -1);
        r.resize(n, 1);
    }

    int find(int x){
        if(p[x] == -1) return x;
        else return p[x] = find(p[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);

        if(x == y) return;
        if(r[x] > r[y]) swap(x, y);
        if(r[x] == r[y]) ++r[y];

        p[x] = y;
    }
};

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

    vector<double> ans;
    while(1){
        int n;
        cin >> n;

        if(n == 0) break;

        vector<double> x(n), y(n), z(n), r(n);
        rep(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];

        vector<vector<double>> dist(n, vector<double>(n));
        vector<pair<double, pair<int, int>>> dp;
        rep(i, n) rep(j, n){
            if(i < j) continue;
            dist[i][j] = pow(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2) + pow(z[i]-z[j], 2), 0.5);
            dist[i][j] = max(0.0, dist[i][j] - r[i] - r[j]);
            dist[j][i] = dist[i][j];

            dp.push_back(make_pair(dist[i][j], make_pair(i, j)));
        }

        sort(dp.begin(), dp.end());
        UnionFind uf(n);

        double res = 0;
        rep(i, dp.size()){
            double d = dp[i].first;
            int from = dp[i].second.first;
            int to = dp[i].second.second;

            if(uf.find(from) != uf.find(to)){
                res += d;
                uf.unite(from, to);
            }
        }



        // rep(i, n){
        //     rep(j, n) cout << dist[i][j] << " ";
        //     cout << endl;
        // }

        // cout << res << endl;
        ans.push_back(res);

    }

    rep(i, ans.size()) printf("%.3f\n", ans[i]);

    return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>
#include <string.h>

int main(){
    char s[11];
    char hi[3] = "hi";
    int i;

    scanf("%s", s);
    if ((strlen(s) % 2) != 0){
        printf("No");
        return 0;
    }

    for (i = strlen(s) - 2; i >= 0; i -= 2)
    {
        if (strcmp(&s[i], hi) != 0)
        {
            printf("No");
            return 0;
        }
        s[i] = '\0';
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
    ll a,b;
    cin>>a>>b;
    ll g = gcd(a,b);
    ll ans = 1;
    ll t= g;
    for(ll i=2;i*i<=g;i++){
        if(t%i==0){
            while(t%i==0)t/=i;
            ans++;
        }
    }
    if(t>1)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s=new Scanner(System.in);
        String str=s.next();
        long sum=0;
        for(int i=0;i<str.length();i++){
            int num=str.charAt(i)-'0';
            sum+=num;
        }
            
        if(sum%9==0){
            System.out.print("Yes");
        }
        else{
            System.out.print("No");
        }

    }
}

Measured memory_bytes: 31068
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		long double a,b,x;
		cin>>a>>b>>x;
		if(x<=(.5*a*a*b)){
			long double h=x*2/(b*a);
			cout<<fixed<<setprecision(10)<<atan(b/h)*180/acos(-1);
		}
		else{
			long double h=2*(-x/(a*a)+b);
			cout<<fixed<<setprecision(10)<<atan((h)/a)*180/acos(-1);
		}
	}
	return 0;
}

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

int main() {
	long l,r,i,j,ans=2018,mod=2019;
	cin >> l >> r;
	r=min(r,l+2019);
	for(i=l; i<r; i++){
		for(j=i+1; j<=r; j++){
			ans=min(ans,(i*j)%mod);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

# MOD = 998244353

A, B = list(map(int, sys.stdin.buffer.readline().split()))

# 最初の偶数から最後の奇数までの数
c = int(math.ceil(B / 2) * 2) - int(math.ceil(A / 2) * 2)
if c % 4 == 0:
    # 下位1ビットが1のやつが偶数個
    ret = 0
elif c % 2 == 0:
    # 下位1ビットが1のやつが奇数個
    ret = 1
else:
    assert False

if A % 2 == 1:
    ret ^= A
if B % 2 == 0:
    ret ^= B
print(ret)


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

using namespace std;

int memo[51][51][51][51][2][4];

constexpr void initializer() {
  for (int i = 0; i < 51; ++i) {
    for (int j = 0; j < 51; ++j) {
      for (int k = 0; k < 51; ++k) {
        for (int l = 0; l < 51; ++l) {
          for (int m = 0; m < 2; ++m) {
            for (int n = 0; n < 4; ++n) {
              memo[i][j][k][l][m][n] = 1e9;
            }
          }
        }
      }
    }
  }
  return;
}

int min_max(int s1, int s2, int c1, int c2, vector<int> &a, vector<int> &b,
            int cnt, int flag) {
  if (memo[s1][s2][c1][c2][cnt & 1][flag] != 1e9)
    return memo[s1][s2][c1][c2][cnt & 1][flag];
  int ret = 0;
  if (flag == 3) return memo[s1][s2][c1][c2][cnt & 1][flag] = 0;
  if (cnt & 1) {
    ret = 1e9;
    if (s1 + c1 <= (int)a.size() && s2 + c2 + 1 <= (int)b.size())
      ret = min(min_max(s1, s2, c1, c2 + 1, a, b, cnt + 1, 0), ret);
    int aa = 0, bb = 0;
    if (c1 > c2) {
      if (a[s1] > 0) aa += a[s1];
      for (int i = 0; i < c2; ++i) {
        if (b[s2 + i] > 0)
          bb += b[s2 + i];
        else
          aa = 0;
        if (a[s1 + i + 1] > 0)
          aa += a[s1 + i + 1];
        else
          bb = 0;
      }
    } else {
      for (int i = 0; i < c2; ++i) {
        if (b[s2 + i] > 0)
          bb += b[s2 + i];
        else
          aa = 0;
        if (a[s1 + i] > 0)
          aa += a[s1 + i];
        else
          bb = 0;
      }
    }
    ret =
        min(min_max(s1 + c1, s2 + c2, 0, 0, a, b, cnt + 1, flag + 1) + aa - bb,
            ret);
  } else {
    ret = -1e9;
    if (s1 + c1 + 1 <= (int)a.size() && s2 + c2 <= (int)b.size())
      ret = max(min_max(s1, s2, c1 + 1, c2, a, b, cnt + 1, 0), ret);
    int aa = 0, bb = 0;
    if (c1 < c2) {
      if (b[s2] > 0) bb += b[s2];
      for (int i = 0; i < c1; ++i) {
        if (a[s1 + i] > 0)
          aa += a[s1 + i];
        else
          bb = 0;
        if (b[s2 + i + 1] > 0)
          bb += b[s2 + i + 1];
        else
          aa = 0;
      }
    } else {
      for (int i = 0; i < c1; ++i) {
        if (a[s1 + i] > 0)
          aa += a[s1 + i];
        else
          bb = 0;
        if (b[s2 + i] > 0)
          bb += b[s2 + i];
        else
          aa = 0;
      }
    }
    ret =
        max(min_max(s1 + c1, s2 + c2, 0, 0, a, b, cnt + 1, flag + 1) + aa - bb,
            ret);
  }
  return memo[s1][s2][c1][c2][cnt & 1][flag] = ret;
}

int main() {
  initializer();
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  cout << min_max(0, 0, 0, 0, a, b, 0, 0) << endl;
}



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

void solve() {
    int H, A;
    cin >> H >> A;
    int x = H / A;
    int m = H % A;
    cout << (m == 0 ? x : x + 1) << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> n;

int main(){
	int k,n,af,al,a1,ans=0;
	cin>>k>>n;
	cin>>af;
	a1=af;
	for(int i=0;i<n-1;i++){
		cin>>al;
		ans=max(ans,al-af);
		af=al;
	}
	ans=max(ans,k-al+a1);
	cout<<k-ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else:    #opが"?"以外の時
        # ここ処理を書いてください
        # else のなかです。この通りのインデントを付けてください。
        if op == '+':
            print(a + b)
        if op == '-':
            print(a - b)
        if op == '*':
            print(a * b)
        if op == '/':
            print(a // b)


Measured memory_bytes: 5592
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int max=a;if(max<b){max=b;}if(max<c){max=c;}
    printf("%d\n",10*max+a+b+c-max);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int h, w;
	int i, j;
	
	while (scanf("%d %d", &h, &w), h || w) {

		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) putchar('#');
				else putchar('.');
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    string S;
    cin >> S;
    if(S[5] == '0' && S[6] <= '4'){
        cout << "Heisei";
    }else{
        cout << "TBD";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main() {
	int n;
	int count = 0;
	cin >> n;

	for (int i = 1; i <= 9; i++) {
		if (n%i == 0&&n/i<10) {
			count += 1;
		}
		else
		{
			count += 0;
		}
	}

	if (count > 0) {
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	vector<P> rec(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		rec[i] = P(a, b);
	}
	P p1;
	vector<int> vi(n, 0);
	vector<int> used(n, 0);
	function<void(int)> Dfs = [&](int v) {
		vi[v] = 1;
		used[v] = 1;
		for (int c : g[v]) {
			if (used[c]) continue;
			if (p1 == P(v, c) || p1 == P(c, v)) continue;
			Dfs(c);
		}
	};
	int ans = 0;
	rep(i, m) {
		vi = vector<int>(n, 0);
		used = vector<int>(n, 0);
		p1 = rec[i];
		Dfs(0);
		bool ok = true;
		rep(i, n) if (!vi[i]) ok = false;
		if(!ok) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;
}

int main(){
  int N;
  scanf("%d",&N);
  long long int A[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%lld",&A[i]);
  }
  qsort(A, N, sizeof(long long int), compare_int);
  long long int ans=0;
  if(N%2==0){
    for(i=0;i<N/2-1;i++){
      ans=ans-2*A[i]+2*A[N/2+i+1];
    }
    ans=ans-A[N/2-1]+A[N/2];
    printf("%lld",ans);
  }else{
    for(i=0;i<(N-3)/2;i++){
      ans=ans-2*A[i]+2*A[i+(N+3)/2];
    }
    if(A[(N+1)/2]+A[(N-3)/2]>2*A[(N-1)/2]){
      ans=ans+2*A[(N+1)/2]-A[(N-3)/2]-A[(N-1)/2];
    }else{
      ans=ans+A[(N+1)/2]-2*A[(N-3)/2]+A[(N-1)/2];
    }
    printf("%lld",ans);
  }
  return 0;
}


Measured memory_bytes: 1788
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			
			int[] r = new int[n], w = new int[n];
			int max = 0, p=0, sumr = 0, sumw = 0;
			for(int i=0;i<n;i++){ 
				r[i] = sc.nextInt(); 
				w[i] = sc.nextInt();
				if( r[i] > max ) {
					max = r[i]; p = i;
				}
				sumr += r[i];
				sumw += w[i];
			}
			
			if( sumr - max >= max ) {
				System.out.println((sumr + sumw));
			}
			else {
				boolean[] dp = new boolean[2 * max - sumr + 1];
				dp[0] = true;
				for(int i=0;i<n;i++) if(i != p) 
					for(int j = 2 * max - sumr;j>=w[i];j--)	dp[j] |= dp[j-w[i]];
				for(p = 2 * max - sumr;!dp[p];p--);
				System.out.println((2 * max + sumw - p));
			}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 59860
#include <iostream>
#include <vector>
#define inf 100000000

using namespace std;

struct edge{
	int to, cap, cost, rev;
	edge(int a, int b, int c, int d){
		to = a, cap = b, cost = c, rev = d;
	}
};

int n;
vector<edge> G[370];
const int S = 0, T = 366;
int prevv[370], preve[370];

void add_edge(int s, int t, int cap, int cost)
{
	G[s].push_back( edge(t, cap, cost, G[t].size()) );
	G[t].push_back( edge(s, 0, -cost, G[s].size()-1) );
}

void BellmanFord()
{
	int dist[370];
	for(int i = S; i <= T; i++) dist[i] = inf;
	dist[S] = 0;
	prevv[S] = -1;
	
	bool update = true;
	while(update){
		update = false;
		for(int i = S; i <= T; i++){
			for(int j = 0; j < G[i].size(); j++){
				if(G[i][j].cap == 0) continue;
				if(dist[G[i][j].to] > dist[i] + G[i][j].cost){
					update = true;
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					prevv[G[i][j].to] = i;
					preve[G[i][j].to] = j;
				}
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = S; i <= T; i++) G[i].clear();
		for(int i = S; i < T; i++) add_edge(i, i+1, inf, 0);
		
		int ii, jj, ww;
		for(int i = 0; i < n; i++){
			cin >> ii >> jj >> ww;
			add_edge(ii, jj+1, 1, -ww);
		}
		
		int F = 2, ans = 0;
		while(F > 0){
			BellmanFord();
			
			int flow = F;
			int p = T;
			while(prevv[p] != -1){
				flow = min(flow, G[prevv[p]][preve[p]].cap);
				p = prevv[p];
			}
			
			p = T;
			while(prevv[p] != -1){
				ans += G[prevv[p]][preve[p]].cost * flow;
				G[prevv[p]][preve[p]].cap -= flow;
				G[p][G[prevv[p]][preve[p]].rev].cap += flow;
				p = prevv[p];
			}
			F -= flow;
		}
		cout << -ans << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 3124
n,m=map(int,input().split())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(n-1+m)]
indeg_n=[0]*n
indeg=[[]for i in range(n)]
outdeg=[[]for i in range(n)]
for a,b in src:
  indeg_n[b]+=1
  indeg[b].append(a)
  outdeg[a].append(b)
root=indeg_n.index(0)
toposo=[]
stack=[root]

while stack:
  v=stack.pop()
  toposo.append(v)
  for to in outdeg[v]:
    indeg_n[to]-=1
    if indeg_n[to]==0:
      stack.append(to)
order=[-1]*n
for i,v in enumerate(toposo):
  order[v]=i
ans=[-1]*n
ans[root]=0
for ti in range(1,n):
  v=toposo[ti]
  maxo=max(order[p] for p in indeg[v])
  ans[v]=toposo[maxo]+1
print(*ans,sep='\n')

Measured memory_bytes: 52068
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
 
public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            int[][] map = new int[10][10];
             
            while((line=br.readLine())!=null){
                if(line.equals(""))break;
                String[] splited = line.split(",");
                int x = Integer.parseInt(splited[0]);
                int y = Integer.parseInt(splited[1]);
                int size = Integer.parseInt(splited[2]);
                map[x][y]++;
                if(x!=0)map[x-1][y]++;if(x!=9)map[x+1][y]++;
                if(y!=0)map[x][y-1]++;if(y!=9)map[x][y+1]++;
                if(size>1){
                    if(x!=0&&y!=0)map[x-1][y-1]++;if(x!=9&&y!=0)map[x+1][y-1]++;
                    if(x!=9&&y!=9)map[x+1][y+1]++;if(x!=0&&y!=9)map[x-1][y+1]++;
                }
                if(size==3){
                    if(x>=2)map[x-2][y]++;if(x<=7)map[x+2][y]++;
                    if(y>=2)map[x][y-2]++;if(y<=7)map[x][y+2]++;
                }
            }
            int max=0, tile=0;
            for(int i=0; i<100;i++){
                int den = map[i%10][i/10];
                if(den>max)max=den; if(den>0)tile++;
            }
            System.out.println(100-tile);
            System.out.println(max);
        }catch(Exception e){e.printStackTrace();}
    }
}


Measured memory_bytes: 24112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int n, a[100000];
int modpow(int a, int b, int m) {
	int cnt = 1;
	for (int i = 0; i < b; i++) {
		cnt *= a; cnt %= m;
	}
	return cnt;
}
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			int T = (i / 2) * 2 + 1;
			if (a[i] != T) { cout << "0" << endl; return 0; }
		}
	}
	if (n % 2 == 1) {
		for (int i = 0; i < n; i++) {
			int T = ((i + 1) / 2) * 2;
			if (a[i] != T) { cout << "0" << endl; return 0; }
		}
	}
	cout << modpow(2, n / 2, 1000000007) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	rep(i,n){
		fact[i+1]=fact[i]*(i+1)%mod;
		if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
		invfact[i+1]=invfact[i]*inv[i+1]%mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%mod;
		n=n*n%mod;
		k>>=1;
	}
	return ret;
}

int main(){
	mod_build();
	int n,m;
	cin>>n>>m;
	int a[n][m];
	rep(i,n)rep(j,m)cin>>a[i][j];
	int cnt=0;
	rep(i,n){
		bool ok=false;
		int idx = -1;
		for(int j=cnt;j<m;++j)if(a[i][j]==1)ok=true,idx=j;
		if(!ok)continue;
		if(a[i][cnt]!=1){
			rep(k,n)swap(a[k][cnt],a[k][idx]);
		}
		rep(j,m){
			if(!a[i][j]||j==cnt)continue;
			rep(k,n)a[k][j]^=a[k][cnt];
		}
		++cnt;
	}
	ll ans=powmod(2,m+n-1);
	ans+=mod-powmod(2,n+m-cnt-1);
	cout<<ans%mod<<endl;
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

int N;
int P[200000];

int main()
{
  int ret, i;
  int inum, now_min;

  ret = scanf("%d", &N);
  for ( i=0; i<N; i++ )
    ret = scanf("%d", &(P[i]));

  inum = 1;
  now_min = P[0];
  for ( i=1; i<N; i++ ) {
    if ( P[i] <= now_min ) {
      inum++;
      now_min = P[i];
    }
  }

  printf("%d\n", inum);
}


Measured memory_bytes: 896
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

const int N = 2e5 + 1;
vector<int> adj[N];
bool vis[N];
int nxt[N];
int n, m;

void testcase() {
	cin >> n >> m;

	rep (i, 1, n) adj[i].clear();

	memset(vis, false, sizeof(vis));
	memset(nxt, 0, sizeof(nxt));

	while(m--) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	queue<int> q; 
	q.push(1);
	vis[1] = true;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int v : adj[u]) {
			if (!vis[v]) {
				nxt[v] = u;
				vis[v] = true;
				q.push(v);
			}
		}
	}

	rep (i, 2, n) {
		if (nxt[i] == 0) {
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	rep (i, 2, n) {
		cout << nxt[i] << "\n";
	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 13488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  ld A;
  cin >> A;
  ld B;
  cin >> B;

  ll ans = floor(A*B);
  cout << ans << endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mx=100001;
ll n=0;
vector<ll> a(mx);
vector<int> dp(mx,-1);
ll foo(int src){
	if(dp[src]!=-1) return dp[src];
	if(src==n-1) return 0;
	// else if (src>=n) return INT_MAX;
	else {
		ll ans = abs(a[src]-a[src+1])+foo(src+1);
		if(src+2<n)
		ans=min(ans,abs(a[src]-a[src+2])+foo(src+2));
		return dp[src]=ans;
	}
	// if(i==n-2) { return abs(h[n-1]-h[n-2]);}
	// if(i==n-1) return abs(h[n-1]-h[n-3]);
	// return cost+=min(dp(i+1,h,n),dp(i+2,h,n));
}
int main() {
	// int n;
	cin>>n;
	// int a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	
	cout<<foo(0)<<endl;
	return 0;
}

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

using namespace std;

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

int main(){
    int N,X,ls=1000000000,ans;
    cin >> N >> X;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
        if(ls>abs(X-x[i])){
            ls = abs(X-x[i]);
        }
    }

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

    ans = ls;

    for(int i=0;i<N-1;i++){
        ans = gcd(ans,x[i+1]-x[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        while (H != 0 || W != 0) {
            for ( int a = 0; a < H; a++) {
                for ( int b = 0; b < W; b++) {
                    System.out.print("#");
                }
                System.out.println("");
            }
             System.out.println("");
            H = scan.nextInt();
            W = scan.nextInt();
        }

    }
}


Measured memory_bytes: 33268
import sys
input = sys.stdin.buffer.readline

def main():
    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    parent = list(range(n+1))
    rank = [0]*(n+1)
    cnt = 0
    
    def root(x):
        if parent[x] == x:
            return x
        parent[x] = root(parent[x])
        return parent[x]
    
    def unite(x, y):
        x = root(x)
        y = root(y)
        if x != y:
            if rank[x] < rank[y]:
                parent[x] = y
            elif rank[x] > rank[y]:
                parent[y] = x
            else:
                parent[y] = x
                rank[x] += 1

    for _ in range(m):
        x, y = map(int, input().split())
        unite(x, y)
    for i, pi in enumerate(p, 1):
        if root(i) == root(pi):
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 12496
#include <stdio.h>
#include <math.h>

int isPrime(int x)
{
	int i;
	double s;

	if (x == 2) return 1;

	if (x < 2 || x % 2 == 0) return 0;

	s = sqrt(x);
	for (i = 3; i <= s; i += 2) 
		if (x % i == 0) return 0;

	return 1;
}

int main()
{
	int c, i, n, x;

	scanf("%d",&n);

	c = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d",&x);
		if (isPrime(x)) c++;
	}

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

	return 0;
}

Measured memory_bytes: 1828
#include <stdio.h>

int main() {
	int w, h, x, y, r;
	scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
	printf("%s\n", (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 2148
//============================================================================
// Name        : a.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	int n;cin>>n;
	if(n%2){
		cout<<n/2<<endl;
	}else{
		cout<<n/2-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,M,C;
  int A[20],B[20],i,judge,count=0;
  scanf("%d",&N);
  scanf("%d",&M);
  scanf("%d",&C);

  for(i=0;i<M;i++)
    scanf("%d",&B[i]);

  for(;N>0;N--){
    judge=0;
    for(i=0;i<M;i++){
    scanf("%d",&A[i]);
    judge+=A[i]*B[i];
    }
    if(judge+C>0)count++;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    private int A;
    private int B;

    public Main() {
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
    }

    public void run() {
        int max = A + B;
        if (A - B > max) {
            max = A - B;
        }
        if (A * B > max) {
            max = A * B;
        }
        System.out.println(max);
    }

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

}


Measured memory_bytes: 22996
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
}
    


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

using namespace std;

typedef long long ll;
typedef long double K;
typedef pair<int, int> pii;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int inf = 2000000000;

main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n; 
    cin >> n; 
    set<string> a; 
    for(int i = 0; i < n; i++){
        string s; 
        cin >> s; 
        a.insert(s);
    }
    cout << a.size();
}


Measured memory_bytes: 19276
#include<stdio.h>
#define max 100000
#define se 2000000000
struct Card{
  char Su;
  int Va;
};
struct Card L[max/2+2], R[max/2+2];
void merge(struct Card K[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i=0;i<n1;i++){
    L[i] = K[left + i];}
  for (i=0;i<n2;i++){
    R[i] = K[mid + i];}
  L[n1].Va=R[n2].Va=se;
  i=j=0;
  for (k=left;k<right;k++ ){
    if (L[i].Va<=R[j].Va){
      K[k] = L[i++];
    } else {
      K[k] = R[j++];
    }
  }
}
void mergeSort(struct Card 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);
  }
}
void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q=partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}
int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x=A[r];
  i=p-1;
  for (j=p;j<r;j++ ){
    if ( A[j].Va<=x.Va){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}


int main(){
  int n, i, v;
  struct Card P[max], K[max];
  char S[10];
  int stable=1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    P[i].Su=K[i].Su=S[0];
    P[i].Va=K[i].Va=v;
  }

  mergeSort(P, n, 0, n);
  quickSort(K, n, 0, n-1);

  for (i=0;i<n;i++){
    if (P[i].Su!= K[i].Su) {
      stable = 0;}
  }
  if ( stable == 1 ){
    printf("Stable\n");}
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", K[i].Su, K[i].Va);
  }
}


Measured memory_bytes: 4056