akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

/*iamsorry*/
 
#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define E               "\n"
#define S               " "
#define INF             9e18
#define M7              1000000007
#define M9              998244353
#define PI              3.141592653589793238L
#define lcm(a,b)        ((a)/__gcd((a),(b)))*(b)
#define midl(l,r)       ((l)+((r)-(l))/2)
#define prec(n)         fixed<<setprecision(n)
#define in(arr,n)       for(int i=0; i<(n); ++i) cin>>arr[i]
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define vc              vector
#define fr              first
#define sc              second
#define pb              push_back
#define eb              emplace_back
#define ins             insert
#define emp             emplace

#ifdef DOPPELLEBEN
template<typename T1,typename T2> ostream& operator<<(ostream &out,const pair<T1,T2> &p) {return out<<'('<<p.first<<", "<<p.second<<')';}
template<typename T> auto operator<<(ostream &out,T &&x)->decltype(x.begin(),out) {out<<'{'; for(auto it=x.begin();it!=x.end();++it)out<<*it<<(it==prev(x.end())?"":", "); return out<<'}';}
void dump() {}
template<typename T,typename... Args> void dump(T &&x,Args... args) {cerr<<" "<<x; dump(args...);}
struct ND{~ND(){cerr<<"]\n";}};
#define dbg(x...) cerr<<" ["<<(strcmp(#x,"")?#x ":":""),dump(x),ND(),cerr<<""
#else
#define dbg(...) 0 && cerr
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rann(n) rng()%(n)
#define ran(l,r) (l)+rng()%((r)-(l)+1)

template<typename T,typename t> T maxm(T &x,t y) {if(y>x)x=y; return x;}
template<typename T,typename t> T minm(T &x,t y) {if(y<x)x=y; return x;}
template<typename T> int sz(T &&x) {return (int)((x).size());}

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int,int>;
using mii = map<int,int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using seti = set<int>;
using setd = set<int,greater<int>>;
using pqmx = priority_queue<int>;
using pqmn = priority_queue<int,vector<int>,greater<int>>;

/*__*/

void Main() {
	int n; cin>>n;
	string s; cin>>s;
	int w=count(s.begin(), s.end(), 'W'), cnt=0;
	fi(i,1,w+1) {
		if(s[n-i]=='W') ++cnt;
	}
	cout<<w-cnt;
}

signed main() {
    thegamebegins
    
    int T=1;
    // cin>>T;
    while(T--) Main();

    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll=long long;

ll n,k;
vector<ll> ps,ms;
ll zr=0;
//x以上の積になるペアの個数
ll count(ll x){
    ll ret=0;
    if(x>0){
        ll cnt=0;
        for(int i=0;i<(int)ps.size();i++){
            cnt+=(int)ps.size()-(lower_bound(ps.begin(),ps.end(),(x+ps[i]-1ll)/ps[i])-ps.begin());
            if(ps[i]*ps[i]>=x)cnt--;
        }
        for(int i=0;i<(int)ms.size();i++){
            cnt+=(int)ms.size()-(lower_bound(ms.begin(),ms.end(),(x+ms[i]-1ll)/ms[i])-ms.begin());
            if(ms[i]*ms[i]>=x)cnt--;
        }
        cnt/=2;
        ret+=cnt;
    }else if(x==0){
        ret+=count(1);
        ret+=zr*(n-zr)+zr*(zr-1)/2;
    }else if(x<0){
        ret+=count(0);
        for(int i=0;i<(int)ps.size();i++){
            ret+=lower_bound(ms.begin(),ms.end(),(-x+ps[i])/ps[i])-ms.begin();
        }
    }
    return ret;
}
ll search(){
    ll l=-1e18-1,r=1e18+1;
    while(abs(l-r)>1){
        ll mid=(l+r)/2;
        if(n*(n-1)/2-count(mid)+1<=k)l=mid;
        else r=mid;
    }
    return l;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a<0)ms.push_back(-a);
        else if(a==0)zr++;
        else ps.push_back(a);
    }
    sort(ms.begin(),ms.end());
    sort(ps.begin(),ps.end());
    cout<<search()<<endl;
}

