akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:u32=read();
    println!("{}", if n>999{"ABD"}else{"ABC"});

}


Measured memory_bytes: 4352
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<Integer>();
			used[i].add(-1);
		}
		int sat = 0;
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used[j].last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used[now].add(d);
			sat += max;
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		Random r = new Random();
		while(true) {
			int d = r.nextInt(D);
			for(int q = 0; q < 26; q++) {
				int temp = 0;
				temp -= s[d][con[d]];
				temp += s[d][q];
				temp -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
				temp += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
				if(temp > 0) {
					sat += temp;
					con[d] = q;
					used[con[d]].remove(d);
					used[q].add(d);
				}
			}
			if(System.currentTimeMillis() - start > 1850)
				break;
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


Measured memory_bytes: 59140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int dp[200005];
int solve(){
    int w; cin>>n>>w;
    int a[n+1],b[n+1];
    rep(i,1,n) cin>>a[i]>>b[i];
    rep(i,1,n){
        rep1(j,w,0){
            dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
        }
    }
    cout<<dp[w];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q, _e, _w, _q;
    string _s;
    while(cin >> N >> Q && N){
        map<int, string> cvt;
        map<int, int> cvt2;
        int start = INF, last = -1;
        rep(i, N){
            cin >> _s >> _e >> _w;
            cvt[_w] = _s;
            cvt2[_w] = _w - _e;
            start = min(start, _w - _e + 1);
            last = max(last, _w);
        }
        rep(i, Q){
            cin >> _q;
            if(_q < start || last < _q)
              cout << "Unknown" << endl;
            else{
                auto lb = cvt.lower_bound(_q);
                string sa = lb->second;
                int ia = _q - cvt2[lb->first];
                if(ia >= 1)
                  cout << sa << ' ' << ia << endl;
                else
                  cout << "Unknown" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] and s[0]==s[2]){
        cout<<"No";
    }else {
        cout<<"Yes";
    }
        return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i = 1;i <= n;++i){
            int x = i;
            if(x % 3 == 0) sb.append(' ').append(i);
            else while(x > 0) {
                if (x % 10 == 3){
                    sb.append(' ').append(i);
                    break;
                }
                x /= 10;
            }
        }
        System.out.println(sb);
    }

}

