akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

class P3 {
public:
	double x, y, z;
	P3(double x=0, double y=0, double z=0) : x(x), y(y), z(z) {}
	P3(const P3& p) : x(p.x), y(p.y), z(p.z) {}
	void set(const P3& p){ x = p.x, y = p.y, z = p.z; }
	void set(double px, double py, double pz){ x = px, y = py, z = pz; }
	P3 operator + (const P3 &p) const { return P3(x+p.x, y+p.y, z+p.z); }
	P3 operator - (const P3 &p) const { return P3(x-p.x, y-p.y, z-p.z); }
	P3 operator * (double p) const { return P3(x*p, y*p, z*p); }
	void add(const P3& p){ x += p.x, y += p.y, z += p.z; }
	void sub(const P3& p){ x -= p.x, y -= p.y, z -= p.z; }
	void scale(double s){ x *= s, y *= s, z *= s; }
	double dot(const P3& p) const { return x*p.x + y*p.y + z*p.z; }
	double squaredLength() const { return x*x + y*y + z*z; }
	double length() const { return sqrt(squaredLength()); }
	double normalize(){ double L = length(); if(L>0) scale(1.0/L); return L; }
};

int main(){
	int N;
	while(cin >> N && N){
		P3 pos(0, 0, 0), dir;
		cin >> dir.x >> dir.y >> dir.z;
		dir.normalize();
		vector< pair<P3, double> > vp(N);
		for(int i=0;i<N;i++){
			cin >> vp[i].first.x >> vp[i].first.y >> vp[i].first.z >> vp[i].second;
		}
		while(true){
			bool end = true;
			double nearest = 1e12;
			P3 npos, ndir;
			for(int i=0;i<N;i++){
				P3 p(vp[i].first);
				p.sub(pos);
				double l = dir.dot(p);
				p.sub(dir*l);
				double dist = p.length();
				if(dist > vp[i].second - 1e-8) continue;
				double sub = sqrt(vp[i].second*vp[i].second - dist*dist);
				if(l-sub > 0 && nearest > l-sub){
					nearest = l-sub;
					npos.set(pos);
					npos.add(dir*(l-sub));
					ndir.set(dir);
					ndir.scale(-1);
					P3 ref(npos-vp[i].first);
					ref.normalize();
					P3 add(ndir);
					ref.scale(ndir.dot(ref));
					add.sub(ref);
					add.scale(-2.0);
					ndir.add(add);
					end = false;
				}
			}
			if(end) break;
			pos.set(npos);
			dir.set(ndir);
		}
		printf("%.8lf %.8lf %.8lf\n", pos.x, pos.y, pos.z);
	}
}

Measured memory_bytes: 1252
def main():
    n, m = map(int, input().split())
    num_list = list(map(int, input().split()))

    if m <= n:
        print(0)
        exit()

    num_list.sort()

    dist_list = []
    for i in range(1,m):
        dist_list.append(num_list[i]-num_list[i-1])

    dist_list.sort(reverse=True)


    ans = num_list[m-1]-num_list[0]
    for i in range(n-1):
        ans -= dist_list[i]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56616
N = gets.to_i
W = gets.split.map!(&:to_i)
sum = W.inject(:+)

min = 100*100
N.times do |i|
  weight = 0
  i.times do |k|
    weight += W[k]
  end
  abs = (weight - (sum-weight)).abs
  min = abs if min > abs
end

p min


Measured memory_bytes: 1788
S = list(input())

if S.count("R") == 3:
    print(3)
if S.count("R") == 1:
    print(1)
if S.count("R") == 2:
    if S[0] == "R" and S[2] == "R":
        print(1)
    else:
        print(2)
if S.count("R") == 0:
    print(0)

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

int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

int lcm(int a, int b){
  return a * b / gcd(a,b);
}

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];
    int ans =0;

    for(int i=0;i<N;i++){
        ans += a[i] -1;
    }
    
    cout<<ans<<endl;
    return 0;

}

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

const int MAX_N = 501;
const int MAX_V = 2000;
// ティツオツ、テ」ツ?ィテゥツ敖津」ツ?ョテ」ツつォテ」ツδシテ」ツδ?
int b[MAX_N],r[MAX_N];
// テゥツ?づァツつケテヲツ閉ー
int V;
// テ」ツつーテ」ツδゥテ」ツδ?
vector<int> G[MAX_V];
// テ」ツδ榲」ツδε」ツδ?」ツδウテ」ツつーテ」ツ?ョテ」ツδ堙」ツつ「
int match[MAX_V];
// テ」ツ?凖」ツ?ァテ」ツ?ォティツェツソテ」ツ?ケテ」ツ?淌」ツ?凝」ツ?ゥテ」ツ??」ツ??
bool used[MAX_V];