Measured memory_bytes: 2420
N,K = map(int, input().split())
H = [int(h) for h in input().split()]

dp = [10**12]*N
dp[0] = 0
for i in range(1, N):
    t = 1
    while t <= K and i-t >= 0:
        dp[i] = min(dp[i], dp[i-t]+abs(H[i]-H[i-t]))
        t += 1
        
print(dp[-1])

Measured memory_bytes: 52448
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main (String[] args) throws Exception
        { 
            BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
             StringTokenizer st = new StringTokenizer(infile.readLine());
             int N = Integer.parseInt(st.nextToken());
            int arr[] = new int[N];
            st = new StringTokenizer(infile.readLine());
             for(int i=0; i < N; i++)
                arr[i] = Integer.parseInt(st.nextToken());
            System.out.println(findNumberOfTriangles(arr)); 
        } 
       public static int findNumberOfTriangles(int arr[]) 
        { 
            int n = arr.length; 
            // Sort the array elements in non-decreasing order 
            Arrays.sort(arr); 
      
            // Initialize count of triangles 
            int count = 0; 
      
            // Fix the first element. We need to run till n-3 as 
            // the other two elements are selected from arr[i+1...n-1] 
            for (int i = 0; i < n-2; ++i) 
            { 
                // Initialize index of the rightmost third element 
                int k = i + 2; 
      
                // Fix the second element 
                for (int j = i+1; j < n; ++j) 
                { 
                    /* Find the rightmost element which is smaller 
                    than the sum of two fixed elements 
                    The important thing to note here is, we use 
                    the previous value of k. If value of arr[i] + 
                    arr[j-1] was greater than arr[k], then arr[i] + 
                    arr[j] must be greater than k, because the 
                    array is sorted. */
                    while (k < n && arr[i] + arr[j] > arr[k]) 
                        ++k; 
      
                /* Total number of possible triangles that can be 
                    formed with the two fixed elements is k - j - 1. 
                    The two fixed elements are arr[i] and arr[j]. All 
                    elements between arr[j+1] to arr[k-1] can form a 
                    triangle with arr[i] and arr[j]. One is subtracted 
                    from k because k is incremented one extra in above 
                    while loop. k will always be greater than j. If j 
                    becomes equal to k, then above loop will increment 
                    k, because arr[k] + arr[i] is always/ greater than 
                    arr[k] */
                    if(k>j) 
                    count += k - j - 1; 
                } 
            } 
            return count; 
        }
   }

