akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007


bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;

    return true;
}


ll max(ll a,ll b)
{
    if(a>b)
    {
        return a;
    }
    return b;
}

ll min(ll a,ll b)
{
    if(a<b)
    {
        return a;
    }
    return b;
}

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

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


ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = res * i;
    return res;
}

ll nCr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fastpow(ll base,ll exp)
{
    base%=mod;
    ll ans=1;
    while(exp)
    {
        if(exp&1) {ans*=base; ans%=mod;}
        exp/=2;
        base*=base;
        base%=mod;
    }
    return ans;
}

class DSU {
public:
    int n;
    vector<int> parent,size;

    DSU(int a) {
        n = a;
        parent.assign(n,0);
        size.assign(n,0);
        for(int i=0 ; i<n ; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }

    void makeSets(int k) {
        for(int i=0 ; i<n ; i++) {
            if(find(i) != i) {
                size[i] = 0;
            }
        }
    }

    int find(int a) {
        int root = a;
        while(root != parent[root]) {
            root = parent[root];
        }
        while(root != a) {
            int temp = parent[a];
            parent[a] = root;
            a = temp;
        }
        return root;
    }

    void unionSet(int a, int b) {
        int root_a = find(a);
        int root_b = find(b);
        if(root_a == root_b) return;
        if(size[a] < size[b]) {
            parent[root_a] = root_b;
            size[root_b] += size[root_a];
        }
        else {
            parent[root_b] = root_a;
            size[root_a] += size[root_b];
        }
    }
};




int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);



int n,m;
cin>>n>>m;
double a[n];
double s=0,ch;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    s+=a[i];
}

int k=0;
for(int i=0;i<n;i++)
{
    if((4*m*a[i])>=s)
    {
        k++;
    }
}

if(k>=m)
{
    cout<<"Yes";
} else{
    cout<<"No";
}




    return 0;
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;
#define INF 1e9+7

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N,M,L;
    cin >> N >> M >> L;
    int d[N][N];
    rep(i,0,N)rep(j,0,N){
        d[i][j] = INF;
        if(i == j) d[i][j] = 0;
    } 
    rep(i,0,M){
        int a,b,c;
        cin >> a >> b >> c;
        d[a-1][b-1] = c;
        d[b-1][a-1] = c;
    }
    int q; 
    cin >> q;
    int s[q]; int t[q]; //start,end
    rep(i,0,q) cin >> s[i] >> t[i];
    //最小パスをみつける;
    rep(i,0,N){
        rep(j,0,N){
            rep(k,0,N){
                d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
            }
        }
    }
    rep(i,0,N)rep(j,0,N){
        if(d[i][j] <= L) d[i][j] = 1;
        else d[i][j] = INF;
    }
    
    rep(i,0,N){
        rep(j,0,N){
            rep(k,0,N){
                d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
            }
        }
    }
    rep(i,0,q) cout << (d[s[i]-1][t[i]-1] != INF ? d[s[i]-1][t[i]-1]-1 : -1) << endl;
}