// aテ」ツ?ィbテ」ツ?ョテヲツ慊?・ツ、ツァテ・ツ?ャテァツエツ?ヲツ閉ーテ」ツつ津ィツソツ氾」ツ??テ」ツδヲテ」ツδシテ」ツつッテ」ツδェテ」ツδε」ツδ嘉」ツ?ョテ、ツコツ津ゥツ卍、テヲツウツ?
int gcd(int a, int b){
    return (b>0)? gcd( b , a%b ) : a ;
}

// ティツセツコテ」ツ?ョティツソツステ・ツ環?
void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

// テ・ツ「ツ療・ツ環?ath テ」ツつ?DFSテ」ツ?ァテヲツ篠「テ」ツ??
bool dfs(int v){
	used[v] = true;
	for(int i=0 ; i < G[v].size() ; i++ ){
		int u = G[v][i];
		int w = match[u];
		if( w < 0 || !used[w] && dfs(w) ){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

// テ、ツコツ古ゥツδィテ」ツつーテ」ツδゥテ」ツδ陛」ツ?ョテヲツ慊?・ツ、ツァテ」ツδ榲」ツδε」ツδ?」ツδウテ」ツつーテ」ツつ津ヲツアツづ」ツつ?」ツつ?
int solve(){
	int res = 0;
	for(int v=0 ; v < V ; v++ ){
		if( match[v] < 0 ){
			// テ・ツ按敕ヲツ慊淌・ツ個?
			for(int i=0 ; i < V ; i++ ){
				used[i] = false;
			}
			if( dfs(v) ){
				res++;
			}
		}
	}
	return res;
}

// テ・ツ按敕ヲツ慊淌・ツ個?
void init(){
	for(int i=0 ; i < MAX_V ; i++ ){
		G[i].clear();
		match[i] = -1;
	}
}

int main(){
	int m, n;
	while( cin >> m >> n , m || n ){
		// テ・ツ按敕ヲツ慊淌・ツ個?
		V = n + m;
		init();
		
		// テ・ツ?・テ・ツ環?
		for(int i=0 ; i < m ; i++ ){
			cin >> b[i];
		}
		for(int i=0 ; i < n ; i++ ){
			cin >> r[i];
		}
		
		// テ」ツδ堙」ツつ「テ」ツつ津ヲツ篠「テ」ツ?療」ツ?ヲティツセツコテ」ツつ津ィツソツステ・ツ環?」ツ?療」ツ?ヲテ」ツ?甘」ツ??
		for(int i=0 ; i < m ; i++ ){
			for(int j=0 ; j < n ; j++ ){
				if( gcd(b[i], r[j]) >= 2 ){
					int u = i;
					int v = j + m;
					add_edge(u,v);
				}
			}
		}
		int ans = solve();
		cout << ans << endl;
	}
}

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

const ll INF = 1LL << 60;


int main() {
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);

    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> C;
    vector<ll> A(a);
    for(int i=0;i<a;i++)cin>>A[i];
    sort(A.rbegin(),A.rend());
    for(int i=0;i<x;i++)C.emplace_back(A[i]);
    A.resize(b);
    for(int i=0;i<b;i++)cin>>A[i];
    sort(A.rbegin(),A.rend());
    for(int i=0;i<y;i++)C.emplace_back(A[i]);
    for(int i=0;i<c;i++){
        cin>>a;
        C.emplace_back(a);
    }
    sort(C.rbegin(),C.rend());
    c=0;
    for(int i=0;i<x+y;i++)c+=C[i];
    cout<<c<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool approved = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        approved = false;
      }
    }
  }
  if (approved) {
    cout << "APPROVED" << endl;
    return 0;
  }
  cout << "DENIED" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n; cin>>n;
  int c=(n+999)/1000;
  co(1000*c-n);
    
  return 0;
}

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