Measured memory_bytes: 21076
#include<stdio.h>
int main() {
    int k, a, b, found = 0;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            found = 1;
        }
    }
    if (found)
    {
        printf("OK\n");
    }
    else
    {
        printf("NG\n");
    }



    return 0;
}

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int n;
	si(n);
	int vec[n];
	for(int  i = 0; i < n; i++)
		si(vec[i]);
	bool sw = true;
	for(int i = 0; i < n; i++)
	{
		if(vec[i] % 2 == 0)
		{
			if(vec[i]%5 == 0 || vec[i]%3 == 0)
				continue;
			else
			{
				sw = false;
				break;
			}
		}
	}

	if(sw)
		printf("APPROVED\n");
	else
		printf("DENIED\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const double eps = 1e-8;

int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	if(c - a - b <= 0) cout <<"No\n";
	else{
		if((c-a-b)*(c-a-b)-4*a*b>0) cout <<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

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

int main() {
	long long n,m,k,ans,cur,res,i,j;
	cin >> n >> m;
	vector<long long> a(n,10);
	for(i=0; i<m; i++){
		cin >> k >> cur;
		k--;
		if(a[k]==10){
			a[k]=cur;
		}else if(a[k]!=cur){
			cout << -1;  return 0;
		}
	}
	
	if(n!=1 && a[0]==0){
		cout << -1; return 0;
	}
	
	if(n==1 && m==0){
		cout << 0; return 0;
	}
	for(i=0; i<n; i++){
		if(a[i]==10 && i==0){
			cout << 1;
		}else if(a[i]==10 && i!=0){
			cout << 0;	
		}else{
			cout << a[i];
		}
	}

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, u, v = map(int, input().split())
u -= 1
v -= 1
F = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  F[a].append(b)
  F[b].append(a)
a_dist = [-1]*N
t_dist = [-1]*N
a_dist[v] = 0
t_dist[u] = 0
def dfs(p):
  dist = [-1]*N
  stack = [p]
  dist[p] = 0
  while stack:
    q = stack.pop()
    for nq in F[q]:
      if dist[nq] == -1:
        dist[nq] = dist[q]+1
        stack.append(nq)
  return dist
a_dist = dfs(v)
t_dist = dfs(u)
ans = 0
for t, a in zip(t_dist, a_dist):
  if t < a:
    temp = a-1
    if ans < temp:
      ans = temp
    
print(ans)

Measured memory_bytes: 29880
#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;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll S = 1;
    rep(i, n) {
        if (1000000000000000000/S < a[i]) {
            S = -1;
            break;
        }
        S *= a[i];
        if (S > 1000000000000000000) {
            S = -1;
            break;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String[] a = sc.next().split("");
		String[] b = sc.next().split("");
		String[] c = sc.next().split("");
		sc.close();
		int cnt = 0;
		for(int i=0;i<n;i++) {
			if(a[i].equals(b[i])&&b[i].equals(c[i])&&a[i].equals(c[i])) {

			}else if(a[i].equals(b[i])||b[i].equals(c[i])||a[i].equals(c[i])) {
				cnt++;
			}else {
				cnt+=2;
			}

		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define LL long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)
#define YES "Yes"
#define NO "No"

using namespace std;

typedef pair<int, int> P;

class CTaxIncrease {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        LL a, b;
        cin >> a >> b;
        for (LL x = 1; x <= 1000; x++) {
            if ((LL)(x*0.08) == a && (LL)(x*0.1) == b) {
                cout << x;
                return;
            }
        }
        cout << -1;
    }
};

int main() {
	CTaxIncrease solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
function main()
  n, m = map(s -> parse(BigInt, s), split(readline()))
  answer = BigInt(1)
  i = BigInt(2)
  while i * i <= m
    if mod(m, i) == 0
      count = BigInt(0)
      while mod(m, i) == 0
        count += 1
        m /= i
      end
      answer *= comb(n + count - 1, count)
    end
    i += 1
  end
  if m > 1
    answer *= n
  end
  println(mod(answer, BigInt(10^9 + 7)))
end

function comb(n::Integer, k::Integer)
  if n - k < k return comb(n, n - k) end
  numer = one(n)
  denom = one(n)
  for i = 0:k - 1
    numer = numer * (n - i)
    denom = denom * (i + 1)
  end
  return div(numer, denom)
end

main()


Measured memory_bytes: 116488
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n;
int a[400000];
int b[400000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u = read() - 1;
		a[u]++;
		b[a[u]]++;
	}
	vector<int>s(n + 1, 0);
	for (int i = 1; i <= n; i++) s[i] = s[i - 1] + b[i];
	for (int k = 1; k <= n; k++) {
		int ok = 0, ng = n + 1;
		while (ng - ok > 1) {
			int t = (ok + ng) / 2;
			if (s[t] >= k * t) ok = t;
			else ng = t;
		}
		cout << ok << endl;
	}
}

Measured memory_bytes: 9344
#include <iostream>
#include <vector>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> have(n, 0);
  int d;
  int a;
  rep(i, k){
    cin >> d;
    rep(j, d){
      cin >> a;
      a--;
      have[a] = 1;
    }
  }
  
  int ans = 0;
  rep(i, n){
    if (have[i] == 0)
      ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
s = input()
a = [str(c) for c in s]
b = set(a)
c = list(b)
if len(c) == 2:
    if s.count(c[0]) == 2 and s.count(c[1]) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var d = int.Parse(line[2]);
        var map = new char[n, m];
        var hcount = 0; var vcount = 0;
        var targ = new string('.', d);
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < m; j++) map[i, j] = s[j];
            hcount += StringCount(s, targ);
        }
        for (int i = 0; i < m; i++)
        {
            var s2 = "";
            for (int j = 0; j < n; j++) s2 += map[j, i];
            vcount += StringCount(s2, targ);
        }
        Console.WriteLine(hcount + vcount);

    }
    public static int StringCount (string s , string t)
    {
        var count = 0;
        var sp = 0;
        while (true)
        {
            var te = s.IndexOf(t, sp);
            if (te < 0) return count;
            else
            {
                count++;
                if (te + 1 > s.Length - t.Length) return count;
                else sp = te + 1;
            }
        }
    }
}

Measured memory_bytes: 9980
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> v(n + 1, k);
	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;
		v[a]++;
	}
	for (int i = 1; i <= n; i++) {
		if (v[i] - q <= 0) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;



int main(int argc, const char * argv[]) {

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

	int A,B;
	int ans;

	cin >> A >> B;

	ans= B % A;

	if (ans == 0) {
		ans = A + B;
	}else{
		ans = B - A;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		Py[] py0 = new Py[m];
		Py[] py1 = new Py[m];
		for(i = 0; i < m; i++) {
			py0[i] = new Py(parseInt(sc.next()), parseInt(sc.next()));
			py1[i] = py0[i];
		}
		sc.close();
		Arrays.sort(py1, new Comparator<Py>() {
			@Override
			public int compare(Py a, Py b) {
				if(a.p != b.p) {
					return a.p - b.p;
				} else {
					return a.y - b.y;
				}
			}
		});
		int prep = -1;
		int xx = 0;
		for(i = 0; i < m; i++) {
			if(prep == py1[i].p) {
				xx++;
			} else {
				prep = py1[i].p;
				xx=1;
			}
			py1[i].y = xx;
		}
		DecimalFormat df = new DecimalFormat("000000");
		PrintWriter pw = new PrintWriter(out);
		for(i = 0; i < m; i++) {
			pw.print(df.format(py0[i].p));
			pw.println(df.format(py0[i].y));
		}
		pw.flush();
	}
}
class Py {
	int p;
	int y;
	Py(int p, int y){
		this.p = p;
		this.y = y;
	}
}


Measured memory_bytes: 68940
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
void main() {
    int N, A, B;
    readf("%d %d %d\n", &N, &A, &B);
    readln.split.to!(long[]).repeat(2).enumerate.map!"a.value[a.index..$+a.index-1]".pipe!(a => zip(a[0], a[1])).map!"a[1]-a[0]".map!(d => min(d*A, B)).sum.writeln;
}

// ----------------------------------------------

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                return reduce!fun(tuple(seed), r);
            }
        }
    }
}