Measured memory_bytes: 1664
/**
 * ABC042 B
 * 
 * @date 2020.05.02
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

int main(int argc, char const *argv[])
{
  int n;
  int l;
  std::cin >> n;
  std::cin >> l;
  std::vector<std::string> dic = {};
  for (int i = 0; i < n; i++)
  {
    std::string in;
    std::cin >> in;
    dic.push_back(in);
  }
  std::sort(dic.begin(), dic.end());

  for (std::vector<std::string>::iterator item = dic.begin(); item != dic.end(); item++)
  {
    std::cout << *item;
  }
  std::cout << endl;

  return 0;
}

Measured memory_bytes: 888
local n=io.read("n")
local x,y={},{}
for i=1,n do
    x[i],y[i]=io.read("n","n")
end

local map={}
for i=1,n do
    for j=1,n do
        if i~=j then
            local p=tostring(x[i]-x[j])
            local q=tostring(y[i]-y[j])
            local s=p.." "..q
            map[s]=(map[s] or 0)+1
        end
    end
end

local mincost=n
for k,v in pairs(map) do
    mincost=math.min(mincost,n-v)
end
print(mincost)

Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int po[11],a[11];
void print(int x){
  for(int i=0;i<n;i++) cout<<x%11<<" ",x/=11;
  cout<<endl;
}
void sw(int &x,int i,int j){
  int s=(x%po[i+1])/po[i]*(po[j]-po[i]);
  int t=(x%po[j+1])/po[j]*(po[i]-po[j]);
  x+=s+t;
}
signed main(){
  po[0]=1;
  for(int i=0;i<10;i++) po[i+1]=po[i]*11;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  int p[2]={};
  for(int i=0;i<n;i++) p[0]=p[0]*11+a[i];
  for(int i=0;i<n;i++) p[1]=p[1]*11+(i+1);
  if(p[0]==p[1]){
    cout<<0<<endl;
    return 0;
  }
  //cout<<p<<endl<<ans<<endl;
  //print(p);print(ans);
  queue<int> q[2];
  unordered_map<int,int> m[2];
  int ans=n-1;
  for(int j=0;j<2;j++){
    q[j].push(p[j]);
    m[j][p[j]]=0;
    while(!q[j].empty()){
      int t=q[j].front();q[j].pop();
      int d=m[j][t];
      if(d>=(n-1)/2) break;
      //cout<<d<<":";print(p);
      for(int i=1;i<n-1;i++){
	int r=t;
	for(int k=1;i-k>=0&&i+k<n;k++){
	  sw(r,i-k,i+k);
	  if(!m[j].count(r)){
	    q[j].push(r);
	    m[j][r]=d+1;
	    if(j&&m[0].count(r))
	      ans=min(ans,m[0][r]+m[1][r]);
	  }
	}
      }
      for(int i=0;i<n-1;i++){
	int r=t;
	for(int k=0;i-k>=0&&i+1+k<n;k++){
	  sw(r,i-k,i+1+k);
	  if(!m[j].count(r)){
	    q[j].push(r);
	    m[j][r]=d+1;
	    if(j&&m[0].count(r))
	      ans=min(ans,m[0][r]+m[1][r]);
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 26496
#include <iostream>

int main(int argc, char *argv[]) {
  char c;
  int i = 1;
  bool ok = true;
  while (std::cin >> c) {
    if (i % 2 == 0) {
      if (c == 'R')
        ok = false;
    } else if (c == 'L')
      ok = false;
    ++i;
  }

  std::cout << (ok ? "Yes" : "No") << std::endl;
}


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

using namespace std;

const int MAXN = 2E5;
int pos[MAXN + 1];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        pos[x] = i;
    }
    int ans = n;
    int cur = 1;
    while (cur <= n)
    {
        int index = pos[cur++];
        int cnt = 1;
        while (cur <= n && pos[cur] > index)
        {
            index = pos[cur];
            cur++;
            cnt++;
        }
        ans = min(ans, n - cnt);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, Q;
    cin >> N >> Q;
    
    string S;
    cin >> S;
    
    vector<int> l(Q), r(Q);
    for (int i=0; i<Q; i++) {
        cin >> l[i] >> r[i];
    }
    
    //与えられた文字列の中のACを見つけ印をつけておき、それが含まれるか調べるといけるな
    //累積和にしとくか
    vector<int> sum(N+1);
    for (int i=0; i<N-1; i++) {
        sum[i+1] = sum[i] + (S[i] == 'A' && S[i+1] == 'C'); //ここ賢い
    }
    
    for (int i=0; i<Q; i++) {
        int left = l[i] - 1, right = r[i] - 1;
        cout << sum[right] - sum[left] << endl;
    }

}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool check(string n){
	for(int i=0;i<n.size();i++){
		if(n[i]!=n[n.size()-i-1])return false;
	}
	return true;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[s.size()-1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()/2-1-i]||s[(s.size()+1)/2+i]!=s[s.size()-1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll R,D,x2000;
  cin>>R>>D>>x2000;
  ll x=x2000;
  FORi(10){
    x=R*x-D;
    cout<<x<<endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, z, w;
  cin >> n >> z >> w;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  if(n > 1) cout << max(labs(a[n-1]-w), labs(a[n-2] - a[n-1])) << endl;
  else cout << labs(a[0]-w) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
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;}

ll mod;
vector<vector<int>> graph;
vector<ll> dp1;
vector<ll> dp2;

ll dfs1(int v,int pa){
  ll ans=1;
  for(int i=0;i<sz(graph.at(v));i++){
    int nv=graph.at(v).at(i);
    if(nv==pa)  continue;
    ans*=(dfs1(nv,v)+1);
    ans%=mod;
  }
  return dp1.at(v)=ans;
}

void dfs2(int v,int pa){
  if(pa==-1)  dp2.at(v)=1;
  int vsize=sz(graph.at(v));
  vector<ll> mul1(vsize+1,1);
  vector<ll> mul2(vsize+1,1);
  for(int i=0;i<vsize;i++){
    int nv=graph.at(v).at(i);
    if(nv==pa)  mul1.at(i+1)=mul1.at(i);
    else  mul1.at(i+1)=mul1.at(i)*(dp1.at(nv)+1)%mod;
  }
  for(int i=vsize-1;i>=0;i--){
    int nv=graph.at(v).at(i);
    if(nv==pa)  mul2.at(i)=mul2.at(i+1);
    else  mul2.at(i)=mul2.at(i+1)*(dp1.at(nv)+1)%mod;
  }
  for(int i=0;i<vsize;i++){
    int nv=graph.at(v).at(i);
    if(nv==pa)  continue;
    dp2.at(nv)=(dp2.at(v)*(mul1.at(i)*mul2.at(i+1)%mod)+1)%mod;
    dfs2(nv,v);
  }
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N >> mod;
  graph.resize(N);
  for(int i=0;i<N-1;i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    graph.at(x).pb(y);
    graph.at(y).pb(x);
  }

  dp1.assign(N,0);
  dfs1(0,-1);
  dp2.assign(N,0);
  dfs2(0,-1);
  for(int i=0;i<N;i++)  cout << dp1.at(i)*dp2.at(i)%mod << endl;

  return 0;
}

Measured memory_bytes: 22016
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 55, M = 25;
int lca[N][N], fa[N];

vector<int> edg[N];
vector<int> son[N];

void dfs(int u, int f) {
  fa[u] = f;
  son[u].push_back(u);
  for(int i = 0; i < int(edg[u].size()); i++) {
    if(edg[u][i] != f) {
      dfs(edg[u][i], u);
      for(auto &x: son[edg[u][i]]) {
        son[u].push_back(x);
      }
    }
  }
  const int sz = son[u].size();
  for(int i = 0; i < sz; i++) {
    for(int j = 0; j < sz; j++) {
      if(!lca[son[u][i]][son[u][j]]) {
        lca[son[u][i]][son[u][j]] = u;
      }
    }
  }
}

int num[N][N], qa[N], qb[N];
bool vis[N];


void Main() {
  int n; cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    edg[u].push_back(v);
    edg[v].push_back(u);
    num[u][v] = i;
    num[v][u] = i;
  }
  dfs(1, -1);
  int m; cin >> m;
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    qa[i] = u, qb[i] = v;
  }
  ll ans = 0;
  for(int i = 0; i < (1 << m); i++) {
    ll minus = 1;
    int cnt = n - 1;
    memset(vis, 0, sizeof(*vis) * n);
    for(int j = 0; j < m; j++) {      
      if((i >> j) & 1) {
        minus *= -1;
        int u = qa[j], v = qb[j];
        while(u != lca[qa[j]][qb[j]]) {
          if(!vis[num[u][fa[u]]]) {  
            vis[num[u][fa[u]]] = true;
            cnt--;
          }
          u = fa[u];
        }
        while(v != lca[qa[j]][qb[j]]) {
          if(!vis[num[v][fa[v]]]) {
            vis[num[v][fa[v]]] = true;
            cnt--;
          }
          v = fa[v];
        }
      }
    }
    ans += minus * (1ll << cnt);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k,m,i,j;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << "-1" << endl;
    return 0;
  }
  m=n*(n-1)/2-k;
  cout << m << endl;
  for(i=1;i<n;i++)
    for(j=i+1;j<=n&&m>0;j++,m--)
      cout << i << " " << j << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<tuple>
#include<map>
#define DB double
#define LL long long
#define PP std::pair<DB,DB>
#define MPP std::make_pair
#define TT std::tuple<int,int,int>
#define INF (100000000000000000)
int N, K;
int P[20010];
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		int tmp;
		std::cin >> tmp;
		P[tmp] = i;
	}
	for (int i = 1; i <= N; i++) {
		std::cout << 30000 * i;
		if (i != N)std::cout << " ";
	}
	std::cout << std::endl;
	for (int i = 1; i <= N; i++) {
		std::cout << 30000 * (N - i) + P[i];
		if (i != N)std::cout << " ";
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	LL arr[MaxN];
	int n;
	arr[0] = 0;
	for(int i = 1 ; i <= 100 ; i++)
		arr[i] = arr[ i - 1 ] + i;
	scanf("%d",&n);
	printf("%lld\n",arr[n]);
	return 0;
	}

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

int main(){
    vector<int> A(3);
    for(int i=0;i<3;i++){
        cin >>A.at(i);
    }
    sort(A.begin(),A.end());
    int ans=A.at(1)-A.at(0)+A.at(2)-A.at(1);
    cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    ll N, M;
    cin>>N>>M;
    vll A;
    ll sum=0;
    for(int i=0;i<M;i++){
        ll a;
        cin>>a;
        sum+=a;
    }

    if(sum>N)
        cout<<-1<<endl;
    else
        cout<<N-sum<<endl;

    return 0;
}


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

typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pb push_back
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

ll bekijo(ll n,ll m){
    if(m==1)return n;
    
    if(m%2==0)return (bekijo(n,m/2)) % 1000000007* (bekijo(n,m/2)) % 1000000007;
    else return  bekijo(n,m/2) % 1000000007* bekijo(n,m/2) % 1000000007*n % 1000000007;
}

int main() {
    ll n,m;
    cin>>n>>m;
    cout<<bekijo(n,m)<<endl;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  set<long> st;
  for (long a = 1; a <= 9; a++) for (long b = 1; b <= 9; b++) st.insert(a * b);
  if (st.count(N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()
    println(if ((a*b)%2 == 1) "Odd" else "Even")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;

double distance(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idistance(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
signed main() {
  int N, M;
  cin >> N >> M;
  int k;
  vector<vector<ll>> ks(M, vector<ll>(N, -1));
  vector<ll> ms(M);
  rep(i, M) {
    cin >> k;
    rep(j, k) {
      cin >> ks[i][j];
      ks[i][j]--;
    }
  }
  //cout << "-" << endl;
  rep(i, M) { cin >> ms[i]; }
  //cout << "F" << endl;
  int c = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> S(N);  //目的の集合
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        S[i] = 1;
      }
    }
    int f = 1;
    rep(i, M) {
      int tmp = 0;
      rep(j, N) {
        if (ks[i][j] != -1) {
          if (S[ks[i][j]] == 1) {
            tmp++;
          }
        }
      }
      if (tmp % 2 != ms[i]) {
        f = 0;
      }
    }
    if (f == 1) {
      c++;
    }
  }
  cout << c;
}


Measured memory_bytes: 3724
<?php
fscanf(STDIN, '%d', $x);
$amount = 100;
for($i = 1; $i < 1000000000000; $i++){
    $amount = (int) $amount * 1.01;
    if($x < $amount){
        print($i);
        break;
    }
}
$amount = 100*1.01;
?>

Measured memory_bytes: 16164
N, X = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

ans = 0
(ans += A[0]-X; A[0] = X) if X < A[0]
(1...N).each{|i|
  if A[i] + A[i-1] > X then
    ans += (A[i] + A[i-1] - X)
    A[i] = X - A[i-1]
  end
}

puts ans


Measured memory_bytes: 9612
if __name__ == '__main__':
    
    ans = 0
    while True:
        try:
            line = list(input())
            tmp = ""
            for i in line:
                if i.isdigit():
                    tmp += i
                else:
                    if len(tmp) >= 1:
                        ans += int(tmp)
                        tmp = ""
            if len(tmp) >= 1:
                ans += int(tmp)

        except EOFError:
            break

    print(ans)



Measured memory_bytes: 5592
/**
 *     author: qodjf
 *     created: 04.17.2020 12:42:11
 */