Measured memory_bytes: 27072
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
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;}
int main(){
    ll a,b;
  cin>>a>>b;
  ll ans=a+b;
  chmax(ans,a-b);
  chmax(ans,a*b);
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  int sum=0;
  cin>>N;
  int len = N.length();
	for(int i= 0; i<len;i++){
		sum += (int)(N[i]-'0');
	}
	if(stoi(N)%sum==0){
	cout<<"Yes"<<endl;
	}else{
	cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int[] v = new int[k.length];
		for (int i = 0; i < v.length; i++) {
			v[i] = Integer.parseInt(k[i]);
		}

		if (v[0] < v[1] && v[1] < v[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 26096
import java.io.IOException;
import java.util.*;

/**
 */
class Main {
	final static int N = 10;

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int choho = 0;
		int hishi = 0;
		while (in.hasNext()) {
			String[] strArr = in.nextLine().split(",");
			int[] intArr = new int[strArr.length];
			for(int i=0;i<strArr.length;i++) {
				intArr[i] = Integer.parseInt(strArr[i]);
			}
			if(intArr[0] * intArr[0] + intArr[1] * intArr[1] == intArr[2] * intArr[2]) {
				choho++;
			} else if(intArr[0] == intArr[1]) {
				hishi++;
			}
		}
		System.out.println(choho);
		System.out.println(hishi);
	}
}

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

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


Measured memory_bytes: 256
#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>;

void Main()
{
  string s; cin >> s;
  int cnt = 0;
  int maxlen = 0;
  for(char c : s) {
    if (c == 'A' or c == 'T' or 
        c == 'G' or c == 'C') cnt++;
    else cnt = 0;
    maxlen = max(maxlen, cnt);
  }
  cout << maxlen << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
int n,m;
char mp[205][205];
bool In(int x,int y){
	if (x<=0 || y<=0 || x>n || y>m){
		return false;
	}
	return true;
}
int Ex,Ey;
int dist1[205][205];
int dist2[205][205];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
bool vis[205][205];
int bfs1(int x,int y){
	queue<pair<int,int> > q;
	q.push(make_pair(x,y));
	dist1[x][y]=0;
	vis[x][y]=true;
	while (!q.empty()){
		pair<int,int> t=q.front();
		q.pop();
		int x=t.first;
		int y=t.second;
		for (int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			//cout<<nx<<" "<<ny<<endl;
			if (!In(nx,ny)){
				continue;
			}
			if (mp[nx][ny]=='#'){
				continue;
			}
			if (vis[nx][ny]){
				continue;
			}
			if (mp[nx][ny]=='@'){
				continue;
			}
			dist1[nx][ny]=dist1[x][y]+1;
			vis[nx][ny]=true;
			q.push(make_pair(nx,ny));
		}
	}
}
int bfs2(int x,int y){
	queue<pair<int,int> > q;
	while (!q.empty()){
		q.pop();
	}
	q.push(make_pair(x,y));
	dist2[x][y]=0;
	vis[x][y]=true;
	while (!q.empty()){
		pair<int,int> t=q.front();
		q.pop();
		int x=t.first;
		int y=t.second;
		for (int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			//cout<<nx<<" "<<ny<<endl;
			if (!In(nx,ny)){
				continue;
			}
			if (mp[nx][ny]=='#'){
				continue;
			}
			if (vis[nx][ny]){
				continue;
			}
			if (mp[nx][ny]=='$'){
				continue;
			}
			dist2[nx][ny]=dist2[x][y]+1;
			vis[nx][ny]=true;
			q.push(make_pair(nx,ny));
		}
	}
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			cin>>mp[i][j];
			if (mp[i][j]=='%'){
				Ex=i;
				Ey=j;
			}
		}
	}
	bfs1(Ex,Ey);
	memset(vis,0,sizeof(vis));
	bfs2(Ex,Ey);
	int mn=1e9;
	int Plen=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (mp[i][j]=='$'){
				if (dist1[i][j]==0){
					continue;
				}
				mn=min(mn,dist1[i][j]);
			}
			if (mp[i][j]=='@'){
				Plen=dist2[i][j];
			}
		}
	}
/*	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			cout<<dist1[i][j]<<" ";
		}
		cout<<endl;
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			cout<<dist2[i][j]<<" ";
		}
		cout<<endl;
	}*/
	if (Plen==0){
		cout<<"No";
	}
	else if (mn<=Plen){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	cout<<endl;
	return 0;
}

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

int main() {
  long long N,K;
  cin >> N >> K;
  long long a = N/K;
  long long X,Y;
  X = N - K*a;
  Y = -N + K*(a+1);
  
  if (N%K == 0) {
    cout << 0 <<endl;
  }
  else if (X < Y) {
    cout << X <<endl;
  }
  else {
    cout << Y <<endl;
  }
  
    
    
}


Measured memory_bytes: 256
using System;
					
public class Program
{
	public static void Main()
	{
		Console.ReadLine();
		
		double[] x = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		double[] y = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		
		double Dxy1 = 0.0;
		double Dxy2 = 0.0;
		double Dxy3 = 0.0;
		double Dmax = 0.0;
		
		for(int i = 0; i < x.Length; i++) {
			double t = Math.Abs(x[i] - y[i]);
			
			Dxy1 += t;
			Dxy2 += t * t;
			Dxy3 += t * t * t;
			
			if(t > Dmax) Dmax = t;
		}
		
		Console.WriteLine( Dxy1 );
		Console.WriteLine( Math.Sqrt(Dxy2) );
		Console.WriteLine( Math.Pow(Dxy3, 1/3.0) );
		Console.WriteLine( Dmax );
	}
}

Measured memory_bytes: 9544
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int mi = IINF;
    int idx = -1;
    rep(i, n){
        if(mi > a[i]){
            mi = a[i];
            idx = i;
        }
    }
    cout << idx + 1 << endl;
    return 0;
}