// minElement/maxElement was added in D 2.072.0
static if (__VERSION__ < 2072) {
    auto minElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto minimum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b < minimum) {
                element = a;
                minimum = b;
            }
        }
        return element;
    }
    auto maxElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto maximum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b > maximum) {
                element = a;
                maximum = b;
            }
        }
        return element;
    }
}


Measured memory_bytes: 3964
var abc="abcdefghijklmnopqrstuvwxyz".split("");

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var str=Arr[I];
   [1,3,5,7,9,11,15,17,19,21,23,25].forEach(function(A){
      for(var B=0;B<26;B++){
         var STR="";
         for(var i=0;i<str.length;i++){
            var index=abc.indexOf(str[i]);
            STR+=(index!=-1)?abc[(A*(index+B))%26]:" ";
         }
         if(STR.match(/this|that/))return console.log(STR);
      }
   });
}

Measured memory_bytes: 10452
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

vl fact,finv;
ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=modpw(fact[i+1],MOD-2);
		}
	}
};

ll cb(ll n,ll k){
	chmin(k,n-k);
	ll ret=1;
	rep(i,k){
		ret*=(n-i);
		ret%=MOD;
	}
	rep(i,k){
		ret*=modpw(i+1,MOD-2);
		ret%=MOD;
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	ferm(max(a,b+2));
	ll sum=modpw(2,n);
	ll ans=sum-cb(n,a)-cb(n,b)-1;
	ans=(ans+MOD*2)%MOD;
	puta(ans);
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';
    char c;
    cin >> c;
    cout << mp[c] << endl;
    return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0; i<N; i++) cin >> x.at(i);
  int ans=0;
  for(int i=0; i<N; i++){
    ans+=min(x.at(i),K-x.at(i))*2;
  }
  cout << ans << endl;
}


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

typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        } else {
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    ans = max(cnt, ans);
    cout << ans << endl;
    return 0;
}


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

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<string> vs(n);
  for(int i=0;i<n;i++) cin>>vs[i];

  map<string, int> cnt;
  for(auto s:vs) cnt[s]++;

  int mx=0;
  for(auto p:cnt)
    chmax(mx,p.second);

  for(auto p:cnt)
    if(mx==p.second) cout<<p.first<<endl;

  return 0;
}


Measured memory_bytes: 26752
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	sc.Scan()
	s := sc.Text()
	return strconv.Atoi(s)
}

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

	n, _ := nextInt()

	max := 0
	min := 0
	sum := 0
	for i := 0; i < n; i++ {
		a, _ := nextInt()
		if a <= min || i == 0 {
			min = a
		}
		if max <= a || i == 0 {
			max = a
		}
		sum += a
	}

	fmt.Printf("%d %d %d\n", min, max, sum)
}



Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vi s(N + 1);
    s[0] = 0; s[1] = 0;
    for (int i = 1; i < N; ++i) {
        if (S[i-1] == 'A' && S[i] == 'C')
        s[i + 1] = s[i] + 1;
        else
        s[i + 1] = s[i];
    }
 
    while(Q--) {
        int l, r; cin >> l >> r;
        cout << s[r] - s[l] << endl;
    }
    
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N);
    for (int i = 0; i < M; i++){
      int a, b;
      cin >> a >> b;
      ans.at(a-1)++;
      ans.at(b-1)++;      
    }
  
    for (int i = 0; i < N; i++){
      cout << ans.at(i) << endl;
    }
}


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

typedef pair<string,int> psi;
typedef pair<psi,int> psii;

vector<psii> li;
int n;

bool cmp(psii a, psii b){
  if(a.first.first == b.first.first){
    return a.first.second > b.first.second;
  }
  return a.first.first < b.first.first;
}