#include <bits/stdc++.h>
using namespace std;

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

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

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

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

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

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

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

  priority_queue<int> que(a.begin(), a.end());
  while (M) {
    int v = que.top();
    que.pop();
    M--;
    que.push(v / 2);
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}


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

int main(){
  string str;
  int a[3];
  int rect=0,hisi=0;
  while(cin>>str){
    stringstream ss(str);
    string buf;
    int i=0;
    while(getline(ss,buf,',')){
      a[i]= (buf[0]-'0');
      i++;
    }
    if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]) rect++;
    else if(a[0]==a[1]) hisi++;
  }

  cout << rect << endl << hisi << endl;

}

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

int main(){
  string s, ans="yes";
  char c='a';
  int i, count;
  cin >> s;
  
  for (i=0; i<='z'-'a'; i++) {
    count = std::count(s.begin(), s.end(), char('a'+i));
    if (count >= 2) {
      ans = "no";
      break;
    }
  }
  
  cout << ans << endl;
      
  return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n;
  cin >> n;

  cout << lcm(2, n) << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
ll c;
ll x[1000000],v[1000000];
ll a[1000000],amax[1000000];
ll b[1000000],bmax[1000000];
ll ans;

int main(){
  cin>>n>>c;

  rep(i,n){
    cin>>x[i]>>v[i];
  }

  rep(i,n){
    a[i] =v[i]-x[i];
    if(i!=0) a[i]+=a[i-1]+x[i-1];
  }
  rep(i,n){
    amax[i]=max((ll)0,a[i]);
    if(i!=0) amax[i]=max(amax[i],amax[i-1]);
    ans = max(ans,amax[i]);
  }

  for(int i=n-1;i>=0;i--){
    b[i] = v[i]-(c-x[i]);
    if(i!=n-1) b[i]+=b[i+1]+(c-x[i+1]);
  }

  for(int i=n-1;i>=0;i--){
    bmax[i]=max((ll)0,b[i]);
    if(i!=n-1) bmax[i]=max(bmax[i],bmax[i+1]);
    ans = max(ans,bmax[i]);
  }

  rep(i,n){
    ans=max(ans,a[i]-x[i]+bmax[i+1]);
  }
  for(int i=n-1;i>=0;i--){
    if(i!=0)ans=max(ans,b[i]-(c-x[i])+amax[i-1]);
 }

  cout<<ans<<endl;

  return 0;
}



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

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

int rec(vector<int> v) {
  int ret = v.size();

  if (v.size() == 0) return 0;

  
  for (int i=0; i<v.size(); i++) {
    int x = i%4;
    int y = i/4;
    for(int k=0; k<4; k++) {
      if (x+dx[k]>=0&&x+dx[k]<4&&y+dy[k]>=0&&y+dy[k]<5 && x+dx[k] + (y+dy[k]) * 4 < v.size() )
        if (v[i] == v[x+dx[k] + (y+dy[k]) * 4]) {
          vector<int> nv(v);
          nv.erase(nv.begin()+x+dx[k]+(y+dy[k])*4);
          nv.erase(nv.begin()+x+y*4);
          ret = min(ret, rec(nv));
          if (ret == 0) return 0;
        }
    }
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    vector<int> v;
    for (int i=0; i<20; i++) {
      int in;
      cin >> in;
      v.push_back(in);
    }
    cout << rec(v) << endl;
  }
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL N_,P;
LL odd=0,even=0;
LL counter=0;


int main(){
   cin>>N_>>P;
   //cout<<N<<" "<<P<<endl;
   REP(i,N_){
       int a;
       cin>>a;
       if(a%2==0){
           even++;
       }
       else{
           odd++;
       }
   }
   
   //すべて偶数の場合
   if(even==N_){
       if(P==0){
           counter=pow(2,even);
           cout<<counter<<endl;
           return 0;
       }
       else{
           counter=0;
           cout<<counter<<endl;
           return 0;
       }
   }
   //奇数が入ってきた場合
   //最後に選ぶのを奇数個入った袋だとすると
   //今の合計がきすうならこれを食べないし合計が偶数ならこれを食べればいい。
   counter=pow(2,N_-1);
   cout<<counter<<endl;

   
}

Measured memory_bytes: 256
A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

if "0" in list1:
    print("0")
    
else:
    for i in range(0,A):
        Ans=Ans*int(list1[i])    
        if Ans >10**18:
                print(-1)
                break
    if Ans <=10**18:    
        print(Ans)  
    

Measured memory_bytes: 19304
n=int(input())
lst=[[0 for i in range(10)]for j in range(10)]
cnt=0
for i in range(1,n+1):
  l,r=int(str(i)[0]),int(str(i)[-1])
  lst[l][r]+=1
for i in range(10):
  for j in range(10):
    cnt+=lst[i][j]*lst[j][i]
print(cnt)   

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define MP(x, y) make_pair(x, y)
#define Pair pair<int, int> 
//#define int long long 
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, M;
Pair P[MAXN];
main() {
	N = read(); M = read();
	for(int i = 0; i < M; i++) {
		int x = read(), y = read();
		P[i] = MP(y, x);
	}
	int ans = 0, last = -1;
	sort(P , P + M);
	for(int i = 0; i < M;) {
		int j = i + 1;
		while(j < M && P[i].first == P[j].first) j++;
		if(P[j - 1].second >= last) 
			ans++, last = P[j - 1].first;
		i = j;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 1)a = 14;
    if(b == 1)b = 14;
    if(a > b)cout << "Alice";
    else if(a < b) cout << "Bob";
    else cout << "Draw";
    return 0;
}


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

int main()
{
	int N, M;
	cin >> N;
	map<int, int> cnt;
	for (int i = 0, D; i < N; i++) {
		cin >> D;
		cnt[D] += 1;
	}
	cin >> M;
	bool ok = true;
	for (int i = 0, T; i < M; i++) {
		cin >> T;
		if (cnt.count(T) && cnt[T] > 0) {
			cnt[T]--;
		}
		else {
			ok = false;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 9600
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#define eps 1e-10
#define inf 1e9
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define y1 orz
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{if(c=='-')	f=-1;c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
int n,h,F[1001],deg[1001],hav[1001],is_father[1001];
inline int get(int x){return x==F[x]?F[x]:F[x]=get(F[x]);}
int x,y,x1,y1,tx,ty;
int main()
{
	n=read();h=read();
	For(i,1,1000)	F[i]=i;
	For(i,1,n)	
	{
		x=read();y=read();x1=read();y1=read();
		if(x1==0)	tx=x;else tx=-x1;
		if(y1==0)	ty=-y;else ty=y1;
		tx+=500;ty+=500;
		deg[tx]++;deg[ty]--;hav[tx]=1;
//		cout<<tx<<' '<<ty<<endl;
		F[get(tx)]=get(ty);
	}
	For(i,501,1000)	if(deg[i]<0)	{puts("NO");return 0;}		
	For(i,1,500)	if(deg[i]>0)	{puts("NO");return 0;}
	For(i,1,1000)	
		hav[get(i)]|=hav[i];
	For(i,1,1000)
		if(deg[i])is_father[get(i)]=1;
	For(i,1,1000)	
		if(hav[i])
			if(F[i]==i&&!is_father[i])	return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    String s = scanner.nextLine();
		    
		    s = s.replaceFirst("7","8");
		    System.out.println(s);
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21588
#  import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
import sys
import numpy as np


#  sys.setrecursionlimit(10**7)
#  inf = 10 ** 20
#  eps = 1.0 / 10**10
#  mod = 10**9+7
#  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#  ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    N = I()
    h = LI()
    h = np.array(h)
    #  print(N, h)
    # 0以上の塊をみつける
    # その塊に水をやる
    # 以上を繰り返す
    count = 0
    while True:
        #  print(h)
        first_non_zero_idx = [idx for idx, i in enumerate(h) if i != 0]
        if len(first_non_zero_idx) == 0:
            # 終了
            print(count)
            return
        else:
            first_non_zero_idx = first_non_zero_idx[0]

        first_zero_idx = [idx for idx, i in enumerate(h) if idx > first_non_zero_idx and i == 0]
        if len(first_zero_idx) == 0:
            # 0がないので最後まで水をやる
            first_zero_idx = len(h)
        else:
            first_zero_idx = first_zero_idx[0]

        # 水をやる
        min_value = min(h[first_non_zero_idx:first_zero_idx])
        h[first_non_zero_idx:first_zero_idx] -= min_value
        count += min_value





main()


Measured memory_bytes: 12468
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextLong());
        }
        List<Long> sum = new ArrayList<>();
        long total = 0;
        sum.add(total);
        for (Long it : a) {
            total += it;
            sum.add(total);
        }
        Map<Long, Long> map = new HashMap<>();
        for (Long it : sum) {
            long amari = it % m;
            if (map.containsKey(amari)) {
                map.put(amari, map.get(amari) + 1L);
                continue;
            }
            map.put(amari, 1L);
        }
        long ans = 0;
        for (Long key : map.keySet()) {
            long num = map.get(key);
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 65720
#include <bits/stdc++.h>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b;
}
void usaco() {
	freopen("problem.in", "r", stdin); 
	freopen("problem.out", "w", stdout);
}
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

const int MXN = 200005;
int n, k;
int arr[MXN];

bool works(int x) {
	int cuts = 0;
	for (int i=0; i<n; i++) {
		int h = arr[i] / x;
		if (arr[i] % x != 0) h++;
		h--;
		cuts += h;
	}
	// cout << x << ' ' << cuts << endl;
	return cuts <= k;
}

signed main() {

	ran(); fast();
	
	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> arr[i];
	
	int low = 1;
	int high = INT_MAX;
	
	while (low + 1 < high) {
		int mid = (low + high) / 2;
		if (works(mid)) {
			high = mid;
		}
		else {
			low = mid;
		}
	}
	
	if (works(low)) cout << low << endl;
	else cout << high << endl;

}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,s;
long long a[3005];
long long dp[3005][3005];
int main(){
	cin>>n>>s;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	dp[0][0]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<=s;++j){
			dp[i+1][j]+=2*dp[i][j];
			dp[i+1][j]%=mod;
			if(j+a[i]<=s){
				dp[i+1][j+a[i]]+=dp[i][j];
				dp[i+1][j+a[i]]%=mod;
			}
		}
	}
	cout<<dp[n][s]<<'\n';
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    long double a[n+10];
    long double cal=1.0,sum=0.0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        cal*=a[i];
    }
    for(int i=0; i<n; i++)
    {
        sum += (cal/a[i]);
    }

    cout<<cal/sum<<endl;
}


Measured memory_bytes: 256
/*******************­************\
 Name: MD ASHRAFUZZAMAN KHAN |
 School: COMILLA UNIVERSITY |
 CSE (5TH BATCH) |
 ********************­************/

#include <bits/stdc++.h>

#define ll long long int
#define inf 1<<30
#define Pi 2*acos(0,0)
#define pi acos(-1)
#define PI 3.1415926535897932384626433832795
#define mem(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sf scanf
#define MAX 50

///template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T ncr(T n,T r){return n*(n-1)/r;}

using namespace std;


int main()
{

   ios_base::sync_with_stdio(0);

    int n;
    cin>>n;
    int v[n],c[n];
    ll ans=0;
    for(int i= 0;i<n;i++)
    {
         cin>>v[i];
    }
    for(int i= 0;i<n;i++)
    {
          cin>>c[i];
          if(v[i]-c[i]>0)
             ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
   ///cin.get(); cin.get();
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
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);
// }
int main(){
  int N, M;
  cin >> N >> M;
  int sum = 0;
  for(int i=0; i<M; ++i){
    int A;
    cin >> A;
    sum += A;
  }
  if(N-sum>=0) cout << N-sum << endl;
  else cout << -1 << endl;
}

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

n = int(input())
C = [list(input().split()) for i in range(n)]

l = 2*10**5 + 5
# l = 100

# for jj in range(1000):
    # DD = ["U", "R", "D", "L"]
    # from random import randint
    # n = 10
    # l = 13
    # C = [[randint(0, 10) for j in range(2)] for i in range(n)]
    # C=[[10, 7, 'R'], [1, 9, 'U'], [9, 8, 'R'], [2, 5, 'U'], [4, 6, 'R'], [3, 9, 'U'], [10, 3, 'D'], [3, 6, 'L'], [6, 9, 'L'], [0, 8, 'U']]
    # C=[[2, 5, 'U'], [3, 6, 'L']]
    
    # for i in range(n):
    #     C[i].append(DD[randint(0,3)])
    # print(C)
    # co = 0
    # for i in range(n):
    #     for j in range(i+1,n):
    #         if C[i][:2] == C[j][:2]:
    #             co = 1
    # if co == 1:
    #     print("CONTINUE")
    #     continue

A = []
D = {"U": 0, "R": 1, "D": 2, "L": 3}
for i in range(n):
    A.append([int(C[i][0]), int(C[i][1]), D[C[i][2]]])

from bisect import bisect

ans = float("inf")
for ii in range(4):
    # print("ii",ii)
    # 正面衝突
    if ii <= 1:
        L = [[] for i in range(l)]
        R = [[] for i in range(l)]
        for i in range(n):
            if A[i][2] == 3:
                L[A[i][1]].append(A[i][0])
            if A[i][2] == 1:
                # print(A[i][0],A[i][1])
                R[A[i][1]].append(A[i][0])

        for i in range(l):
            R[i].sort()
            # print(L[i],R[i])
            for j in range(len(L[i])):
                ind = bisect(R[i], L[i][j])
                if ind > 0:
                    ans = min(ans, (L[i][j]-R[i][ind-1]) * 5)

    # 90度の衝突
    D = [[] for i in range(2*l)]
    L = [[] for i in range(2*l)]

    for i in range(n):
        if A[i][2] == 3:
            L[A[i][0] + A[i][1]].append(A[i][0])
        if A[i][2] == 2:
            D[A[i][0] + A[i][1]].append(A[i][0])
    for i in range(2*l):
        D[i].sort()
        for j in range(len(L[i])):
            ind = bisect(D[i], L[i][j])
            if ind > 0:
                ans = min(ans, (L[i][j]-D[i][ind-1]) * 10)
                # print("NEW", ans,L[i],D[i])

    for i in range(n):
        l2 = l // 2 - 1
        A[i][0], A[i][1] = (A[i][1]-l2) + l2, -(A[i][0]-l2) + l2
        A[i][2] = (A[i][2] + 1) % 4

if ans == float("inf"):
    ans = "SAFE"
print(ans)

    # eps = 10**-4
    # ans1 = float("inf")
    # for t in range(30):
    #     for i in range(n):
    #         if C[i][2] == "R":
    #             C[i][0] += 0.5
    #         elif C[i][2] == "L":
    #             C[i][0] -= 0.5
    #         elif C[i][2] == "D":
    #             C[i][1] -= 0.5
    #         else:
    #             C[i][1] += 0.5
    #     for i in range(n):
    #         for j in range(i+1, n):
    #             if abs(C[i][0] - C[j][0]) < eps and abs(C[i][1] - C[j][1]) < eps:
    #                 ans1 = (t+1)*5
    #                 print("CLASH",i,j, C[i][0],C[i][1])
    #     if ans1 != float("inf"):
    #         break
    # if ans1 == float("inf"):
    #     ans1 = "SAFE"

    # print(ans,ans1)
    # if ans != ans1:
    #     break

Measured memory_bytes: 322960
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
i = 1
while True:
    if d > x:
        print(i - 1)
        break
    if i == n + 1:
        print(i)
        break
    i += 1
    d += l[i-2]


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i<N;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 0;
  int pn = 1;
  
  for(int i = 0;i<N;i++){
    sum += pn*vec.at(i);
    pn *= -1;
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = ContestWriter.getInstance("out.txt", true);
	public static void main(String[] args) {
		while(solve());
		pw.flush();
	}

	public static boolean solve() {
		int n = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		if (w == 0) return false;
		ArrayList<Cake> cakes = new ArrayList<>();
		cakes.add(new Cake(h,w));
		for(int q=0;q<n;q++) {
			int p = sc.nextInt() - 1;
			int s = sc.nextInt();
			Cake c0 = cakes.get(p);
			s %= (c0.h * 2 + c0.w * 2);
			Cake c1,c2;
			if (s < c0.w) {
				int w1 = s;
				int w2 = c0.w - w1;
				c1 = new Cake(c0.h, w1);
				c2 = new Cake(c0.h, w2);
			} else if(s < c0.w + c0.h) {
				int h1 = s - c0.w;
				int h2 = c0.h - h1;
				c1 = new Cake(h1, c0.w);
				c2 = new Cake(h2, c0.w);
			} else if(s < c0.w * 2 + c0.h) {
				int w1 = s - c0.w - c0.h;
				int w2 = c0.w - w1;
				c1 = new Cake(c0.h, w1);
				c2 = new Cake(c0.h, w2);
			}else {
				int h1 = s - c0.w * 2 - c0.h;
				int h2 = c0.h - h1;
				c1 = new Cake(h1, c0.w);
				c2 = new Cake(h2, c0.w);
			}
			if (c1.w * c1.h > c2.w * c2.h) {
				Cake temp = c1;
				c1 = c2;
				c2 = temp;
			}
			cakes.add(c1);
			cakes.add(c2);
			cakes.remove(p);
//			System.out.println(cakes);
		}
		cakes.sort((c1,c2)->Integer.compare(c1.area(), c2.area()));
		for(int i=0;i<cakes.size();i++) {
			if (i > 0) {
				pw.print(' ');
			}
			pw.print(cakes.get(i).area());
		}
		pw.println();
		return true;
	}
}
class Cake {
	int h,w;
	
	public Cake(int h, int w) {
		this.h = h;
		this.w = w;
	}
	public int area() {return h*w;};
	public String toString() {
		return "(" + h + "," + w + ")";
	}
}
class ContestWriter extends PrintWriter {
	private ContestWriter(String fileName) throws IOException {
		super(new OutputStreamWriter(new FileOutputStream(new File(fileName)), "UTF-8"), false);
	}
	public static PrintWriter getInstance(String fileName, boolean debug) {
		if (debug) return new PrintWriter(System.out);
		try {
			return new ContestWriter(fileName);
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}
	public void println() {
		write('\n');
	}
}


Measured memory_bytes: 44400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int maxn = 2e5 + 5;
ii ans[maxn];
int res[maxn];

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

	string s;
	cin >> s;
	int n = (int) s.size();
	for(int i = 0; i < n; i++){
		if(s[i] == 'R'){
			int start = i;
			while(s[i] != 'L') i++;
			for(int x = start; x < i; x++)
				ans[x] = {i - x, i};
		}
	}
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == 'L'){
			int start = i;
			while(s[i] != 'R') i--;
			for(int x = start; x > i; x--)
				ans[x] = {abs(i - x), i};
		}
	}
	for(int i = 0; i < n; i++){
		int numMoves = ans[i].first;
		int stand = ans[i].second;
		if(s[i] == 'R'){
			if(numMoves % 2 == 0) res[stand]++;
			else res[stand - 1]++;
		}
		else{
			if(numMoves % 2 == 0) res[stand]++;
			else res[stand + 1]++;
		}
	}
	for(int i = 0; i < n; i++)
		cout << res[i] << " ";
}

Measured memory_bytes: 1872
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long 
struct r{
	int u,v,w;
}e[400050];
int w[400050],fa[200050],cnt,n,m;
ll ans;
int get_fa(int u){return fa[u]==u ? u:fa[u]=get_fa(fa[u]);}
bool cmp(r a,r b){return a.w<b.w;}
int main(){
	scanf("%d%d",&n,&m);
	memset(w,127,sizeof w);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
		w[e[i].u]=std::min(w[e[i].u],e[i].w+1);
		w[e[i].v]=std::min(w[e[i].v],e[i].w+2);
	}
	for (int i=0;i<n;i++) fa[i]=i;
	for (int i=1;i<(n<<1);i++)
		w[i]=std::min(w[i],w[i-1]+2);
	for (int i=0;i<n;i++)
		e[++m]=(r){i,(i+1)%n,std::min(w[i],w[i+n])};
	std::sort(e+1,e+m+1,cmp);
        int u,v;
	for (int i=1;i<=m;i++){
		if ((u=get_fa(e[i].u))==(v=get_fa(e[i].v))) continue;
		fa[v]=u;
		ans+=1ll*e[i].w;
		cnt++;
		if (cnt==n-1) {
			printf("%lld",ans);
			return 0;
		}
	}
} 


Measured memory_bytes: 7168
main(a,b,c,d,e,f){
	for(;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a|b|c|d|e|f;){
		a+=d,b+=e,c+=f,d=(a-1)/3,a-=d*3,e=(b-1)/3,b-=e*3,d+=e,f=(c-1)/3,c-=f*3,d+=f;
		e=0;if(a==3)e++;if(b==3)e++;if(c==3)e++;
		if(a>b)a=b;if(a>c)a=c;
		printf("%d\n",d+(a>e?a:e));
	}
}

Measured memory_bytes: 600
n=int(input())
ls=[list(map(int,input().split())) for i in range(n)]
ls.sort()

first_robot=ls.pop(0)
prev_right=first_robot[0]+first_robot[1]

for robot in ls:
    left=robot[0]-robot[1]
    right=robot[0]+robot[1]
    if left<prev_right:
        n-=1
        if right<prev_right:
            prev_right=right
    else:
        prev_right=right
print(n)


Measured memory_bytes: 61400
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S, T = input().split()

for i in range(N):
	print(S[i], T[i], sep="", end="")


Measured memory_bytes: 4016