Measured memory_bytes: 3104
/**
 * CODE
 * BY
 * VIKAS VERMA
 * 
 * $$Always Check for Constraints
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, n) for (int i = 1; i <= n; i++)
#define fr(i, n) for (ll i = n - 1; i >= 0; i--)
#define REP(l, r) for (int i = l; i < r; i++)
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n"
#define jaldi ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef long long ll;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6 + 13;
//=======================
vi g[N];
int a[N];
//=======================

void solve()
{
  int x;
  cin >> x;
  cout << (x == 0) << endl;
}

int main()
{
  jaldi
      // #ifndef ONLINE_JUDGE
      //       freopen("input.txt", "r", stdin);
      //   freopen("output.txt", "w", stdout);
      // #endif
      int t = 1;

  // cin >> t;

  while (t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 50524
#include <stdio.h>

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

  if(a < b){
    printf("a < b\n");
  }else if(a > b){
    printf("a > b\n");
  }else
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
//#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;

//=============================================================
string S, T;

void solve()
{
  bool isOK = true;

  set<pair<char, char>> s2t;
  rep(i, S.size())
  {
    s2t.insert(make_pair(S[i], T[i]));
  }

  bool exs1[26] = {};
  bool exs2[26] = {};

  for (auto x : s2t)
  {
    if (exs1[x.second - 'a'])
    {
      isOK = false;
      break;
    }
    else
      exs1[x.second - 'a'] = true;

    if (exs2[x.first - 'a']) {
      isOK = false;
      break;
    }
    else exs2[x.first - 'a'] = true;
  }
  cout << (isOK ? "Yes" : "No") << endl;
}
signed main()
{
  cin >> S;
  cin >> T;
  if (S.size() != T.size())
    return -1;
  solve();
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    vsort(v);
    int cnt = 3;
    for (int i = 1; i < 3; i++) {
        if (v[i] == v[i-1]) {
            cnt--;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;
using vpl = vector<pl>;

int main()
{
    int m;
    cin >> m;
    vpl dc(m);
    rep(i, m)
    {
        cin >> dc[i].first >> dc[i].second;
    }
    ll round = 0;
    ll totallen = 0;
    ll total = 0;
    rep(i, m)
    {
        totallen += dc[i].second;
        total += dc[i].first * dc[i].second;
    }
    round = (totallen - 1) + ( (total - 1) / 9);
    cout << round << endl;
}

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

struct UnionFind{
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int size):r(size,-1),p(size,0){
    for(int i=0;i<size;i++)p[i]=i;
    
  }
  int find(int x){
    if(x==p[x])return x;
    return p[x]=find(p[x]);
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);

    if(x==y)return;
    if(r[x]<r[y]){
      swap(x,y);
    }
    r[x]+=r[y];
    p[y]=x;
  }
};

int main(){
  int N,Q;
  int com,x,y,cn=0;
  cin>>N>>Q;
  UnionFind U(N);
  //vector<pair<int,int> > pairs(Q);
  vector<int>p(Q);
  for(int i=0;i<Q;i++){
    cin>>com>>x>>y;
    if(com==0){
      U.unite(x,y);//unite
    }
    if(com==1){
      //pairs[cn]=make_pair(x,y);
      //U.unite(x,y);
      p[cn]=U.same(x,y);
      cn++;
    }   
  }

  for(int i=0;i<cn;i++){
    cout<<p[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3284
MOD = 10**9 + 7
s = int(input())

# https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8


def cmb(n, r):
  if (r < 0 or r > n):
    return 0
  r = min(r, n - r)
  return g1[n] * g2[r] * g2[n - r] % MOD


N = s * 2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)

ans = 0
for k in range(1, s // 3 + 1):
  n = s - 3 * k
  ans += cmb(n + k - 1, n)
  ans %= MOD
print(ans)


Measured memory_bytes: 9488
n,m = map(int,input().split())
lists = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    pattern = []
    flag = True
    for j in range(n):
        if ((i >> j) & 1):
            pattern.append(1)
        else:
            pattern.append(0)
    for k in range(m):
        k_kosu = 0
        for l in range(1,len(lists[k])):
            if pattern[lists[k][l]-1] == 1:
                k_kosu += 1
        if k_kosu % 2 != p[k]:
            flag = False
            break
    if flag:
        ans += 1 
print(ans)

Measured memory_bytes: 3064
import math

n = int(input())

def p(x):
  if x == 2:
    return True
  for i in range(2,int(math.sqrt(x))+1):
    if x % i == 0:
      return False
  return True

def check(x):
  res = 10 ** 12
  for i in range(2,int(math.sqrt(x))+1):
    if x % i == 0:
      s = (i-1) + (x//i -1)
      res = min(res,s)
  return res

if p(n):
  print(n-1)
else:
  print(check(n))
      

Measured memory_bytes: 9184
#include<stdio.h>
int main(){
	int i, j, max=0, min=1000, sum=0, point;
	while(1){
		scanf("%d", &i);
		if(i == 0)
			break;
		else{
			for(j=0; j<i; j++){
				scanf("%d", &point);
				if(point <= min)
					min = point;
				if(point >= max)
					max = point;
				sum += point;
			}
				printf("%d\n", (sum-max-min)/(i-2));
				min=1000;
				max=0;
				sum=0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
#define int long long
#define inf 1e17
using namespace std;
int n,m,k,ans;
int a[11][11],pd1[11],pd2[11];
char ch;
void zh()
{
	int tot=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(a[i][j]&&(pd1[i]==pd2[j])&&pd1[i]==0)
	tot++;
	if(tot==k)
	ans++;
}
void dfs1(int x)
{
	if(x==m+1)
	{
		zh();
		return;
	}
	pd2[x]=0;
	dfs1(x+1);
	pd2[x]=1;
	dfs1(x+1);
}
void dfs(int x)
{
	if(x==n+1)
	{
		dfs1(1);
		return;
	}
	pd1[x]=0;
	dfs(x+1);
	pd1[x]=1;
	dfs(x+1);
}
signed main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		ch=getchar();
		while(ch!='#'&&ch!='.')
		ch=getchar();
		if(ch=='#')
		a[i][j]=1;
	}
	dfs(1);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	string s;
	cin >> s;
	map<char, int> mp;
	for (int i = 0; i < s.size(); i++) {
		mp[s.at(i)]++;
		if (mp[s.at(i)] > 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K,S,T;
int A[51];

ll C[55][55];

int dp[1<<18];
ll dp2[1<<18];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,52) for(j=0;j<=i;j++) C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j]);

	
	cin>>N>>K>>S>>T;
	
	if(S&~T) return _P("0\n");
	
	FOR(i,N) {
		cin>>A[i];
		if((A[i]&~T) ||(A[i]&S)!=S) {
			i--;
			N--;
			continue;
		}
	}
	
	int mask;
	int U=T&(~S);
	ll ret=0;
	FOR(mask,1<<18) if((mask&U)==mask) {
		FOR(i,N) dp[A[i]&mask]++;
		ll tmp=0;
		FOR(i,N) if(dp[A[i]&mask]) {
			for(j=1;j<=min(K,dp[A[i]&mask]);j++) tmp+=C[dp[A[i]&mask]][j];
			dp[A[i]&mask]=0;
		}
		if(__builtin_popcount(mask)%2) ret-=tmp;
		else ret+=tmp;
	}
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main()
{
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
  {
    cin >>a.at(i);
  }
  // greedy method
  sort(a.begin(), a.end(),greater<int>());
  int alice=0;
  int bob=0;
  for(int i=0; i<N; i++)
  {
    if(i%2==0) alice+=a.at(i);
    else bob+=a.at(i);
  }
  
  cout<<abs(alice-bob)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// 文字の入力
		String s = sc.next();

     	 if(a >= 3200){
           System.out.println(s);
     	 }else{
           System.out.println("red");
         };
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

double toDeg(double rad)
{
    return (rad * 180.0 / M_PI);
}
int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    double h = (double)x / (a * a);
    if (b / 2 < h)
    {
        printf("%.10lf\n", toDeg(atan(2 * (b - h) / a)));
    }
    else
    {
        printf("%.10lf\n", toDeg(((M_PI / 2) - atan((2 * x) / (double)(a * b * b)))));
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	int K;
	cin >> K;
	set<string> st;
	for(int i=0;i<n;i++){
		string t = "";
		for(int j=0;j<5;j++){
			if(i+j<s.size()){
				t = t + s[i+j];
				st.insert(t);
			}
		}
	}
	auto it = st.begin();
	advance(it,K-1);
	cout << *it << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,p;
  cin >> a >> b >> c >> d >> p;
  cout << min(a * p, b + ((c < p) ? d*(p-c):0))<<endl;
  return 0;
}

Measured memory_bytes: 3192
//#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

const i64 INF = 1LL << 50;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 H, W, K;
  cin >> H >> W >> K;
  pair<i64, i64> start, goal;
  cin >> start.first >> start.second;
  cin >> goal.first >> goal.second;
  start.first--;
  start.second--;
  goal.first--;
  goal.second--;

  vector<string> grid(H);
  cin.ignore();
  REP(i, H) {
    getline(cin, grid[i]);
    assert(grid[i].size() == (size_t)W);
  }

  map<tuple<int, int, int>, i64> distm;
  auto get_dist = [&](int r, int c, int dir) -> i64 {
    auto it = distm.find(make_tuple(r, c, dir));
    if (it == distm.end()) return INF;
    return it->second;
  };
  auto solve = [&]() -> i64 {
    priority_queue<tuple<i64, int, int, int>> pq;
    REP(i, 4) { pq.emplace(0LL, start.first, start.second, i); }
    while (pq.size()) {
      auto [d, r, c, dir] = pq.top();
      d *= -1;
      pq.pop();
      if (get_dist(r, c, dir) <= d) continue;
      if (r == goal.first && c == goal.second) {
        return (d + K - 1) / K;
      }
      distm[{r, c, dir}] = d;
      DEBUG(r, c, d);
      REP(j, 4) {
        i64 nd = d;
        if (j > 0 && nd % K != 0) {
          nd = nd - nd % K + K;
        }
        nd++;
        int ndir = (dir + j) % 4;
        int nr = r + dx[ndir];
        int nc = c + dy[ndir];
        if (nr < 0 || nr >= H) continue;
        if (nc < 0 || nc >= W) continue;
        if (grid[nr][nc] == '@') continue;
        if (get_dist(nr, nc, ndir) <= nd) continue;
        pq.emplace(-nd, nr, nc, ndir);
      }
    }
    return -1LL;
  };
  i64 ans = solve();
  cout << ans << endl;
}

Measured memory_bytes: 120524
#include<stdio.h>
int main()
{
    int a, b, t, ku, ka;
    scanf("%d",&a);
    scanf("%d",&b);

    t=a+b;
    ku=a-b;
    ka=a*b;

    if(ka >= t && ka >= ku){
        printf("%d", ka);
        }
    else if(ku >= t && ku >= ka){
            printf("%d", ku);
        }
    else if(t >= ku && t >= ka){
            printf("%d", t);
        }
    else{
        printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
a, b, c, x, y = map(int, input().split())
ans = 0
r = min(x, y)

if a + b > 2 * c:
    ans += (2 * c) * r
    x -= r
    y -= r
if a > 2 * c and x > 0:
    ans += (2 * c) * x
    y -= x
    x = 0
if b > 2 * c and y > 0:
    ans += (2 * c) * y
    x -= y
    y = 0
if x > 0:
    ans += a * x
if y > 0:
    ans += b * y
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,ll>pa;

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

double pi=acos(-1);
ll a[N];
int main()
{
    ll n,z,w;
    cin>>n>>z>>w;
    for(int i=1;i<=n;i++) cin>>a[i];
    if(n>1)
    cout<<max(abs(a[n]-w),abs(a[n-1]-a[n]));
    else 
    cout<<abs(a[n]-w);
    return 0;
}



Measured memory_bytes: 3624
n = int(input())

t_num , a_num = 1, 1

for t, a in [map(int, input().split()) for _ in range(n)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        # m = m + 1
        t_k = (pre_t_num + t - 1) // t
        a_k = (pre_a_num + a - 1) // a
        m = max(t_k, a_k)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
print()
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    int H,W;
    cin >> H >> W;
    char tile[H+1][W+1];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> tile[i][j];
        }
    }

    bool skip_h[H], skip_w[W];
    memset(skip_h, 0, sizeof(skip_h));
    memset(skip_w, 0, sizeof(skip_w));
    for(int h=0; h<H; h++){
        bool flag=true;
        for(int w=0; w<W; w++){
            if(tile[h][w]!='.') flag=false;
        }
        skip_h[h]=flag;
    }
    for(int w=0; w<W; w++){
        bool flag=true;
        char tmp=tile[0][w];
        for(int h=0; h<H; h++){
            if(tile[h][w]!='.') flag=false;
        }
        skip_w[w]=flag;
    }
    for(int h=0; h<H; h++){
        if(skip_h[h]==true) continue;
        for(int w=0; w<W; w++){
            if(skip_w[w]==true) continue;
            cout << tile[h][w];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import heapq
n , m = map(int, input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
heapq.heapify(a)

for i in range(m):
    t = (heapq.heappop(a)*(-1)//2)*(-1)
    heapq.heappush(a,t)

print(sum(a)*(-1))


Measured memory_bytes: 14180
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
#include <map>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<int,int> m;
  REP(i,N){
    int A;
    cin>>A;
    m[A]++;
  }
  bool flag=1;
  if(N%2){
    if(m[0]!=1)flag=0;
    REP(i,N/2){
      if(m[2*(i+1)]!=2)flag=0;
    }
  }
  else{
    REP(i,N/2){
      if(m[2*i+1]!=2)flag=0;
    }
  }
  if(flag){
    lint ans=1;
    REP(i,N/2){
      ans*=2;
      ans=ans%(1000*1000*1000+7);
    }
    cout<<ans<<endl;
  }
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 4096
N, M = map(int, input().split())

ans = [0 for i in range(M)]

for i in range(N):
    tmp = list(map(int, input().split()))
    for j in range(tmp[0]):
        ans[tmp[j+1]-1]+=1
        
now = 0
        
for i in range(M):
    if ans[i]==N:
        now+=1
        
print(now)



Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	ll res = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n-1) {
		cin >> c[i];
	}
	ll bef = a[0]-1;
	rep(i, n) {
		ll k = a[i]-1;
		res += b[k];
		if (k == bef + 1) {
			res += c[bef];
		}
		bef = k;
	}
	cout << res << endl;
}



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

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};

typedef struct node *Nodepointer;

Nodepointer r,NIL;

void insert(int);
void print(void);

void inorder(Nodepointer);
void preorder(Nodepointer);

int main(){
  int i,n,num;
  char c[7];

scanf("%d",&n);
 
for(i=0;i<n;i++){
  scanf("%s",c);
  
  if(c[0]=='i'){
    scanf("%d",&num);
    insert(num);
  }
  else print();
 }
  return 0;
}

void insert(int k){
  Nodepointer y=NIL;
  Nodepointer x=r;

  Nodepointer z = (Nodepointer)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NIL){
    r = z;
  }

  else if(z->key < y->key){
    y->left = z;
  }

  else{
    y->right = z;
  }

}

void print(void){
    inorder(r);
    printf("\n");
    preorder(r);
    printf("\n");
}

void inorder(Nodepointer a){
  if(a==NIL)return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}
void preorder(Nodepointer a){
  if(a == NIL){
    return;
  }
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}



Measured memory_bytes: 25144
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 209;

int wx[N];
int wy[N];
int to_x[N];
int to_y[N];
bool used[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    wx[x] = 0;
    wy[y] = 0;
    to_y[x] = y;
    to_x[y] = x;
  }
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    wx[x] = 1;
    wy[y] = 1;
    to_y[x] = y;
    to_x[y] = x;
  }
  memset(used, false, sizeof used);
  int ans = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (wx[i] == 0) {
      continue;
    }
    for (int j = 2 * n - 1; j >= 0; --j) {
      if (wy[j] == 1 || used[j]) {
        continue;
      }
      if (to_x[j] < i && j < to_y[i]) {
        used[j] = true;
        ++ans;
        break;
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using pint = pair<int, int>;

int n;
vector<vector<pint>> v;

bool judge(int bit) {
    for (int i = 0; i < n; ++i) {
        if (!((bit >> i) & 1)) continue; // 不親切な人の証言は無視

        for (auto xy: v[i]) {
            int x = xy.first;
            int y = xy.second;
            bool pro = (bit >> x) & 1;
            if (y == 1 && !pro) return false; // 矛盾
            if (y == 0 &&  pro) return false; // 矛盾
        }
    }

    return true;
}


int main() {
    cin >> n;
    v.resize(n);

    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        v[i].resize(a);

        for (int j = 0; j < a; ++j) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << n); ++bit) { // 0: 不親切な人 1: 正直者
        if (judge(bit)) { // 矛盾がなかったら、1の数を数える。
            int cnt = 0;
            for (int i = 0; i < n; ++i) if ((bit >> i) & 1) ++cnt;
            res = max(res, cnt);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

cnt = 0
x = float('inf')
s = 0
for a in A:
    if a < 0:
        cnt += 1
    a = abs(a)
    x = min(x, a)
    s += a

if cnt % 2 == 0:
    print(s)
else:
    print(s - 2 * x)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char n;
    int a,b;
    cin>>a>>b;
    for(int s=0;s<a;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-')
    {
        cout<<"No"<<endl;
        return 0;

    }
    for(int s=0;s<b;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl; 
    return 0;
}

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

int main()
{
    int n, l;
    std::cin >> n >> l;

    std::vector<std::string> str;
    for (int i = 0; i < n; ++i)
    {
        std::string tmp;
        std::cin >> tmp;
        str.emplace_back(std::move(tmp));
    }
    std::sort(str.begin(), str.end());

    for (const auto &s : str)
    {
        std::cout << s;
    }
    std::cout << std::endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll w, h;
    cin >> w >> h;
    vector<ll> p(w), q(h);
    for (int i=0; i<w; ++i) cin >> p.at(i);
    for (int i=0; i<h; ++i) cin >> q.at(i);

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    ll res = 0;
    ll cnt = (h+1) * (w+1) - 1;
    ll curP = 0, curQ = 0;
    while (cnt > 0) {
        bool addP = true;
        if (curP == w || (curQ < h && p.at(curP) > q.at(curQ))) addP = false;
        ll add = addP ? h+1-curQ : w+1-curP;
        chmin(add, cnt);
        cnt -= add;
        res += add * (addP ? p.at(curP++) : q.at(curQ++));
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 2e5 + 7;

int n, k, cnt[N];

int main()
{
	_upgrade
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        cnt[x - 1]++;
    }
    sort(cnt, cnt + n);
    reverse(cnt, cnt + n);
    int sm = 0;
    for(int i = 0; i < k; i++)
        sm += cnt[i];
    cout << n - sm << "\n";
    return 0;
}


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

const int MOD = 1000000007;
const int MAXN = 100055;

int dp[MAXN][2];

vector<int> G[MAXN];
bitset<MAXN> chk;

int N;

void f(int i) {
	chk[i] = true;
	dp[i][0] = dp[i][1] = 1;
	for(int v : G[i]) if(!chk[v]) {
		f(v);
		dp[i][0] = ll(dp[i][0]) * dp[v][1] % MOD;
		dp[i][1] = ll(dp[i][1]) * (dp[v][0] + dp[v][1]) % MOD;
	}
}

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

	cin >> N;
	for(int i = 1, a, b; i < N; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}

	f(1);

	cout << (dp[1][0] + dp[1][1]) % MOD << endl;
	return 0;
}

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

using namespace std;

int main(){
	long long  a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[2]%2==0){
		cout<<0<<endl;
	}else{
		cout<<a[0]*a[1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[200005]={},ans=0,cnt[200005]={};
  cin >> n;
  map<ll,ll> m;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    m[a[i]]++;
    if(m[a[i]]>1) {
      ans+=m[a[i]]-1;
      cnt[a[i]]+=m[a[i]];
    }
  }
  for(int i=0; i<n; i++) {
    cout << ans-m[a[i]]+1 << "\n";
  }
}


Measured memory_bytes: 11136
#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;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

unsigned  int  randInt (){ 
    static  unsigned  int  tx  =  123456789 ,  ty = 362436069 ,  tz = 521288629 ,  tw = 88675123 ; 
    unsigned  int  tt  =  ( tx ^ ( tx << 11 )); 
    tx  =  ty ;  ty  =  tz ;  tz  =  tw ; 
    return  (  tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 ))  ); 
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    int s,w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe";
    else cout << "safe";
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 13:24:45 2019

@author: Yamazaki Kenichi
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
a = ['{:040b}'.format(i) for i in A]
k = '{:040b}'.format(K)
ans = 0
b = 0
for i in range(40):
    counta = 0
    for j in range(N):
        counta += 1 if a[j][i] == '1' else 0
        check = 1 if counta<N/2 else 0
    
    if b == 1:
        ans += pow(2,39-i)*(N-counta) if check==1 else pow(2,39-i)*counta
    elif check==1 and k[i]=='0':
        ans += pow(2,39-i)*counta
    elif check==0 and k[i]=='1':
        ans += pow(2,39-i)*counta
        b=1
    else:
        ans += pow(2,39-i)*(N-counta) if check==1 else pow(2,39-i)*counta
print(ans)


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

int main() {

  int x, y, W, H, r;
  cin >> W >> H >> x >> y >> r;
  if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }

}



Measured memory_bytes: 3108