int main()
{
    int a,b;

    cin >> a >> b;

    if(a == 1 && b == 2 || a == 2 && b == 1)
    {
        cout << 3 << endl;
    }
    else if(a == 1 && b == 3  || a == 3 && b == 1)
    {
        cout << 2 << endl;
    }
    else if(a == 2 && b == 3 || a == 3 && b == 2)
    {
        cout << 1 << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n, l, r;
        cin >> n >> l >> r;
        if(!n) break;
        vector<ll> a(n);
        for(auto &e: a) cin >> e;

        ll res = 0;
        for(ll k=l; k<=r; k++) {
            ll i;
            for(i=0; i<n; i++)
                if(k % a[i] == 0) break;
            res += ~i&1;
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3140
[n,m]=[int(i) for i in input().split()]
py=[]
for i in range(m):
    temp=[int(i) for i in input().split()]
    py.append([i+1, temp[0], temp[1]])

py.sort(key=lambda x:x[2])

count=[0 for i in range(n)]

ans=[]
#print(py)
#print(count)
for i in py:
    #print(i)
    count[i[1]-1]+=1
    ans.append([i[0], i[1], count[i[1]-1]])

ans.sort(key=lambda x:x[0])
for i in ans:
    a1=str(i[1])
    #print("a1!", i[1])
    c1=len(a1)
    while c1<6:
        print("0", end="")
        c1+=1
    print(a1, end="")

    a2=str(i[2])
    c2=len(a2)
    while c2<6:
        print("0", end="")
        c2+=1
    print(a2)

#print(ans[1], ans[2])


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

int main()
{
	string S;
	cin >> S;
	int N(S.length());
	int cnt1(0), cnt2(0);
	for(int i(0);i<N;++i){
		if(i%2 == 0 && S[i] == '0') cnt1++;
		if(i%2 == 1 && S[i] == '1') cnt1++;
	}
	for(int i(0);i<N;++i){
		if(i%2 == 0 && S[i] == '1') cnt2++;
		if(i%2 == 1 && S[i] == '0') cnt2++;
	}
	if(cnt1 > cnt2) cout << cnt2 << endl;
	else cout << cnt1 << endl;
	return 0;
}

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

struct SegmentTree {
  int N;
  vector<int> t;

  int INIT = 0;
  inline int f(int a, int b) {
    return (a | b);
  }

  SegmentTree(int n, char* s) : N(n), t(2*n) {
    for(int i = N; i < 2*N; i++) {
      t[i] = 1 << (s[i-N] - 'a');
    }
    build();
  }

  void build() {
    for (int i = N-1; i > 0; i--)
      t[i] = f(t[2*i], t[2*i+1]);
  }

  void update(int p, char c) {
    for (t[p += N] = (1 << (c-'a')); p > 1; p /= 2)
      t[p/2] = f(t[p], t[p^1]);
  }

  int query(int l, int r) {
    int res = INIT;
    for(l += N, r += N; l < r; l /= 2, r /= 2) {
      if(l&1) res = f(res, t[l++]);
      if(r&1) res = f(res, t[--r]);
    }
    int cnt = 0;
    while(res != 0) {
      res &= (res-1);
      cnt++;
    }
    return cnt;
  }
};


char ss[500001];
int main() {
  int N, M;
  scanf("%d %s %d", &N, ss, &M);
  SegmentTree seg(N, ss);
  for(int i = 0; i < M; i++) {
    int cmd, l, r, p;
    char c;
    scanf("%d", &cmd);
    if(cmd == 1) {
      scanf("%d %c", &p, &c);
      seg.update(p-1, c);
    } else {
      scanf("%d %d", &l, &r);
      printf("%d\n", seg.query(l-1,r));
    }
  }
}




Measured memory_bytes: 4736
function Main(input) {
    const N = parseInt(input[0])
    const S = input[1]
    
    var white = 0;

    for (var index = 0; index < N; index++) {
        var element = S[index];
        white += element == "." ? 1 : 0;
    }

    var black = 0;
    var result = white;
    for (var index = 0; index < N; index++) {
        var element = S[index];
        if(element == ".") {
            white--;
        } else {
            black++;
        }
        result = Math.min(result, white + black);
    }

    console.log(result);
}

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

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

  int rnum = 0;
  for (int i = 0; i < N;i++) {
    if (c[i] == 'R') {
      rnum++;
    }
  }
  int ans = 0;
  for (int i = rnum; i < N; i++) {
    if (c[i] == 'R') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         HashSet<Integer> set = new HashSet<Integer>();
         st = new StringTokenizer(infile.readLine());
         while(K-->0)
            set.add(Integer.parseInt(st.nextToken()));
         matcha:for(int res=N; res <= 99999; res++)
         {
            int temp = res;
            while(temp > 0)
            {
               int d = temp%10;
               if(set.contains(d))
                  continue matcha;
               temp /= 10;
            }
            System.out.println(res);
            return;
         }
      }
   }

Measured memory_bytes: 32788
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
main(){
  ll n,k,f,ans=0,x;
  cin>>n>>k;
  x=n/k;
  if(k%2==0){
    f=n/(k/2)-x;
    ans=f*f*f+x*x*x;
  }
  else ans=x*x*x;
  cout<<ans;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/
int main(){
    int n;
    string s,t,s1,t1;
    cin >> n;
    cin >> s >> t;
    int tmp=0;
    rep(j,n){
        s1="";t1="";
        repr(i,j){
            s1+=s[n-i-1];
            t1+=t[j-i];
        }
    if(s1==t1)tmp=s1.size();
    }
    cout << 2*n-tmp;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

int main() {
  long N, M;
  cin >> N >> M;
  cout << ((N - M) * 100 + M * 1900) * (1 << M) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint dp[101010][2];

int main(){
    string s;
    cin >> s;
    dp[0][1] = 1;
    rep(i, s.size()){
        if(s[i] == '1'){
            dp[i+1][1] += dp[i][1]*2;
            dp[i+1][0] += dp[i][0]*3;
            dp[i+1][0] += dp[i][1];
        }else{
            dp[i+1][1] += dp[i][1];
            dp[i+1][0] += dp[i][0]*3;
        }
       // cout << dp[i+1][0] << " : " << dp[i+1][1] << endl;
    }
    cout << dp[s.size()][1] + dp[s.size()][0] << endl;


}

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


int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int s=0;
  if(k>a) {
    k-=a;
    s+=a;
  }else {
    s+=k;
    cout<<s;
    return 0;
  }
  if(k>b) {
    k-=b;
  }else {
    cout<<s;
    return 0;
  }
  s-=k;
  cout<<s;
  return 0;
}

Measured memory_bytes: 3620
let a, b, c, x = Scanf.scanf "%d\n%d\n%d\n%d" (fun a b c x -> (a, b, c, x))

let rec calc a' b' tmp =
  let rec aux c' tmp' =
    if c' > c then tmp'
    else if a' * 500 + b' * 100 + c' * 50 = x then aux (c' + 1) (tmp' + 1)
    else aux (c' + 1) tmp'
  in
  aux 0 tmp


let rec secound a' tmp =
  let rec aux b' tmp' =
    if b' > b then tmp'
    else
      let tmp'' = calc a' b' tmp' in
      aux (b' + 1) tmp''
  in
  aux 0 tmp


let rec main a' tmp =
  if a' > a then tmp
  else
    let tmp' = secound a' tmp in
    main (a' + 1) tmp'


let () = main 0 0 |> Printf.printf "%d\n"

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end()); reverse(t.begin(), t.end());
  string result;
  if (s < t) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include<string>
#include<iostream>
using namespace std;
int main(){
    set<string> st;
    int a=0;
    cin >>a;
    for(int i=0;i<a;i++){
        string s;
        cin >>s;
        st.insert(s);
    }
    cout<<st.size()<<'\n';
}


Measured memory_bytes: 19216
from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = input_row()[1:]
    for s_ in s:
        C[i, s_-1] = 1

p = input_row()

all_on_num = 0

for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p
    L_on = L[L == True]
    all_on = len(L_on) == M

    if all_on:
        all_on_num += 1
print(all_on_num)



Measured memory_bytes: 27304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int cnts[4];

int main() {
    for (int i = 0, a, b; i < 3; i++) {
        cin >> a >> b;
        a--; b--;
        cnts[a]++;
        cnts[b]++;
    }
    int one_cnt = 0, two_cnt = 0;
    for (int i = 0; i < 4; i++) {
        if (cnts[i] == 2) two_cnt++;
        else if (cnts[i] == 1) one_cnt++;
    }
    if (one_cnt == 2 && two_cnt == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
s = gets.chomp
q = gets.chomp.to_i

rev = false
s_left = []
s_right = []

q.times do
  t, f, c = gets.chomp.split(' ')
  if t == "1"
    rev = !rev
  elsif (f == "1" && rev) || (f == "2" && !rev)
    s_right << c
  else
    s_left << c
  end
end

s_join = s_left.reverse.join + s + s_right.join
s_join = s_join.reverse! if rev
print(s_join)


Measured memory_bytes: 18428
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define in insert
#define bs binary_search   
 ll opc(ll arr[][3],int n,int index,ll dp[][3])
 {
    if(n==-1)
        return 0;
    else if(dp[n][index]!=-1)
        return dp[n][index];
    else
    {
        if(index==0) dp[n][index]=max(opc(arr,n-1,1,dp)+arr[n][1],opc(arr,n-1,2,dp)+arr[n][2]);
        else if(index==1) dp[n][index]=max(opc(arr,n-1,0,dp)+arr[n][0],opc(arr,n-1,2,dp)+arr[n][2]);
        else dp[n][index]=max(opc(arr,n-1,1,dp)+arr[n][1],opc(arr,n-1,0,dp)+arr[n][0]);
        return dp[n][index];
    }
 }

int main()
{
    int n;
    cin>>n;
    ll arr[n][3],dp1[n][3],dp2[n][3],dp3[n][3];
    for(int i=n-1;i>=0;i--)
        for(int j=0;j<3;j++)
        {
            dp1[i][j]=-1;dp2[i][j]=-1;dp3[i][j]=-1;
            cin>>arr[i][j];
        }
    cout<<max(opc(arr,n-1,0,dp1),max(opc(arr,n-1,1,dp2),opc(arr,n-1,2,dp3)));
    return 0;
}

Measured memory_bytes: 17920
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h> 
using namespace std;   
int main()
{
	string s;
	cin>>s;
	if (s=="abc") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="acb") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="bca") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="bac") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="cab") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="cba") 
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
    return 0;  
}

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

using namespace std;

 

int main() 

{

  long long int n, a, b;

  cin>>n>>a>>b;

  if(abs(a-b)%2==0)

  {

    cout<<abs(a-b)/2;

  } 

  else

    cout<<min(min(a, b),n-max(a, b)+1) +(abs(a-b)-1)/2;

 } 



Measured memory_bytes: 256
package main

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

var in = bufio.NewReader(os.Stdin)

func solve(a, b, c int) int {
	var temp_ int
	if c == a+b {
		temp_ = b + c
	}else if c-1 > a+b {
		temp := (c - 1) - (a + b)
		temp_ = b + c - temp
	}else{
		temp_ = b+c
	}
	 
	return temp_
}
func main() {
	var a, b, c int
	fmt.Fscanf(in, "%d %d %d¥n", &a, &b, &c)

	ans := solve(a, b, c)
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=a;i<=b;++i)
#define FOR(i,a,b) for(register int i=a;i>=b;--i)
#define next Next
#define inf (0x3f3f3f3f)
#define go(x,i) for(register int i=head[x];i;i=next[i])

using namespace std;

#define tt template<typename T>
#define min(_,__) (_<__?_:__)
#define max(_,__) (_>__?_:__)
tt inline bool chkmax(T &_,T __){return _<__?_=__,1:0;}
tt inline bool chkmin(T &_,T __){return _>__?_=__,1:0;}

tt inline void read(T &_)
{
	T __=1;_=0;char ___=getchar();
	while(!isdigit(___))
	{
		if(___=='-')
			__=-1;
		___=getchar();
	}
	while(isdigit(___))
	{
		_=(_<<3)+(_<<1)+(___^'0');
		___=getchar();
	}
	_*=__;
}

inline void file()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
}

int a[4];

int main()
{
//	file();
	For(i,1,3)
		cin>>a[i];
	sort(a+1,a+4);
	int ans=0;
	while(a[2]<a[3]-1)
		++ans,a[2]+=2;
	sort(a+1,a+4);
	while(a[1]<a[2]-1)
		++ans,a[1]+=2;
	sort(a+1,a+4);
	if(a[1]==a[2]&&a[2]==a[3])
		cout<<ans;
	else
	if(a[2]==a[3]&&a[1]!=a[2])
		cout<<ans+2;
	else
		if(a[1]==a[2]&&a[2]!=a[3])
			cout<<ans+1;
	else
		if(a[1]!=a[2]&&a[2]!=a[3])
			cout<<ans+3;
	return 0;
}



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

using namespace std;

int main(void) {
  string s;
  cin >> s;

  int sz = s.size();
  string t = "";
  for (int i = 0; i < sz; i++) {
    if (s[i] == 'x') continue;
    t += s[i];
  }
  string u = t;
  reverse(t.begin(), t.end());
  
  if (t != u) {
    cout << -1 << endl;
  } else {
    u = s;
    reverse(u.begin(), u.end());
    if (u == s) {
      cout << 0 << endl;
    } else {
      int l = 0, r = sz - 1;
      while (true) {
        while (l < r && s[l] == s[r]) l++, r--;
        if (l >= r || s[l] == s[r]) break;
        while (s[l] == 'x') l++;
        while (s[r] == 'x') r--;
      }
      swap(l, r);

      int ans = 0;
      while (true) {
        if (l == 0) {
          ans += sz - r - 1;
          break;
        } else if (r == sz - 1) {
          ans += l;
          break;
        } else {
          while (l - 1 >= 0 && r + 1 < sz && s[l - 1] == s[r + 1]) l--, r++;
          if (l == 0 || r == sz - 1) continue;
          while (l - 1 >= 0 && s[l - 1] == 'x') l--, ans++;
          while (r + 1 < sz && s[r + 1] == 'x') r++, ans++;
        }
      }
      cout << ans << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stack>
#include<vector>

using namespace std;

int main() {
	char tilt;
	int i = 0;							//iは先頭から何番目
	stack <int>	S1;						//'\'の位置を格納する
	stack < pair< int, int > > S2;		//面積を測る初期位相と面積を格納
	int ans = 0;
	for (i; cin >> tilt; i++) {
		if (tilt == '\\') {
			S1.push(i);
		}
		else if (tilt == '/' && S1.size() > 0) {
			int ver = S1.top();
			S1.pop();
			int area = i - ver;
			ans += i - ver;
			while (S2.size()>0 && S2.top().first>ver) {
				area += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(ver, area));
		}


	}

	vector<int> data;
	while (S2.size() > 0) {
		data.push_back(S2.top().second);
		S2.pop();
	}
	cout << ans << endl;
	cout << data.size();
	for (int l = data.size() - 1; l >= 0; l--) {
		cout << " ";
		cout << data[l];
	}
	cout << endl;


}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200 + 10;
const int INF = 0x3f3f3f3f;

int n, g[maxn][maxn], col[maxn], flag;

void dfs(int u) {
  for(int v = 1;v <= n;v ++) {
		if(!g[u][v]) continue;
		if(col[v]) {
			if((col[v] + col[u]) != 3) flag = 1;
			continue;
		}
		col[v] = 3 - col[u];
		dfs(v);
	}
}

inline void upmin(int &x, int y) { x = min(x,y); }
inline void upmax(int &x, int y) { x = max(x,y); }

char s[maxn];
int main() {
	scanf("%d", &n);
	for(int i = 1;i <= n;i ++) {
		scanf("%s", s + 1);
		for(int j = 1;j <= n;j ++) g[i][j] = s[j] - '0';
	}
	flag = 0;
	col[1] = 1;
	dfs(1);
	if(flag) {
		puts("-1");
		return 0;
	}
	for(int i = 1;i <= n;i ++) {
		for(int j = 1;j <= n;j ++) if(!g[i][j]) g[i][j] = INF;
	}
	for(int k = 1;k <= n;k ++) {
		for(int i = 1;i <= n;i ++) {
			for(int j = 1;j <= n;j ++) upmin(g[i][j],g[i][k] + g[k][j]);
		}
	}
	int Ans = 0;
	for(int i = 1;i <= n;i ++) {
		for(int j = 1;j < i;j ++) upmax(Ans,g[i][j]);
	}
	Ans ++;
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val x = sc.nextLong()

    val a = new Array[Long](n + 1)
    val p = new Array[Long](n + 1)
    a(0) = 1
    p(0) = 1
    for (i <- 1 until n + 1) {
      a(i) = 2 * a(i - 1) + 3
      p(i) = 2 * p(i - 1) + 1
    }

    def f(n: Int, x: Long): Long = {
      if (n == 0) {
        if (x <= 0) 0L else 1L
      } else if (x == 1) {
        0L
      } else if (1 < x && x <= 1 + a(n - 1)) {
        f(n - 1, x - 1)
      } else if (x == 2 + a(n - 1)) {
        p(n - 1) + 1
      } else if (2 + a(n - 1) < x && x <= 2 + 2 * a(n - 1)) {
        p(n - 1) + 1 + f(n - 1, x - 2 - a(n - 1))
      } else {
        2 * p(n - 1) + 1
      }
    }

    println(f(n, x))

  }
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static List<long> ps = null;
        static void Solve()
        {
            var nk = ReadAndParseLongArr();
            long n = nk[0];
            long x = nk[1];
            long length = powNoMod(2, n + 2) - 3;

            ps = new List<long>();
            for(int i=0;i<=n;++i)
            {
                ps.Add(powNoMod(2, i + 1) - 1);
            }
            long ans = CalcP(x-1, 0, length - 1, (int)n);
            Console.WriteLine(ans);
        }
        private static long CalcP( long x, long a, long b, int n)
        {
            if(a == b) { return 1; }
            long halfP = (b-a) / 2 + a;
            if( x == a)
            {
                return 0;
            }
            else if( x < halfP)
            {
                return CalcP(x, a + 1, halfP - 1, n-1);
            }else if( x == halfP)
            {
                return ps[n-1] + 1;
            }
            else // (x <= b)
            {
                return ps[n-1] + 1 + CalcP(x, halfP + 1, b - 1, n-1);
            }
        }

        private static long powNoMod(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = powNoMod(x * x , n / 2);
            if (n % 2 == 1)
            {
                res = res * x;
            }
            return res;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13268
n,m = map(int,input().split())
lst = sorted(list(map(int,input().split())))
if n >= m:
    print(0)
    exit()
lst_gap = sorted([lst[i+1]-lst[i] for i in range(m-1)],reverse=True)
print(sum(lst_gap) - sum(lst_gap[:n-1]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std

void solve() {
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());
    std::vector<std::string> l{"dream", "dreamer", "erase", "eraser"};
    rep(i, 4) {
        std::reverse(l[i].begin(), l[i].end());
    }
    // std::cerr << std::to_string(l) << std::endl;
    int pos = 0;
    while(true) {
        bool found = false;
        rep(i, 4) {
            if(s.substr(pos, l[i].size()) == l[i]) {
                pos += l[i].size();
                found = true;
                break;
            }
        }
        if(!found) break;
    }
    if(pos == s.size()) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_NO(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("NO\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------
void solve(void) {
  int n, m;
  cin >> n >> m;
  vector<set<int>> s(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    --x;
    s[x].insert(y);
  }
  rep(i, n) {
    if (size(s[i]) > 1) {
      cout << -1 << endl;
      return;
    }
  }
  rep(i, 1000) {
    string str = to_string(i);
    if (str.length() != n) continue;
    int cta = 0;
    rep(j, n) {
      if (size(s[j]) == 0)
        cta++;
      else if (s[j].find(str[j] - '0') != s[j].end())
        cta++;
    }
    if (cta == n) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
  return;
}
int main(void) { solve(); }


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int m;
    cin >> m;
    int a[m];
    int i;
    for (i = 0; m > i; i++){
        cin >> a[i];
    }
    for (i = m - 1; i >= 1; i--){
        cout << a[i] << " ";
    }
        
    cout << a[0] << endl;
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1 || b == 1)
	{
		if (a == 1 && b != 1)
			cout << "Alice";
		else if (b == 1 && a != 1)
			cout << "Bob";
		else
			cout << "Draw";
		return 0;
	}
	if (a > b)
		cout << "Alice";
	else if (b > a)
		cout << "Bob";
	else
		cout << "Draw";

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int M = cin.nextInt();

        int[] X = new int[N + 1];
        int[] Y = new int[M + 1];

        X[0] = cin.nextInt();
        Y[0] = cin.nextInt();

        for (int i = 1; i <= N; ++i)
        {
            X[i] = cin.nextInt();
        }

        for (int i = 1; i <= M; ++i)
        {
            Y[i] = cin.nextInt();
        }

        Array.Sort(X);
        Array.Sort(Y);

        WriteLine((X[N] < Y[0])?  "No War" : "War");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>

using namespace std;

typedef vector< vector< pair<int, string> > > Graph;

class Node{
public:
	int pos; string str;
	Node(int pos, string str) : pos(pos), str(str) {}
	bool operator < (const Node &nd) const { return str > nd.str; }
};

int main(){
	int n, a, s, g;
	bool con[40][40];
	bool visit[240][40];
	string str[240][40];
	while(cin >> n >> a >> s >> g, n){
		Graph graph(n);
		memset(con, false, sizeof(con));
		memset(visit, false, sizeof(visit));
		for(int i=0;i<a;i++){
			int x, y; string lab; cin >> x >> y >> lab;
			graph[x].push_back(make_pair(y,lab));
			con[x][y] = true;
		}
		for(int k=0;k<n;k++)
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					if(con[i][k]&&con[k][j]) con[i][j] = true;
		priority_queue<Node> qu; qu.push(Node(s, ""));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int pos = nd.pos, size = nd.str.size();
			if(visit[size][pos]) continue;
			visit[size][pos] = true;
			str[size][pos] = nd.str;
			for(int i=0;i<graph[pos].size();i++){
				int npos = graph[pos][i].first;
				if(size + graph[pos][i].second.size() >= 6*n) continue;
				string nstr = nd.str + graph[pos][i].second;
				if(!visit[nstr.size()][npos])
					qu.push(Node(npos, nstr));
			}
		}
		string ans = "";
		for(int i=0;i<6*(n-1);i++){
			if(!visit[i][g]) continue;
			if(ans == ""||ans > str[i][g]) ans = str[i][g];
		}
		for(int i=0;i<n;i++){
			if(!con[i][g]) continue;
			for(int j=6*(n-1);j<6*n;j++)
				if(visit[j][i]&&str[j][i]<ans) ans = "";				
		}
		cout << (ans!="" ? ans : "NO") << endl;
	}
}

Measured memory_bytes: 5456
N,K=map(int,input().split())
ans=[0]*(K+1)
mod=10**9+7
for i in range(K,0,-1):
  ans[i]=pow((K//i),N,mod)
  ind=2
  while i*ind<=K:
    ans[i]-=ans[i*ind]
    ans[i]%=mod
    ind+=1
res=0
for i in range(1,K+1):
  res+=i*ans[i]
  res%=mod
print(res)

Measured memory_bytes: 68856
#include<stdio.h>


int N,ans=0,alice=0,bob=0,turn=0;

int main(){
  scanf("%d",&N);
  int aN[N];
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&aN[i]);
  }
  int n = N;
  while (n > 0)
  {
    if(turn == 0){
      int max=0;
      int del=0;
      for (int i = 0; i < N; i++)
      {
        if(max < aN[i]){
          max = aN[i];
          del = i;
        }
      }
      alice += max;
      aN[del] = 0;
      turn = 1;
    }else if (turn == 1)
    {
      int max = 0;
      int del = 0;
      for (int i = 0; i < N; i++)
      {
        if(max < aN[i]){
          max = aN[i];
          del = i;
        }
      }
      bob += max;
      aN[del] = 0;
      turn = 0;
    }
    n--;
  }
  ans = alice - bob;
  printf("%d",ans);
  return 0;
}






Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w;
    cin >> h >> w;
    string s[50];
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int count;
    for(int i=0;i<h;i++){//縦
        for(int j=0;j<w;j++){//横
            count = 0;
            if(s[i][j]=='#'){
                continue;
            }
            else{
                for(int k=-1;k<2;k++){
                    for(int l=-1;l<2;l++){
                        if(i==0){
                            if(j==0){
                                if(k==-1 || l==-1){
                                    continue;
                                }
                            }
                            else if(j==w-1){
                                if(k==-1 || l==1){
                                    continue;
                                }
                            }
                            else if(k==-1){
                                continue;
                            }
                        }
                        else if(i == h-1){
                            if(j ==0){
                                if(k==1 || l==-1){
                                    continue;
                                }
                            }
                            else if(j == w-1){
                                if(k==1 || l==1){
                                    continue;
                                }
                            }
                            else if(k==1){
                                continue;
                            }
                        }
                        else if(j==0){
                            if(l==-1){
                                continue;
                            }
                        }
                        else if(j==w-1){
                            if(l==1){
                                continue;
                            }
                        }
                        if(s[i+k][j+l]=='#'){
                            count++;
                        }
                    }
                }
                s[i][j]=count+'0';
            }
            
        }
    }

    for(int i=0;i<h;i++){
        cout << s[i] <<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int sum=0,n=s.nextInt();
		for(;n>0;--n)
			sum-=s.nextInt()-s.nextInt()-1;
		System.out.println(sum);
	}
}

Measured memory_bytes: 25828
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1){
		a=20;
	}
	if(b==1){
		b=20;
	}
	if(a==b){
		cout<<"Draw";
	}
	else if(a>b){
		cout<<"Alice";
	}
	else{
		cout<<"Bob";
	}
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define ull unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n>=30)
        cout<< "Yes";
    else
        cout<< "No";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;

    vector<int> a_div;
    FOR(i, 1, a+1) {
        if (a % i == 0) a_div.push_back(i);
    }
    vector<int> b_div;
    FOR(i, 1, b+1) {
        if (b % i == 0) b_div.push_back(i);
    }

    vector<int> ans;
    EACH(x, a_div) {
        if (EXIST(b_div, x)) {
            ans.push_back(x);
        }
    }
    sort(ALL(ans), greater<int>());
    P(ans[k-1]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define print(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a;
    bool ok = 1;
    rep(i,n){
        cin >> a;
        if (a%2 == 0){
            if (a%3 == 0 || a%5 == 0);
            else ok = 0;
        }
    }
    if (ok) print("APPROVED");
    else print("DENIED");
}


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

int main(void){
	
	int na, nb;
	char a[10], b[10], str[10];
	
	scanf("%s", a);
	scanf("%s", b);
	scanf("%d %d", &na, &nb);
	scanf("%s", str);
	
	if(strcmp(a, str) == 0){
	printf("%d %d\n", na-1,nb);
	}else{
	printf("%d %d\n", na, nb-1);
	}
	return 0;
}

Measured memory_bytes: 128