akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

signed main(){
  int n,q;cin>>n>>q;string s;cin>>s;
  vector<int> v(n,0);
  v[0] = 0;
  rep(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C')v[i+1]++;
  }
  repd(i,1,n+1)v[i] += v[i-1];
  rep(i,q){
    int l,r;cin>>l>>r;r--;
    cout << v[r] - v[l-1] << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;cin>>n>>m;
  vector<vector<int> > a(n+1);
  for(int i=0;i<m;i++)
  {
    int x;cin>>x;
    string t;cin>>t;
    if(t[0]=='W')
      a[x].push_back(0);
    else a[x].push_back(1);
  }
  int score = 0;
  int penalty= 0 ;
  for(int i=1;i<=n;i++)
  {
    int tpen = 0;
    for(auto it:a[i])
    {
      if(it==0) tpen++;
      else{
        score++;
        penalty+=tpen;
        break;
      }
    }
  }
  cout<<score<<" "<<penalty<<endl;
  return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void)
{
        int p,q,r,a,b,c;

        scanf("%d%d%d",&p,&q,&r);

        a=p+q;
        b=p+r;
        c=q+r;

        if(a<=b && a<=c) printf("%d\n",a);
        else if(a>=b && b<=c) printf("%d\n",b);
        else if(a>=c && b>=c) printf("%d\n",c);

        return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,N; cin >> H >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int K = accumulate(all(A),0);

    cout << ((K >= H) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>q;
	map<string, int>mapa;
	vector<string> A = {"AC", "WA", "TLE", "RE"};
	while(q--){
		string s;
		cin>>s;
		mapa[s] ++;
	}
	for(auto s: A){
		cout<<s<<" x "<<mapa[s]<<"\n";
	}
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int n,num = 0,num2[2] = {};
    string s;
    cin >> n >> s;
    
    for(int i = 0;i < n;i++){
        if(s[i] == 'E')num++;
    }
    
    int mn = n-1;
    for(int i = 0;i < n;i++){
        //mn = min(mn,(num2[1]+(num-num2[0])));
        if(s[i] == 'E')num2[0]++;
        else num2[1]++;
        int sum = num2[1]+(num - num2[0]);
        if(s[i] == 'W')sum--;
        mn = min(mn,sum);
    }
    
    cout << mn << endl;
    
}

Measured memory_bytes: 900
//
//  main.cpp
//  127_D_Integer_Cards
//
//  Created by tolemy on 2019/08/23.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <map>
#include <queue>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n, m = 0;
    cin >> n >> m;
    
    
    int *a = new int[n];
    
    for(int i = 0;i<n;i++)
    {
        cin >> a[i];
    }
    
    int *b = new int[m];
    int *c = new int[m];
    
    for(int i=0;i<m;i++)
    {
        cin >> b[i] >> c[i];
    }
    
    //格Aの出現回数をカウント
    map<int, int> acount;
    //int acount[1000000001] = {};
    
    //Aの要素（重複なし、昇順）
    priority_queue<int, vector<int>, greater<int>> aq;
    
    for(int i = 0;i<n;i++)
    {
        //初回のみキューに登録
        if(acount[a[i]]==0) aq.push(a[i]);
        
        acount[a[i]]++;
    }
    
    
    //小さい方から順番に書き換えていく
    for(int i=0;i<m;i++)
    {
        bool flg = true;
        while(b[i] > 0 && !aq.empty() && flg)
        {
            //最小値を更新
            int minA = aq.top();
            if(minA >= c[i])
            {
                flg = false;
                continue;
            }
                
            //最初の１回だけ追加
            if(acount[c[i]] == 0) aq.push(c[i]);
            
            //減らせるだけ減らす
            if(acount[minA] >= b[i])
            {
                acount[minA] -= b[i];
                acount[c[i]] += b[i];
                b[i] = 0;
            }
            else
            {
                b[i] -= acount[minA];
                acount[c[i]] += acount[minA];
                acount[minA] = 0;
            }
            
            //minAがなくなったらpop
            if(acount[minA] == 0) aq.pop();
        }
    }
    
    
    //キューに残っている値はカードに記載されているので、これを合計
    unsigned long sum = 0;
    while(!aq.empty())
    {
        int atop = aq.top();
        long count = acount[atop];
        sum += atop * count;
        aq.pop();
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 9336
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string N;
    cin >> N;
    int cnt = 0;
    rep(i, 4) {
        if(N.at(i) == '2') cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
double pi=3.1415926535897932;

struct point {
    double x,y,val;
    point() {}
    point(double x, double y, double val) : x(x), y(y), val(val) {};
    point(double x, double y) : x(x), y(y), val(0) {};
};
//xの昇順で同じときyの昇順
bool cmp(const point &a, const point &b)
{
  if(a.x == b.x) return a.y < b.y;
  else return a.x < b.x;
}
struct vec {
    double x ,y ;
    vec() {}
    vec(double x, double y) : x(x), y(y)  {};
    vec(point a, point b) : x(b.x-a.x), y(b.y-a.y)  {};
    double size(){return sqrt(x*x+y*y);};
};

//ベクトルabとベクトルbcにおけるbcに対して時計回りの角cba
double arg(vec a,vec b){
  if(a.x*b.y-a.y*b.x>0)return acos((-a.x*b.x-a.y*b.y)/(a.size()*b.size()))*(-180)/pi +360;
  else return acos((-a.x*b.x-a.y*b.y)/(a.size()*b.size()))*180/pi;
}
//線分abとcdの交差判定
bool judgeIentersected(point a,point b, point c,point d) {
  double ta = (c.x - d.x) * (a.y - c.y) + (c.y - d.y) * (c.x - a.x);
  double tb = (c.x - d.x) * (b.y - c.y) + (c.y - d.y) * (c.x - b.x);
  double tc = (a.x - b.x) * (c.y - a.y) + (a.y - b.y) * (a.x - c.x);
  double td = (a.x - b.x) * (d.y - a.y) + (a.y - b.y) * (a.x - d.x);
  return tc * td < 0 && ta * tb < 0;
  //return tc * td <= 0 && ta * tb <= 0; // 端点を含む場合
}
//凸包
vector<point> convex_hull(vector<point>& v){
  sort(v.begin(),v.end(),cmp);
  vector<point> res,res2;
  for(auto p:v){
    if(res.size()<2)res.push_back(p);
    else{
      while(arg(vec(res[res.size()-2],res[res.size()-1]),vec(res[res.size()-1],p))>180.00001&&res.size()>=2)res.pop_back();
      res.push_back(p);
    }
  }
  for(auto p:v){
    if(res2.size()<2)res2.push_back(p);
    else{
      while(arg(vec(res2[res2.size()-2],res2[res2.size()-1]),vec(res2[res2.size()-1],p))<179.99999&&res2.size()>=2)res2.pop_back();
      res2.push_back(p);
    }
  }
  rep(i,res2.size()-2){
    res.push_back(res2[res2.size()-i-2]);
  }
  return res;
}

int main()
{

ll n ;
cin >> n ;
vector<point> v,ans;
rep(i,n){
  double x , y ;
  cin >> x >> y ;
  v.push_back({x,y});
}
ans=convex_hull(v);
cout << ans.size() << endl;
//以下は下（同じなら左）の点から反時計回りに出力する処理
double mi=INF;
rep(i,ans.size()){
  mi=min(mi,ans[i].y);
}
ll num;
rep(i,ans.size()){
  if(ans[ans.size()-1-i].y==mi){num=i;break;}
}
if(mi==ans[0].y){
  cout << ans[0].x <<" " << ans[0].y << endl;
  rep(i,ans.size()-1)cout << ans[ans.size()-1-i].x <<" " << ans[ans.size()-1-i].y << endl;
  return 0;
}
for (ll i = num; i < ans.size(); i++)cout << ans[ans.size()-1-i].x <<" " << ans[ans.size()-1-i].y << endl;
rep(i,num)cout << ans[ans.size()-1-i].x <<" " << ans[ans.size()-1-i].y << endl;


return 0;
}



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

int main() {
	int n,m,k,tmp,ans=0;
	cin>>n>>m;
	vector<int> si(m+1,0);
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>tmp;
			si[tmp]++;
		}
	}
	for(int i=1;i<=m;i++){
		if(si[i]==n)
			ans++;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  rep(i, n) {
    if (s.at(i) == '1') {
      cout << '9';
    } else if (s.at(i) == '9') {
      cout << '1';
    } else {
      cout << s.at(i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long a;
    long long b;
    long long c;
    cin >> a >> b >> c;
    if(c - a - b < 0){
        cout << "No" << endl;
    }
    else{
        if(4 * a * b < (c - a - b) * (c - a - b)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

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

int main()
{	
	int a[100][100];
	int b[100];
	int c[100];
	int i, j;
	for (i = 0;i < 100;i++)
		for (j = 0;j < 100;j++)
			a[i][j] = 0;
	for (i = 0;i < 100;i++)
		b[i] = c[i] = 0;
	int n,m;
	cin >> n >> m;
	for (i = 0;i < n;i++)
		for (j = 0;j < m;j++)
			cin >> a[i][j];
	for (j = 0;j < m;j++)
		cin >> b[j];

	for (i = 0;i < n;i++) {
		for (j = 0;j < m;j++)
			c[i] += a[i][j]*b[j];
	}

	for (i = 0;i < n;i++)
		cout << c[i] << endl;

	return 0;
}


Measured memory_bytes: 3136
#include<cstdio>
#include<cstring>
using namespace std;
int a[256],b[256];
char s[200005],t[200005];
int main(){
	scanf("%s%s",s+1,t+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;++i) {
		if(!a[s[i]]) a[s[i]]=t[i];
		else if(a[s[i]]!=t[i]) {printf("No\n");return 0;}
		if(!b[t[i]]) b[t[i]]=s[i];
		else if(b[t[i]]!=s[i]) {printf("No\n");return 0;}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>'50000000'},'ruby',$0)
N,K,*A=`dd`.split.map &:to_i
H=Hash.new{|h,k|h[k]=[]}
(2..N).each{|i|H[A[i-1]]<<i}
$r=0
def f(i,c)
	h=(H[i].map{|e|f e,i}.max||0)+1
	(h=0;$r+=1)if h>=K&&c!=1
	h
end
f(1,1)
p $r+(A[0]==1?0:1)

Measured memory_bytes: 225308
// start fold
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pairint pair<int,int>
#define fi first
#define se second
#define iv il void
#define enter putchar('\n')
#define size(x) ((int)x.size())
#define mem0(x) memset(x,0,sizeof(x))
template<class T>il void in(T &x)
{
    x=0; short f=1; char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
    x*=f;
}
template<class T>il void out(T x,const char c='\n')
{
    static short st[30];
    short m=0;
    if(x<0) putchar('-'),x=-x;
    do st[++m]=x%10,x/=10; while(x);
    while(m) putchar(st[m--]|'0');
    putchar(c);
}
namespace i207M
{
// end fold
#define N 205
const int md=998244353;
int n;
struct Node
{
    int x,y;
    il void init()
    {
        in(x),in(y);
    }
    Node() {}
    Node(const int xx,const int yy)
    {
        x=xx,y=yy;
    }
    friend Node operator-(const Node &a,const Node &b)
    {
        return Node(a.x-b.x,a.y-b.y);
    }
} p[N];
bool line(const Node &a,const Node &b)
{
    return a.x*b.y-b.x*a.y==0;
}
bool del[N][N];
int bit[N];
signed main()
{
#ifdef M207
    freopen("in.in","r",stdin);
    // freopen("out.out","w",stdout);
#endif
    in(n);
    for(ri i=1; i<=n; ++i) p[i].init();
    int ans=0; bit[0]=1;
    for(ri i=1; i<=n; ++i) bit[i]=(bit[i-1]<<1)%md;
    for(ri i=1; i<=n; ++i)
    {
        static Node tmp[N];
        for(ri j=1; j<=n; ++j) tmp[j]=p[j]-p[i];
        for(ri j=i+1; j<=n; ++j)
            if(!del[i][j])
            {
                static int st[N]; int tp=0;
                for(ri k=1; k<=n; ++k)
                    if(line(tmp[j],tmp[k]))
                        st[++tp]=k;
                (ans+=bit[tp]-1-tp)%=md;
                // printf("M %d %d: %d\n",i,j,tp);
                for(ri k=1; k<=tp; ++k)
                    for(ri h=k+1; h<=tp; ++h)
                        del[st[k]][st[h]]=del[st[h]][st[k]]=1;
            }
    }
    ans=((bit[n]-1-n-ans)%md+md)%md;
    out(ans);
    return 0;
}
// start fold
}
signed main()
{
    i207M::main();
    return 0;
}
// end fold

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>;

const int MAXN = 100010;
vector<vector<int>> edge(MAXN * 2, vector<int>());
vector<int> visited(MAXN * 2);
ll cntx = 0;
ll cnty = 0;

void dfs(int n){
    if (visited[n]) return;
    visited[n] = 1;
    if (n / MAXN) cnty++;
    else cntx++;
    for(auto nv : edge[n]) {
        dfs(nv);
    }
}

int main(){
    int N; cin >> N;
    rep(i, N){
        int x, y; cin >> x >> y;
        x--;y--;
        edge[x].push_back(y+MAXN);
        edge[y+MAXN].push_back(x);
    }
    ll ans = 0;
    rep(i, MAXN*2){
        if(visited[i]) continue;
        // 連結成分の個数を数える
        cntx = cnty = 0;
        dfs(i);
        ans += cnty * cntx;
    }
    cout << ans - N << endl;
    return 0;
}


Measured memory_bytes: 13696
a=[int(input()) for i in range(5)]
m=a[0]%10
s=0
for i in range(1,5):
  if m > a[i]%10 and a[i]%10 != 0 or m == 0:
    m=a[i]%10
for i in range(5):
  if a[i]%10 == 0:
    s+=a[i]
  else:
    s+=a[i]-a[i]%10+10
if m != 0:
  s-=10-m
print(s)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long

string S;
int main(){
	cin >> S;
	/*
	if (S.find("hi") == string::npos){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	*/
	if ((int)S.length()%2 == 1) {
		cout << "No" << endl;
		exit(0);
	}
	int IsOK = 1;
	//cout << S[1] << endl;
	rep(i, (int)S.length()){
		if (i%2==0){
			if(S[i] != 'h') IsOK = 0;
		}
		else{
			if(S[i] != 'i') IsOK = 0;
		}
	}
	if (IsOK){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind{
    vector<int>p;
    UnionFind(int n){
        p.resize(n, -1);
    }
 
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (x < y) swap(x,y);
        p[x] = y;
    }
 
    int find(int x){
        if (p[x] == -1) return x;
        else return p[x] = find(p[x]);
    }
 
};

int main() {
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind Road(N);
    UnionFind Train(N);

    for (int i=0; i<K; i++){
        int pi, qi;
        cin >> pi >> qi;
        Road.unite(pi-1,qi-1);
    }

    for (int i=0; i<L; i++){
        int ri, si;
        cin >> ri >> si;
        Train.unite(ri-1, si-1);
    }
    map<pair<int,int>, int>mp;
    for (int i=0; i<N; i++){
        pair<int,int>pr;
        pr.first = Road.find(i);
        pr.second = Train.find(i);

        mp[pr]++;
    }

    for (int i=0; i<N; i++){
        pair<int, int>pr;
        pr.first = Road.find(i);
        pr.second = Train.find(i);

        cout << mp[pr] << endl;
    }

}

Measured memory_bytes: 13568
import java.util.Arrays;
import java.util.Scanner;

//Luigi's Tavern
public class Main{

	int augumentPath(int v, int t, int f, int[][] cap, boolean[] used){
		if(v==t)return f;
		used[v] = true;
		for(int i=0;i<cap[v].length;i++){
			if(cap[v][i]>0 && !used[i]){
				int d = augumentPath(i, t, Math.min(f, cap[v][i]), cap, used);
				if(d>0){
					cap[v][i] -= d;
					cap[i][v] += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int maxFlow(int s, int t, int[][] cap){
		int flow = 0;
		int n = cap.length;
		boolean[] used = new boolean[n];
		while(true){
			Arrays.fill(used, false);
			int f = augumentPath(s, t, Integer.MAX_VALUE, cap, used);
			if(f==0)return flow;
			flow += f;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int h = sc.nextInt(), w = sc.nextInt(), c = sc.nextInt(), m = sc.nextInt(), nw = sc.nextInt(), nc = sc.nextInt(), nm = sc.nextInt();
			if(h<0)break;
			int n = h+w+c+m, NW = n, NC = n+1, NM = n+2, N = n+3, S = 2*N, T = 2*N+1;
			int[][] cap = new int[2*N+2][2*N+2];
			for(int i=0;i<n;i++)cap[i+N][i] = 1;
			cap[NW+N][NW] = nw;
			cap[NC+N][NC] = nc;
			cap[NM+N][NM] = nm;
			for(int i=0;i<h;i++){
				cap[S][i+N] = 1; cap[i][NW+N] = 1;
			}
			for(int i=0;i<w;i++){
				int k = sc.nextInt();
				while(k--!=0){
					int id = sc.nextInt()-1;
					cap[id][h+i+N] = 1;
				}
				cap[h+i][NC+N] = 1;
			}
			for(int i=0;i<c;i++){
				int k = sc.nextInt();
				while(k--!=0){
					int id = sc.nextInt()-1+h;
					cap[id][i+h+w+N] = 1;
				}
				cap[h+w+i][NM+N] = 1;
			}
			for(int i=0;i<m;i++){
				int k = sc.nextInt();
				while(k--!=0){
					int id = sc.nextInt()-1+h+w;
					cap[id][i+h+w+c+N] = 1;
				}
				cap[i+h+w+c][T] = 1;
			}
			for(int i=0;i<c;i++)cap[NW][i+h+w+N] = 1;
			for(int i=0;i<m;i++)cap[NC][i+h+w+c+N] = 1;
			cap[NM][T] = nm;
			System.out.println(maxFlow(S, T, cap));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;
const ll mod = (ll)(1e9 + 7);
 
void solve() {
  ll a, b, c, k; cin >> a >> b >> c >> k;
  ll r = 0;
  r += min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  r -= min(c, k);
  cout << r << '\n';
}
 
int main() {
  fio();
  
  int T;
  T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, x[100010], i, l[100100], ans=1, left, right;
    pair<long long , long long> p[100100];
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i] >> l[i];
        p[i]=make_pair(x[i]-l[i], x[i]+l[i]);
    }
    ans=n;
    sort(p, p+n);
    left=p[0].first;right=p[0].second;
    for(i=1;i<n;i++){
       if(p[i].second<right){
        ans--;
        left=p[i].first;right=p[i].second;
       }
       else if(p[i].first<right){
            ans--;
       }
       else{
            left=p[i].first;right=p[i].second;
       }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>

int dir[][2] = {{1,0}, {-1,0}, {0,1}, {0,-1}};
char tank[] = {'>','<','v','^'};

char map[20][20],tx,ty,td;

int getdir(char c){
  switch(c) {
  case 'U': return 3;
  case 'D': return 2;
  case 'L': return 1;
  case 'R': return 0;
  }
}

int main(){
  int t;
  scanf("%d",&t);

  for(;t--;){
    int h,w;
    scanf("%d %d\n",&h,&w);

    for(int y=0; y<h; y++){
      for(int x=0; x<w; x++){
	map[x][y] = getchar();
	switch(map[x][y]){
	case '>': tx=x; ty=y; td=0; break;
	case '<': tx=x; ty=y; td=1; break;
	case 'v': tx=x; ty=y; td=2; break;
	case '^': tx=x; ty=y; td=3; break;
	}
      }
      getchar(); 
    }

    int n;
    scanf("%d\n",&n);

    for(;n--;){
      int x,y,op = getchar();
      if(op=='S'){
	int dx=dir[td][0],dy=dir[td][1];
	for(x=tx+dx,y=ty+dy;;x+=dx,y+=dy){
	  if(x<0 || x>=w || y<0 || y>=h)
	     break;
	  else
	    switch(map[x][y]){
	    case '.' : 
	    case '_' : break;
	    case '*' : map[x][y]='.';
	    case '#' : goto outer;
	    }
	}
      }else{
	td = getdir(op);
	x = tx+dir[td][0]; y = ty+dir[td][1];
	map[tx][ty] = '.';
	if(x>=0 && x<w && y>=0 && y<h && map[x][y]=='.'){
	  tx = x; ty = y;
	} 
	map[tx][ty] = tank[td];
      }
    outer: ;
    }

    for(int y=0; y<h; y++){
      for(int x=0; x<w; x++)
	putchar(map[x][y]);
      putchar('\n');
    }
    if(t!=0) putchar('\n');
  }
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){

  int w[11], k[11], n, m, t, sumw, sumk;
 



  for(n=1; n < 11 ; n++){//wåwÌ¾_ÌüÍ
  scanf("%d", &w[n]);
  }

  for(n=1; n < 11 ; n++){//kåwÌ¾_ÌüÍ
    scanf("%d", &k[n]);
  }


  //ÀÑÖ¦
  for(n=1; n<11 ; n++){
    for(m=n+1; m<11 ; m++){
      if(w[n]<w[m]){
      t=w[n];
      w[n]=w[m];
      w[m]=t; 
      }    
    }
  }
  for(n=1; n<11 ; n++){
    for(m=n+1; m<11 ; m++){
      if(k[n]<k[m]){
      t=k[n];
      k[n]=k[m];
      k[m]=t;   
      }
    }
  }


  sumw=w[1]+w[2]+w[3];
  sumk=k[1]+k[2]+k[3];

  printf("%d %d\n", sumw, sumk);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

int main()
{
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> red(A);
    vector<ll> green(B);
    priority_queue<ll> trans;
    for (ll i = 0; i < A; i++)
    {
        cin >> red[i];
    }
    for (ll i = 0; i < B; i++)
    {
        cin >> green[i];
    }
    for (ll i = 0; i < C; i++)
    {
        ll ti;
        cin >> ti;
        trans.push(ti);
    }
    sort(red.begin(), red.end(), greater<ll>());
    sort(green.begin(), green.end(), greater<ll>());

    multiset<ll> ate;
    for (ll i = 0; i < X; i++)
    {
        ate.insert(red[i]);
    }
    for (ll i = 0; i < Y; i++)
    {
        ate.insert(green[i]);
    }

    while (!trans.empty())
    {
        ll ti = trans.top();
        trans.pop();
        if (ti > *ate.begin()) {
            ate.erase(ate.find(*ate.begin()));
            ate.insert(ti);
        }
    }

    ll ans = 0;
    for (auto &&e : ate)
    {
        ans += e;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10996
//辺の長さは確定させたいなO(N^2)*残り２辺の座標はあるかなO(logN)…x座標が一致したらy座標で調べるとか
#include<iostream>
#include<stdlib.h>
using namespace std;

typedef pair<int,int> Pos;
int n;
Pos tou[3000];

int compare(const void *s1,const void *s2){
	int tx = ((Pos*)s1)->first - ((Pos*)s2)->first;
	int ty = ((Pos*)s1)->second - ((Pos*)s2)->second;
	return tx?tx:ty;
}
Pos setpos(Pos start,Pos end,int jpwd){
	Pos pos;
	int t;
	pos.first = end.first - start.first;
	pos.second = end.second - start.second;
	switch(jpwd){
	case 1:
		t = pos.first;
		pos.first = -pos.second;
		pos.second = t;
		break;
	case -1:
		t = pos.first;
		pos.first = pos.second;
		pos.second = -t;
		break;
	}
	pos.first += start.first;
	pos.second += start.second;
	return pos;
}
int pfind(Pos pos,int start,int last){
	int medi = (start+last)/2;
	if(tou[start] == tou[last] || last-start <= 0){
		return pos==tou[start]?1:0;
	}
	if(pos == tou[medi])
		return 1;
	//firstが大きな枠組みなのでfirstから同じか調べる。
	if(pos.first > tou[medi].first)
		return pfind(pos,medi+1,last);
	else if(pos.first < tou[medi].first)
		return pfind(pos,start,medi-1);
	else if(pos.second > tou[medi].second){
		return pfind(pos,medi+1,last);
	}
	else{
		return pfind(pos,start,medi-1);
	}
}
int main(){
	int i,j;
	int mcor = 0;
	int mmax[200] = {0};
	while(1){
		cin >> n;
		if(n == 0)
			break;
		for(i = 0;i < n;i++){
			cin >> tou[i].first >> tou[i].second;
		}
		qsort(tou,n,sizeof(tou[0]),compare);
		//探索開始
		Pos pos[4];
		int men;
		mmax[mcor] = 0;
		for(i = 0;i < n;i++){
			for(j = i+1;j < n;j++){
				pos[0] = setpos(tou[i],tou[j],1);
				pos[1] = setpos(tou[i],tou[j],-1);
				pos[2] = setpos(tou[j],tou[i],-1);
				pos[3] = setpos(tou[j],tou[i],1);
				if((pfind(pos[0],0,n-1) && pfind(pos[2],0,n-1))|| (pfind(pos[1],0,n-1) && pfind(pos[3],0,n-1))){
					men = (tou[i].first-tou[j].first)*(tou[i].first-tou[j].first);
					men += (tou[i].second-tou[j].second)*(tou[i].second-tou[j].second);
					if(mmax[mcor] < men)
						mmax[mcor] = men;
				}
			}
			//cout << pfind(tou[i],0,n-1) << endl;
		}
		mcor++;
	}
	for(i = 0;i < mcor;i++){
		cout << mmax[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main() {

	int N, K, d;
	int *P, C;

	cin >> N >> K;
	P = new int[N];
	int total = N;

	for (int j = 0; j < N; j++) {
		P[j] = 0;
	}

	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> C;
			P[C-1] = 1;
		}
	}

	for (int j = 0; j < N; j++) {
		total -= P[j];
	}

	cout << total;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
 #endif
int t=1;
	//cin>>t;
	while(t--)
	{
	ll n,a;
	cin>>n>>a;
      cout<<n*a;
	
	}
return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int INF=2E5;
typedef pair<int,int> Pair;
int N;
int C[510]={},S[510]={},F[510]={};

int Time(int t, int i){
    if(i==N-1){return t;
    }else if(t<=S[i]) return  Time(S[i]+C[i],i+1);
    else if (t%F[i]==0) return Time(t+C[i],i+1);
    else return Time(t+F[i]-t%F[i]+C[i],i+1);
}


int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i=0;i<N;i++){
        cout << Time(0,i) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;
    int q;
    bool flag = true;

    cin >> s >> q;

    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;

        if (t == 1)
        {
            flag = !flag;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1)
            {
                if (flag)
                {
                    s.insert(s.begin(), c);
                }
                else
                {
                    s.insert(s.end(), c);
                }
            }
            else
            {
                if (flag)
                {
                    s.insert(s.end(), c);
                }
                else
                {
                    s.insert(s.begin(), c);
                }
            }
        }
    }

    if (!flag)
    {
        reverse(s.begin(), s.end());
    }

    cout << s << endl;
}

Measured memory_bytes: 1028
N, M = map(int, input().split())
A = list(map(int, input().split()))

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (N+1)
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Measured memory_bytes: 14692
import * as fs from 'fs';

namespace Atcoder.abc109 {


    class ProgramB {

        inp: string = '';

        /**
         9
         basic
         c
         cpp
         php
         python
         nadesico
         ocaml
         lua
         assembly

         Yes
         */
        constructor(inp: string) {
            this.inp = inp;
        }

        main() {
            const inpArr: string[] = this.inp.split('\n');

            const n: number = parseInt(inpArr[0], 10);
            inpArr.shift();

            let flg = true;
            inpArr.reduce((prev: string, curr: string, idx: number, arr: string[]) => {
                if (prev[prev.length - 1] !== curr[0]) {
                    flg = false;
                }

                if (arr.filter((val: string) => {
                    return (val === curr);
                }).length >= 2) {
                    flg = false;
                }

                return curr;
            }, inpArr[0][0]);


            console.log(flg ? 'Yes' : 'No');
        }
    }

    const func = new ProgramB(fs.readFileSync('/dev/stdin', 'utf8').trim());
    func.main();
}


Measured memory_bytes: 11676
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint l, r;
    cin >> l >> r;
    if(r - l + 1 >= 673 || l == 0){
        cout << 0 << endl;
    }
    else {
        lint ans = 2018;
        for (lint i = l; i < r; ++i){
            for (lint j = i + 1; j <= r; ++j){
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys


def yakusu(i):

    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1

    return cnt


def main():
    N = int(sys.stdin.readline().rstrip())

    cnt = 0
    for i in range(1, N + 1):
        if yakusu(i) == 8 and i % 2 == 1:
            cnt += 1

    print(cnt)


main()


Measured memory_bytes: 9056
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979
 
using namespace std;
       
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
       
/* 
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
       
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
       
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
       
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
       
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
       
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    ld a, b, x;
    cin >> a >> b >> x;
    x /= a;
    if (x <= a*b/2.0)
    {
        x *= 2.0;
        x /= b;
        ld ang = atan(x / b);
        ang *= 180.0 / 3.14159265358979;
        cout << setprecision(12) << fixed << 90.0 - ang;
        return 0;
    }
    x *= 2;
    x /= a;
    x -= b;
    ld ang = atan(a / (b - x));
    ang *= 180.0 / 3.14159265358979;
    cout << setprecision(12) << fixed << 90.0 - ang;
    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b == 15){
        cout<<"+";
        return 0;
    }
    if(a*b == 15){
        cout<<"*";
        return 0;
    }
    cout<<"x";
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int sum = count(s.begin(), s.end(), 'o');
    int N = s.size();
    N = 15 - N;
    if (sum + N >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
// AOJ 2766: Hamming Distance
// 2017.10.8 bal4u@uu

#include <stdio.h>

char s[1002], t[1002];

int main()
{
	int n, d;
	char *p, *q;

	scanf("%d%s%d", &n, s, &d);
	if (d == 0) { puts(s); return 0; }
	p = s, q = t;
	while (*p && d > 0) {
		if (*p++ != '1') d--;
		*q++ = '1';
	}
	if (d == 0) { while (*p) *q++ = *p++; *q = 0; }
	else {
		*q-- = 0, p--;
		while (d > 0) {
			if (*q == '1' && *p == '1') d--, *q = '0';
			q--, p--;
		}
	}
	puts(t);
	return 0;
}

Measured memory_bytes: 1720
#include <cstdio>
#include <algorithm>

using ll = long long int;

constexpr int mod = 1000000007;

int n, k;

int A[100000];
/*
\sum_{S: |S| = K} max(S) - min(S)
*/

int fact[100001];
int ifact[100001];

int modpow(int x, int n){
  int r = 1;
  for(;n;n>>=1){
    if(n&1) r = (ll) r * x % mod;
    x = (ll) x * x % mod;
  }
  return r;
}

int binom(int n, int k){
  return (ll) fact[n] * ifact[n-k] % mod * ifact[k] % mod;
}

int main(){
  fact[0] = 1;
  for(int i = 1; i <= 100000; i++){
    fact[i] = (ll) i * fact[i-1] % mod;
  }
  ifact[100000] = modpow(fact[100000], mod-2);
  for(int i = 100000-1; i >= 0; i--){
    ifact[i] = (ll) (i+1) * ifact[i+1] % mod;
  }

  
  scanf("%d%d", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%d", A+i);
  }
  std::sort(A, A+n);

  long long int ans = 0;
  for(int i = 0; i < n; i++){
    if(i >= k-1) ans += (ll) (mod+A[i]) * binom(i, k-1) % mod;
    if(n-1-i >= k-1) ans += mod - (ll) (mod+A[i]) * binom(n-1-i, k-1) % mod;
  }

  printf("%d\n", (int) (ans % mod));

  return 0;
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
from itertools import accumulate
from collections import Counter
from math import factorial
def nCr(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))

def solve(N: int, M: int, A: "List[int]"):
    a = list(accumulate(A))
    a = [aa%M for aa in a]
    counter = Counter(a)
    answer = a.count(0)

    for value in counter.values():
        if value <= 1:
            continue
        else:
            answer += nCr(value,2)
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


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

#define mp make_pair
#define X first
#define Y second
#define FOE(x, a) for(auto x : a)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 2010;
const int MOD = 1e9 + 7;

int n, k, F[N][N], sF[N][N];

void add(int &x, int y){
    x += y;
    x -= (x >= MOD) * MOD;
}

int powMod(int n, int k){
    assert(n >= 0);
    if (k == 0)
        return 1;
    int res = powMod(n, k >> 1);
    res = (ll) res * res % MOD;
    if (k & 1)
        res = (ll) res * n % MOD;
    return res;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;

    F[0][0] = 1;
    sF[0][0] = 1;

    FOR(i, 1, n){
        FOD(j, i, 1){
            add(F[i][j], sF[i - 1][j]);
            add(F[i][j], F[i - 1][j - 1]);

            add(sF[i][j], sF[i][j + 1]);
            add(sF[i][j], F[i][j]);
        }
        sF[i][0] = sF[i][1];
    }

    cout << (ll) sF[n - 1][n - k] * powMod(2, max(0, n - k - 1)) % MOD;

    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  char c[N];
  
  int nR=0;
  int nW=0;
  for(int i=0;i<N;i++)
  {
    cin >> c[i];
    if(c[i]=='R'){      nR++;}else{      nW++;}
  }
  
//  cout << nR << "," << nW ;
  
  if(nR==N || nW==N){ cout << 0; return 0;}
  
  int count = 0;
  for(int i=0;i<nR;i++)
  {
    if(c[i]=='W')
    {
      count++;
    }
  }
  
  cout << count;
    
  return 0;
}

Measured memory_bytes: 3816
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int n, a, x[51], dp[51][3000][51];

int solve(int i, int sum ,int t){
  if(i == n){
        if(t == 0) return 0;
        if(sum == a*t) return 1;
        return 0;
    }
    if(dp[i][sum][t] != -1) return dp[i][sum][t];
    return  dp[i][sum][t] = solve(i+1, sum, t) + solve(i+1, sum+x[i], t+1);
}

 main() {
   // fr;fw;
    cin >> n >> a;
    REP(i,n) cin >> x[i];
    memset(dp,-1,sizeof dp);
    cout << solve(0,0,0);
    return 0;
}

Measured memory_bytes: 61184
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m;
	LL a[101010]={};
	cin>>n>>m;
	map<int,int> mp;
	FOR(i,1,n+1)cin>>a[i];
	LL c=0;
	mp[0]++;
	FOR(i,1,n+1){
		a[i]+=a[i-1];
		a[i]=a[i]%m;
		c+=mp[a[i]];
		mp[a[i]]++;
		//cerr<<i<<" "<<c<<" "<<mp[a[i]]<<endl;
	}




	cout<<c;
    return 0;
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            if(int.Parse(str[0]) + int.Parse(str[1]) + int.Parse(str[2]) >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }

        }
    }
}


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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int n,ans;

int main(){
	cin>>n;
	vector<pair<int,int>>v;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(!i){
			v.push_back({a,b});
		}
		else{
			bool ok=1;
			for(int j=0;j<sz(v);j++){
				if(v[j].first>b || v[j].second<a)continue;
				else{
					v[j].first=min(v[j].first,a);
					v[j].second=max(v[j].second,b);
				}
			}
			if(ok)v.push_back({a,b});
		}
	}
	for(auto i:v){
		ans+=i.second-i.first+1;
	}
	cout<<ans;
	
	
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
  int X,A,B,R;
  cin >> X;
  cin >> A;
  cin >> B;
  R = X - A;
  do {
    R -=B;
  } while(R >= B);
  cout << R << '\n';
  return 0;
}

Measured memory_bytes: 256
#D
N = int(input()) 
a = list(map(int,input().split()))
box = [0] * N 
result = []
for i in range(N-1, -1, -1):
    aisum = 0 
    for j in range(i, N, i+1):
        aisum += box[j] 
    if aisum%2  != a[i]%2: 
        box[i] = 1 
        result.append(i+1)
    else: 
        box[i] = 0 
print(len(result))
if len(result) != 0:
    print(' '.join(map(str, result)))

Measured memory_bytes: 19856
def main():
    n, m = map(int, input().split())
    h = [None]+list(map(int, input().split()))
    to = [0]*(n+1)
    for _ in range(m):
        a, b = map(int, input().split())
        to[a] = max(to[a], h[b])
        to[b] = max(to[b], h[a])
    ans = [1 for i in range(1, n+1) if h[i] > to[i]]
    print(len(ans))
            
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 89544