int main(){
  cin >> n;
  for(int i=1;i<=n;i++){
    string a;
    int b;
    cin >> a;
    cin >> b;
    psii tmp = make_pair(make_pair(a,b),i);
    li.push_back(tmp);
  }
  sort(li.begin(),li.end(),cmp);
  for(int i=0;i<n;i++){
    printf("%d\n",li[i].second);
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long int a,b,x,count1,count2;
	scanf("%lld%lld%lld",&a,&b,&x);
    if(a == 0){
     count1 = 0;
     count2 = 1 + b/x;
     printf("%lld",count2-count1);
    }
    else{
     count1 = (a-1)/x;
     count2 = b/x;
     printf("%lld",count2-count1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	string s;
	cin >> s;
	string t;
	for (int i = 0; i < string("YAKI").size(); i++) t += s[i];
	if (t == "YAKI") cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

#define PI 3.141592
int main() {
    int n, m;
    cin >> n >> m;

    vector<int> pos(m);
    // O:m
    rep(i, 0, m) {
        cin >> pos[i];
    }

    // O;mlog(m)
    sort(pos.begin(), pos.end());

    vector<int> lenList(m - 1);
    // O:m-1
    rep(i, 0, m - 1) {
        lenList[i] = abs(pos[i] - pos[i + 1]);
    }
    // O:mlog(m)
    sort(lenList.begin(), lenList.end());

    //
    // rep(i, 0, lenList.size()) {
    //     cout << lenList[i] << " ";
    // }
    // cout << endl;

    // O:m-1
    long sum = 0;
    if (lenList.size() > n - 1) {
        rep(i, 0, lenList.size() - (n - 1)) {
            sum += lenList[i];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<map>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    long long n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        long long sum=0;
        if(m>=n*2)
        {
            sum+=n;
            m-=n*2;
            sum+=m/4;
        }
        else
        {
            sum+=m/2;
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  double r;cin>>r;
  cout << r * 2 * 3.141592 << endl;
  return 0;
}

Measured memory_bytes: 3808
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const long long INF = 1e9;
int v[123456], w[123456];
long long ans[105][123456];
int N, W;

int main(int argc, char *argv[])
{
  cin >> N >> W;
  int sum = 0;

  std::fill(ans[0], ans[0] + 100002, INF);
  for (int i = 1; i <= N; i++) {
    std::fill(ans[i], ans[i] + 100002, INF);
    cin >> w[i] >> v[i];
    sum += v[i];
  }

  ans[0][0] = 0;
  for (int i = 1; i <= N; i++) {
    ans[i][0] = 0;
    for (int j = 1; j <= 100000; j++) {
      if (j >= v[i]) {
        ans[i][j] = min(ans[i-1][j], ans[i-1][j-v[i]] + w[i]);
      } else {
        ans[i][j] = ans[i-1][j];
      }
    }
  }


  long long ret=-1;
  for (int i = sum; i >= 0; --i) {
    if(ans[N][i] <= W) {
      ret = i;
      break;
    }
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 98176
/*input
anagram
grandmother
*/
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define sz(x) ( (int) (x).size() )

using vi  = vector<int>;
using ll  = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vvi = vector<vi>;

namespace std { 
    template<> struct hash<pair<int, int> > { 
        size_t operator() (const pair<int, int>& key) const {
            return hash<int>()(key.first) + hash<int>()(key.second);
        }
    };
}

inline int mulmod(int a, int b, int p) {
    ll x = a, y = b, z = p;
    return (x * y) % z;
}

constexpr array<int, 2> primes = {1000000007, 1000000023};
array<int, 4001> alphaSize[2];
array<int, 2> val = {0, 0};

struct rollingHash {
    int alpha;
    rollingHash(int alphaSz = 26) {
        alpha = alphaSz;
        rep(i,0,2) {
            alphaSize[i][0] = 1;
            rep(j,1,alpha) alphaSize[i][j] = mulmod(alphaSize[i][j-1], alpha, primes[i]);
        }
    }
    void addC(char& c) {
        int idx = c - 'a';
        rep(i,0,2) val[i] = ( val[i] + alphaSize[i][idx] ) % primes[i];
    }
    void clear() {
        val[0] = 0ll;
        val[1] = 0ll;
    }
};

string a, b;
vector<pii> memo;
rollingHash rk(26);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b;
    int lenA = sz(a), lenB = sz(b);
    rep(st, 0, lenA) {
        rk.clear();
        rep(x, st, lenA) {
            rk.addC(a[x]);
            memo.push_back(make_pair(val[0], val[1]));
        }
    }
    sort(all(memo));
    int ans = 0;
    pii needle;
    rep(st, 0, lenB) {
        rk.clear();
        rep(x, st, lenB) {
            rk.addC(b[x]);
            needle = make_pair(val[0], val[1]);
            vector<pii>::iterator it = lower_bound(all(memo), needle);
            if(it != memo.end() && *it == needle) ans = max(ans, x - st + 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 68668
import java.util.*;

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

        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();

        int A = Y;
        int B = X;
        int C = A;
        A = Z;

        System.out.println(A + " " + B + " " + C);
    }
}


Measured memory_bytes: 39216
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll a , b , c, k ;
	cin>> a >> b >> c >> k ;
	ll ans = min(a,k) ;
	k=k-a-b;
	ans-=max(0LL , min(c , k));
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

#define ZFor(i,n) for(int i=0;i<n;i++)
#define WFor(i,n) for(int i=1;i<=n;i++)
#define ZWFor(i,n) for(int i=0;i<=n;i++)
#define WZFor(i,n) for(int i=1;i<n;i++)
#define Max -2100000000
#define Min 2100000000
#define F first
#define S second
#define F1 first.first
#define F2 first.second
#define F3 second

typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;


int main(void){
	
	int n,m,hx[50],hy[50],cx[50],cy[50],ans=Min,ansn,x,y;
	
	scanf("%d %d",&n,&m);
	
	for(int i=0;i<n;i++) scanf("%d %d",&hx[i],&hy[i]);
	for(int i=0;i<m;i++) scanf("%d %d",&cx[i],&cy[i]);
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			x = hx[i] - cx[j];
			if(x<0) x*=-1;
			y = hy[i] - cy[j];
			if(y<0) y *= -1;
			
			if(ans > x+y){
				ans=x+y;
				ansn=j;
			}
		}
		printf("%d\n",ansn+1);
		ans=Min;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
const int INF = 1e9;
using P = pair<ll,int>;

void dfs(int v,ll a,int signT,ll &maxT,ll &minT,
    vector<P> &visited,vector<vector<P>> &g){
    if(visited[v] != P(0,0)){
        ll b = visited[v].first;
        int sign = visited[v].second;
        if(a!=b && sign==signT) maxT = 0;
        if(sign != signT){
            if(abs(a-b)&1) maxT = 0;
            minT = max(minT, abs(a-b)/2);
            maxT = min(maxT, abs(a-b)/2);
        }
        return;
    }
    visited[v] = {a,signT};
    if(signT == +1) minT = max(minT, 1-a);
    if(signT == -1) maxT = min(maxT, a-1);
    for(P &e : g[v]){
        ll sum = e.first;
        int to = e.second;
        dfs(to,sum-a,-signT,maxT,minT,visited,g);
    }
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<P>> g(n);
    rep(i,m){
        int u,v;
        ll s;
        cin>>u>>v>>s;
        u--, v--;
        g[u].push_back({s,v});
        g[v].push_back({s,u});
    }
    ll maxT = INF, minT = 0;
    vector<P> visited(n); // <a,sign> (a + sign*t)
    dfs(0,0,+1,maxT,minT,visited,g);
    cout<<max(0LL,maxT-minT+1)<<endl;
    return 0;
}



Measured memory_bytes: 18816
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, m; cin >> n >> m;
    vint k(m);
    vector<vint> s(m);
    rep(i, m) {
        cin >> k[i];
        s[i] = vint(k[i]);
        rep(j, k[i]) { cin >> s[i][j]; s[i][j]--; }
    }
    vint p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(flag, 1 << n) {
        bool flash = true;
        rep(i, m) {
            int cnt = 0;
            rep(j, k[i]) {
                int mask = (1 << s[i][j]);
                if((flag & mask) != 0) {
                    cnt++;
                }
            }
            flash &= (cnt % 2) == p[i];
        }
        if(flash) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	vector<int> f(N + 1);
	fore(i,1, N)
	{
		fore(j,i, N)
		{
			if(j*j>N)
				break;
			fore(k, j, N)
			{
				if (k*k > N)
					break;
				
				int t = i * i + j * j + k * k + i * j + i * k + j * k;
				if(t > N)
					break;
				if (i == j)
				{
					if (j == k)
						f[t]++;
					else
						f[t] += 3;
				}
				else if (j == k)
				{
					f[t] += 3;
				}
				else
				{
					f[t] += 6;
				}
			}
		}
	}
	fore(i, 1,N)
		cout << f[i] << endl;
	return 0;
}


Measured memory_bytes: 3608
from collections import deque

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

opt_p = deque(p[:x])
opt_q = deque(q[:y])
opt_r = deque(r[:x+y])

while len(opt_r) > 0:
    if opt_p[-1] < opt_r[0] or opt_q[-1] < opt_r[0]:
        if opt_p[-1] < opt_q[-1]:
            opt_p.pop()
            opt_p.appendleft(opt_r.popleft())
        else:
            opt_q.pop()
            opt_q.appendleft(opt_r.popleft())
    else:
        break

print(sum(opt_p) + sum(opt_q))


Measured memory_bytes: 23616
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}


int n;
map<int,int> a;



signed main(){
	read(n);
	for(int i=1,x;i<=n;i++){
		read(x);
		if(a[x]){
			puts("NO");
			return 0;
		}
		a[x]=1;
	}
	puts("YES");
}

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

int n,m,q;
int a[55],b[55],c[55],d[55];
int ans,r[15];

void dfs(int p,int mn){
    if(p==n){
        int cur=0;
        for(int i=0;i<q;i++){
            if(r[a[i]]+c[i]==r[b[i]])cur+=d[i];
        }
        ans=max(ans,cur);
        return;
    }
    for(int i=mn;i<=m;i++){
        r[p]=i;
        dfs(p+1,i);
    }
}

int main(){

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

    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];a[i]--;b[i]--;
    }
    dfs(0,1);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3648
import math
a, b, x = map(int, input().split())
if x >= a**2 * b / 2:
    tan = (2 * (a ** 2 * b - x)) / a ** 3
else:
    tan = (a*b**2) / (2 * x)
print(math.atan(tan)/ math.pi * 180)


Measured memory_bytes: 9260
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
	int r, D, x;
	cin >> r >> D >> x;
	for(int i=0; i<10; ++i){
		x *= r;
		x -= D;
		cout << x << endl;
	}
}

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

int mx=1e9+7;
vector<int>v[100007];
int level[100007];
bool visited[1000007];

void debug(int n)
{
	for(int s=1;s<=n;++s){
		cout<<s<<": ";
		for(auto u:v[s]) cout<<u<<" ";
		cout<<"\n";
	}
	return;
}

void find_level()
{
	level[1]=0;
	queue<int>q;
	visited[1]=true;
	q.push(1);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto e:v[x]){
			if(!visited[e]){
				q.push(e);
				level[e]=level[x]+1;
				cout<<e<<" "<<level[e]<<"\n";
				visited[e]=true;
			}
		}
	}
	//for(int i=1;i<=n;++i) cout<<i<<" "<<level[i]<<"\n";
	return;
}

void solve()
{
	int n,m;
	cin>>n>>m;
	vector<int>v[n+1];
	int level[n+1];
	for(int i=1;i<=n;++i) level[i]=mx;
	while(m--){
		int a,b;
		cin>>a>>b;
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	//debug(n);
	find_level();
	//for(int parent=1;parent<=n;++parent) for(int child:v[parent]) level[child]=min(level[child],level[parent]+1);
	//for(int i=1;i<=n;++i) cout<<i<<" "<<level[i]<<"\n";
	level[1]=0;
	queue<int>q;
	visited[1]=true;
	q.push(1);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto e:v[x]){
			if(!visited[e]){
				q.push(e);
				level[e]=level[x]+1;
				//cout<<e<<" "<<level[e]<<"\n";
				visited[e]=true;
			}
		}
	}
	vector<int>direction;
	for(int room=2;room<=n;++room){
		int signal,mn=1e7+7;
		for(int sub_room:v[room]){
			if(level[sub_room]==mx){
				cout<<"No";
				return;
			}
			if(level[sub_room]<mn) signal=sub_room,mn=level[sub_room];
		}
		direction.emplace_back(signal);
		//cout<<signal<<"\n";
	}
	cout<<"Yes\n";
	for(int e:direction) cout<<e<<"\n";
	return;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 13176
h,w=gets.split.map &:to_i
n=gets.to_i
a=gets.split.map &:to_i
b=[]
n.times do |i|
  b+=[i+1]*a[i]
end
r=[]
h.times do |i|
 g=b[i*w..i*w+w-1]
 g.reverse! if i%2==1
 r+=[g]
end
puts r.map{|e|e.*(" ")}.*("\n")



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

bool isDouble(int);

int main()
{
	using vi = std::vector<int>;

	int N, D;
	scanf("%d%d", &N, &D);
	std::vector<vi> points(N, vi(D));
	for (auto& e: points)
		for (auto& f: e)
			scanf("%d", &f);
	
	int count{};
	for (int i{}; i < N; i++)
		for (int j{i + 1}; j < N; j++)
		{
			int pow2{};
			for (int k{}; k < D; k++)
				pow2 += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
			if (isDouble(pow2))
				count++;
		}
	printf("%d\n", count);

	return 0;
}

bool isDouble(int num)
{
	for (int i{}; i * i <= num; i++)
		if (i * i == num)
			return true;
	return false;
}

Measured memory_bytes: 256