akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

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

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

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e6;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

int main(){
    int N;
    cin >> N;
    mint A[N];
    rep(i, N) cin >> A[i].x;
    init();
    //sum[i]:=1/1+1/2+1/3+....+1/i
    mint sum[N+1];
    sum[0] = 0;
    rep2(i, 1, N) sum[i] = sum[i-1]+(mint)1/(mint)i;
    mint ans = 0;
    rep(i, N){
        ans += A[i]*fac[N]*(sum[i+1]+sum[N-i]-(mint)1);
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 9600
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		String ans="null";

		if(Math.abs(a-c)>d && Math.abs(b-a)<=d && Math.abs(c-b)<=d) ans="Yes";
		else if(Math.abs(a-c)<=d) ans="Yes";
		else ans="No";		

		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include <cstdio>

int ans[100];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) ans[i] = -1;
  for (int i = 1; i <= m; i++) {
    int s, c;
    scanf("%d%d", &s, &c);
    if (ans[s] != -1 && ans[s] != c) {
      puts("-1");
      return 0;
    }
    ans[s] = c;
  }
  if (n > 1 && ans[1] == 0) {
    puts("-1");
    return 0;
  }
  if (ans[1] == -1) {
    if (n > 1) ans[1] = 1;
    else ans[1] = 0;
  }
  printf("%d", ans[1]);
  for (int i = 2; i <= n; i++) {
    if (ans[i] == -1) ans[i] = 0;
    printf("%d", ans[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

using pll = pair<ll, ll>;
bool cmp(pll a, pll b) { return a.second < b.second; }  //比較関数

int n;
vector<pll> v;
int main() {
  cin >> n;
  v.resize(n);
  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end(), cmp);

  bool ok = true;
  ll sum = 0;
  rep(i, n) {
    sum += v[i].first;
    if (sum > v[i].second) ok = false;
  }
  cout << (ok ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define cout(v) REP(i,v.size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;

int main(){
  ll n,x,y; cin>>n>>x>>y;
  
  Graph G(n);
  REP(i,n-1){
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[x-1].push_back(y-1);
  G[y-1].push_back(x-1);
  
  vector<ll> ans(n,0);
  REP(i,n){
    vector<int> dist(n, -1);
    queue<int> que;
    
    dist[i] = 0;
    que.push(i);
    
    while (!que.empty()) {
      int v = que.front();
      que.pop();

      for (int nv : G[v]) {
        if (dist[nv] != -1) continue;

        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
    REP(i,n){
      ans[dist[i]]++;
    }
  }
  
  FOR(i,1,n) cout << ans[i]/2 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W; cin>>H>>W;
  queue<int>A;
  queue<int>B;
  int ans=0;
  vector<vector<char>>C(H+2,vector<char>(W+2,'#'));
  for(int i=1;i<=H;i++){
    string S;cin>>S;
    for(int j=1;j<=W;j++){C[i][j]=S.at(j-1);if(C[i][j]=='#'){ans++;}}
  }
  A.push(1);
  B.push(1);
  vector<vector<bool>>Z(H,vector<bool>(W,false));
  Z[0][0]=true;
  int count=1;
  for(int i=2;;i++){
    int z=count;
    count=0;
    for(int j=0;j<z;j++){
      if(C[A.front()+1][B.front()]=='.'&&!Z[A.front()][B.front()-1]){count++;Z[A.front()][B.front()-1]=true;A.push(A.front()+1);B.push(B.front());if(A.front()+1==H&&B.front()==W){cout<<H*W-ans-i<<endl;return 0;}}
      if(C[A.front()-1][B.front()]=='.'&&!Z[A.front()-2][B.front()-1]){count++;Z[A.front()-2][B.front()-1]=true;A.push(A.front()-1);B.push(B.front());if(A.front()-1==H&&B.front()==W){cout<<H*W-ans-i<<endl;return 0;}}
      if(C[A.front()][B.front()+1]=='.'&&!Z[A.front()-1][B.front()]){count++;Z[A.front()-1][B.front()]=true;A.push(A.front());B.push(B.front()+1);if(A.front()==H&&B.front()+1==W){cout<<H*W-ans-i<<endl;return 0;}}
      if(C[A.front()][B.front()-1]=='.'&&!Z[A.front()-1][B.front()-2]){count++;Z[A.front()-1][B.front()-2]=true;A.push(A.front());B.push(B.front()-1);if(A.front()==H&&B.front()-1==W){cout<<H*W-ans-i<<endl;return 0;}}
      A.pop();B.pop();
    }
    if(count==0){cout<<-1<<endl; return 0;}
  }
}

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


int main(){
    string s,t;
    int ans = 0;
    cin >> s >>t;
    int N = s.size();
    rep(i,N){
        if(s[i]!=t[i]) ans ++;
    }
    cout<<ans<<endl;
}

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

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int sum=0;
    int ans=0;
    for(int i=0;sum+i*r<=n;i++){
        sum+=i*r;
        for(int j=0;sum+j*g<=n;j++){
            if((n-sum-j*g)%b==0)ans++;
        }
        sum=0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;


const char T1[10] = {
    'w', ' ', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r'
};
const char T2[5] = {
    'T','L', 'U', 'R', 'D'
};
const char T3[5] = {
    'a', 'i', 'u', 'e', 'o'
};
string s;

bool input() {
    return cin >> s;
}

int get_index( char c ) {
    for ( int i = 0; i < 5; ++ i ) {
        if ( c == T2[i] ) return i;
    }
    return 0;
}

string solve() {
    string res = "";
    int n = s.size();
    for ( int i = 0; i < n; i += 2 ) {
        int ind1 = s[i] - '0';
        int ind2 = get_index( s[i+1] );
        if ( ind1 == 0 && ind2 == 2 ) {
            res += "nn";
        } else if ( ind1 != 1 ) {
            res += T1[ind1];
            res += T3[ind2];
        } else {
            res += T3[ind2];
        }
    }
    return res;
}

int main() {
    while ( input() ) {
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

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

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


int main(){
	ll H;
	cin >> H;

	ll L = 1 << (H - 1);

	vvmint w(L, vmint(H, 0));
	rep(i, L) {
		ll c = i + L;
		w[i][0] = c;
		repn(j, H - 1) {
			c /= 2;
			w[i][j] = w[i][j - 1] * c;
			//cout << i << j << w[i][j] << endl;
		}
	}

	vll p(L);
	rep(i, L) {
		cin >> p[i];
		p[i]--;
	}
	mint ans = 0;

	repn(i, H - 1)repn(j, H - 1) {
		mint now = 0;

		vmint val(1 << (H - j), 0);
		vll prev(1 << (H - j), -1);

		rep(k, L) {
			ll t = p[k] >> (j-1);

			if ((k >> (i - 1)) & 1) {
				ll u = t ^ 1;
				if (prev[u] != -1 && (prev[u] >> i) == (k >> i)) {
					now += val[u] * w[k][i - 1] * w[p[k]][j - 1];
				}
			}
			else {
				if (prev[t] != -1 && (prev[t] >> i) == (k >> i)) {
					val[t] += w[k][i] * w[p[k]][j];
				}
				else { val[t] = w[k][i] * w[p[k]][j]; }

				prev[t] = k;
			}
		}
		//cout << now << endl;

		ans += now;
	}

	cout << ans << endl;
}



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

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, 0, h) cin >> s[i];

  vector<vector<int>> l(h, vector<int>(w)), r(h, vector<int>(w)),
      u(h, vector<int>(w)), d(h, vector<int>(w));

  rep(i, 0, h) {
    rep(j, 0, w) {
      if (s[i][j] == '.') {
        int add = 1;
        if (j == 0) add = 0;
        l[i][j] = l[i][j - add] + 1;
      }
    }
    repr(j, 0, w) {
      if (s[i][j] == '.') {
        int add = 1;
        if (j == w - 1) add = 0;
        r[i][j] = r[i][j + add] + 1;
      }
    }
  }

  rep(i, 0, w) {
    rep(j, 0, h) {
      if (s[j][i] == '.') {
        int add = 1;
        if (j == 0) add = 0;
        u[j][i] = u[j - add][i] + 1;
      }
    }
    repr(j, 0, h) {
      if (s[j][i] == '.') {
        int add = 1;
        if (j == h - 1) add = 0;
        d[j][i] = d[j + add][i] + 1;
      }
    }
  }

  int ans = 0;
  rep(i, 0, h) {
    rep(j, 0, w) {
      int sum_val = 0;
      sum_val = l[i][j] + r[i][j] + u[i][j] + d[i][j];
      ans = max(ans, sum_val);
    }
  }

  cout << ans - 3 << endl;
}


Measured memory_bytes: 67328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a == 0 || b == 0) {
		cout << "Zero" << endl;
		return 0;
	}
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
		return 0;
	}
	if (a < 0 && b > 0) {
		cout << "Zero" << endl;
		return 0;
	}
	int res = b - a + 1;
	if (res % 2 == 0) cout << "Positive" << endl;
	else cout << "Negative" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int dp[11][2001];
int main(){
    vector<int> t[11];
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int r,type;
        cin >> r >> type;
        t[type].PB(r);
    }
    for(int i=1;i<=10;i++){
        sort(t[i].begin(),t[i].end(),greater<int>());
        for(int j=1;j<t[i].size();j++){
            t[i][j]+=t[i][j-1];
        }
        for(int j=1;j<t[i].size();j++){
            t[i][j]+=j*(j+1);
        }
    }
    REP(i,11)REP(j,2001)dp[i][j]=-INF;
    dp[0][0]=0;
    int ans=0;
    for(int i=1;i<=10;i++){
        dp[i][0]=0;
        for(int j=1;j<=k;j++){
            dp[i][j]=dp[i-1][j];
            for(int l=1;l<=j&&l<=t[i].size();l++){
                dp[i][j]=max(dp[i][j],dp[i-1][j-l]+t[i][l-1]);
            }
        }
    }
    cout << dp[10][k] << endl;
}

Measured memory_bytes: 1320
#include<stdio.h>
int main()
{
	int i,x,n,a,b,k,sum,sum1;
    scanf("%d%d",&n,&k);
    sum=1;
    for(i=1;i<=n;i++){
    	sum*=2;
	}
    for(i=1;i<=n;i++){
    	a=1;
    	for(x=1;x<=n-i;x++){
    		a=a*2;
		}
		for(x=i;x>0;x--){
			a+=k;
		}
		sum1=a;
    	if(sum>sum1){
    		b=sum;
    		sum=sum1;
    		sum1=b;
		}
	}
	printf("%d",sum);
}

Measured memory_bytes: 128
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto h = lread();
    func(h).writeln();

}

long func(long h)
{
    if (h == 1)
    {
        return 1;
    }
    return func(h / 2) * 2 + 1;//2体に分裂する+1,h/2を2体倒す(h/2)*2
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


string solve(){
  int N;
  cin >> N;

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i];

  int sum = 0;
  REP(i, N) sum += A[i];

  int k = sum/(N*(N+1)/2);
  if(sum%(N*(N+1)/2) != 0) return "NO";

  REP(i, N) B[i] = A[(i+1)%N]-A[i]-k;

  int cnt = 0;
  REP(i, N){
    if((-B[i])%N != 0 || B[i] > 0) return "NO";
    cnt += (-B[i])/N;
  }

  return (cnt == k)? "YES": "NO";
}


signed main() {
  cout << solve() << "\n";

  return 0;
}

Measured memory_bytes: 1792
/*input
5
0 0
0 1
1 0
2 2
3 1
*/
// clean code
#include <bits/stdc++.h>
#define pr pair<int,int>
#define val(u,t) (u + (t == 0 ? 0 : N))
using namespace std;
const int N = 1e5 + 5;
int n;
bool ok[2*N];
pr point[N];
vector<int> Gx[N], Gy[N];
void dfs(int u, int& xPoint, int& yPoint,bool t){
	if (!t){
		for (auto y : Gx[u]){
			if (!ok[val(y, 1)]){
				ok[val(y,1)] = 1;
				dfs(y, xPoint, ++yPoint,1);
			}
		}
	}
	else{
		for (auto x : Gy[u]){
			if (!ok[val(x, 0)]){
				ok[val(x,0)] = 1;
				dfs(x, ++xPoint, yPoint,0);
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;++i){
		int x,y; cin >> x >> y;
		point[i] = {x, y};
		Gx[x].push_back(y);
		Gy[y].push_back(x);
	}
	long long ans = 0;
	for (int i=1;i<=n;++i){
		if (!ok[val(point[i].first,0)]) {
			#define x point[i].first
			#define y point[i].second
			int xPoint = 1, yPoint = 0;
			ok[val(x, 0)] = 1;
			dfs(x,xPoint, yPoint, 0);
			// cout << xPoint << ' ' << yPoint << ' ' << cnt << '\n';
			ans += 1LL * xPoint * yPoint;
		}
	}
	cout << ans - n;
}

Measured memory_bytes: 16940
#include<stdio.h>
int main()
{
    int number_of_inputs, full_gram, min=100000, i;
    scanf("%d %d", &number_of_inputs, &full_gram);
    int doughnut_gram[number_of_inputs], sum_of_doughnut_gram=0;
    for(i=0; i<number_of_inputs; i++)
    {
        scanf("%d", &doughnut_gram[i]);
        sum_of_doughnut_gram=sum_of_doughnut_gram+doughnut_gram[i];
        if(doughnut_gram[i]<min)
        {
            min=doughnut_gram[i];
        }
    }

    printf("%d\n", number_of_inputs+(full_gram-sum_of_doughnut_gram)/min);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const double EPS = 1e-9;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

ll a, b, c, d, e, f;
double con;
ll ans1;
ll ans2;
void update(ll p, ll q, ll r, ll s){
    ll w = 100*(a*p+b*q);
    ll su = c*r+d*s;
    if(w > 0 && 100.*su/w < e+EPS && w+su <= f && con-EPS < 100.*su/(w+su)){
        ans1 = w+su;
        ans2 = su;
        con = 100.*su/(w+su);
        dump(100*a*p, 100*b*q, r, s, con);
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> a >> b >> c >> d >> e >> f;
    rep(i, 30)rep(j, 30)rep(k, (f+e-1)/e+1)rep(l, (f+d-1)/d+1){
        if(100*(a*i+b*j)+c*k+d*l > f){
            break;
        }
        update(i, j, k, l);
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, m[MAX][MAX];

void dijkstra(void);

int main()
{
  int i, j, k, c, u, v;

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    for(j=0; j<n; j++) {
      m[i][j] = INFTY;
    }
  }

  for(i=0; i<n;i++) {
    scanf("%d %d", &u, &k);
    for(j=0; j<k; j++) {
      scanf("%d %d", &v, &c);
      m[u][v] = c;
    }
  }
  dijkstra();

  return 0;
}

void dijkstra()
{
  int i, minv, u, v;
  int d[MAX], color[MAX];

  for(i=0; i<n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1) {
    minv = INFTY;
    u = -1;
    for(i=0; i<n; i++) {
      if(minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if(u == -1)
      break;
    color[u] = BLACK;
    for(v=0; v<n; v++) {
      if(color[v] != BLACK && m[u][v] != INFTY) {
        if(d[v] > d[u]+m[u][v]) {
          d[v] = d[u] + m[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0; i<n; i++) {
    printf("%d ", i);
    if(d[i] == INFTY)
      printf("-1\n");
    else
      printf("%d\n", d[i]);
  }
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const LL mod=1000000007;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
	LL N, K;
	cin >> N >> K;
	LL d[100010]={0};
	for(int i=2; i<=K; i++) d[i]=K/i;
	LL ans=0;
	LL num[100010]={0};
	for(int i=K; i>=2; i--){
		LL res=modpow(d[i],N);
		int j=2;
		while(i*j<=K){
			res-=num[i*j];
			j++;
		}
		while(res<0) res+=mod;
		num[i]=res;
		ans+=res*i%mod;
	}
	LL sum=0;
	for(int i=2; i<=K; i++){
		sum+=num[i];
		sum%=mod;
	}
	LL r=modpow(K,N)-sum;
	while(r<0) r+=mod;
	cout << (ans+r)%mod << endl;

	return 0;
}


Measured memory_bytes: 5188
#include<iostream>
using namespace std;
int main (void)
{
  int a,b,i;
 
  cin>>a>>b;
 if(a<b){for(i=0;i<b;i++){cout<<a;}return 0;}
 else{for(i=0;i<a;i++){cout<<b;}return 0;}

}

Measured memory_bytes: 3544
#include <stdio.h>
int main(void){
    int r,g,b,s;
    scanf("%1d %1d %1d",&r,&g,&b);
    s = r*100 + g*10 + b;
    if(s%4 == 0){
        printf("YES");
    }else{
        printf("NO");
    }
}

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

int main(){
	long long int q,h,s,d; cin >> q >> h >> s >> d;
	long long n; cin >> n;
	long long qq = min(q*8, min(h*4, min(s*2,d)));
	cout << (n/2) * qq  + (n%2)*(min(4*q, min(2*h,s))) << endl;	
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 2);
	a[0] = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	a[n + 1] = 0;
	int sum = 0;
	for (int i = 1; i <= n + 1; i++)
		sum += abs(a[i] - a[i - 1]);
	for (int i = 1; i <= n; i++)
		cout << sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << endl;
	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;

class Main {

    static int min(int a, int b) {
        return Math.min(a, b);
    }

    static int abs(int a) {
        return Math.abs(a);
    }

    static int get(String s)
    {
        return Integer.parseInt(s);
    }
    static int max(int a,int b)
    {
        return Integer.max(a, b);
    }
    static int max(int a,int b,int c)
    {
        return Math.max(a, Math.max(b, c));
    }
    public static void main(String[] args) throws Exception 
    
    {
        PrintWriter p = new PrintWriter(System.out);
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(bf.readLine());
        int[] a = new int[n],b = new int[n], c= new int[n];
    
        for (int i = 0; i < n; i++) {
            String[] temp = bf.readLine().split(" ");
            a[i] = get(temp[0]);
            b[i] = get(temp[1]);
            c[i] = get(temp[2]);

        }
        int dp[][] = new int[n][3]; //n rows and 3 cols

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                if(i == 0) { //first day
                    if(j == 0 ) dp[i][j] =a[i];
                    else if(j ==1) dp[i][j] = b[i];
                    else if(j ==2 ) dp[i][j] = c[i];
                }else{
                    for (int k = 0; k < 3; k++) {
                        if(j == k) continue; // if previous day activity and present day activity is the same
                        if( j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i]);
                        else if( j == 1) dp[i][j] = max(dp[i][j], dp[i-1][k]+b[i]);
                        else if (j == 2)
                            dp[i][j] = max(dp[i][j], dp[i - 1][k] + c[i]);

                    }
         
                }
            }
        }
 
        int ret = max(dp[n-1][0], dp[n-1][1], dp[n-1][2]);
 
        p.println(ret);
        p.flush();
    }
}

Measured memory_bytes: 46120
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
lisA = list(map(int,input().split()))
lisA.sort()
ans = lisA[0]*lisA[1]//2
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

using namespace std;

int n,m,x,satu,dua,empat,i,j;
char s[107][107];
priority_queue<int> pq;
int a[257];

int main() {
	scanf("%d%d",&n,&m);
	for (i=0 ; i<n ; i++) {
		scanf("%s",&s[i]);
		for (j=0 ; j<m ; j++) {
			a[s[i][j]-'a']++;
		}
	}
	
	for (i=0 ; i<26 ; i++) {
		pq.push(a[i]);
	}
	
	if (n % 2 == 1 && m % 2 == 1) {
		satu = 1;
		dua = (n-1)/2 + (m-1)/2;
		empat = (n*m - satu - 2*dua) / 4;
	} else if (n % 2 == 0 && m % 2 == 0) {
		empat = (n*m)/4;
	} else if (n % 2 == 1) {
		dua = m/2;
		empat = (n*m - satu - 2*dua) / 4;
	} else {
		dua = n/2;
		empat = (n*m - satu - 2*dua) / 4;
	}
	
	while (empat > 0) {
		x = pq.top();
		pq.pop();
		if (x >= 4) {
			x -= 4;
			pq.push(x);
		} else {
			printf("No\n");
			return 0;
		}
		empat--;
	}
	
	while (dua > 0) {
		x = pq.top();
		pq.pop();
		if (x >= 2) {
			x -= 2;
			pq.push(x);
		} else {
			printf("No\n");
			return 0;
		}
		dua--;
	}
	
	while (satu > 0) {
		x = pq.top();
		pq.pop();
		if (x >= 1) {
			x -= 1;
			pq.push(x);
		} else {
			printf("No\n");
			return 0;
		}
		satu--;
	}
	
	x = pq.top();
	assert(x == 0);
	printf("Yes\n");
}


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++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  pair<string, ll> a;
  ll n, k;
  k = 0;
  char f;
  string s;
  in(n);
  a.first = "a";
  a.second = 1;
  vector<pair<string, ll>> c;
  c.pb(a);
  while(true){
    rep(i, c.size()){
      f = 'a';
      k = 1;
      rep(j, c[i].second + 1){
        s = f;
        a.first = c[i].first + s;
        a.second = max(k, c[i].second);
        c.pb(a);
        f++;
        k++;
        if(a.first.size() >= 12){
          k = 100;
          break;
        }
      }
      if(k == 100)
        break;
    }
    if(k == 100)
      break;
  }
  rep(i, c.size()){
    if(c[i].first.size() == n){
      out(c[i].first);
      memi;
    }
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n >> k >> q;
    vl score(n + 10);
    NREP() {
        score[i] = k - q;
    }

    REP(i, 0, q) {
        cin >> tmp;
        score[tmp - 1]++;
    }

    REP(i, 0, n) {
        Yn(score[i] > 0)
    }
}


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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

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

	int n; cin >> n;

	LL ans = 1;
	for (int i = 0; i < 3; ++i)
		ans *= n;

	cout << ans << '\n';


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#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 = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b;
  cin >> a >> b;
  int ans=max({a+b,a-b,a*b});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
ans = 0
max_diff = 0
total_diff = 0

for _ in range(5):
    time = int(input())
    diff = 10-time%10
    diff = 0 if diff==10 else diff 
    total_diff += diff
    max_diff = max(max_diff,diff)
    ans += time
ans += total_diff-max_diff

print(ans)


Measured memory_bytes: 2940
while n = gets.to_i
  break if n == 0
  team = Array.new
  univ = Array.new(1001, 0)
  sum = 0
  n.times do
    i, u, a, p = gets.split.map(&:to_i)
    team << [10-a,p,i,u]
  end
  team.sort!
  team.each do |item|
    u = item[3]
    if (sum < 10 && univ[u] < 3) || (sum < 20 && univ[u] < 2) ||
       (sum < 26 && univ[u] < 1)
      p item[2]
      univ[u] += 1
      sum += 1
    end
  end
end

Measured memory_bytes: 8796
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        ll tmp = -inf;
        for (ll i = 1; i*i <= N; ++i) {
                if (N % i == 0) tmp = i;
        }
        ll A = tmp;
        ll B = N / tmp;
        ll ans = max(len(to_string(A)), len(to_string(B)));
        cout << ans << endl;
}

Measured memory_bytes: 256
s = list(map(int,list(input())))

n = len(s)
anses = [[], []]
for i in range(n):
  anses[0].append(i % 2)
  anses[1].append((i + 1) % 2)

draw = [0, 0]
for i in range(n):
  if s[i] != anses[0][i]:
    draw[0] += 1
  if s[i] != anses[1][i]:
    draw[1] += 1

print(min(draw))


Measured memory_bytes: 6556
import java.util.*;
import java.util.Collections;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double M = sc.nextDouble();
    Double[] A = new Double[N];
    double sum = 0;
    String ret = "Yes";
    for(int i = 0; i < A.length; i++){
      A[i] = sc.nextDouble();
      sum += A[i];
    }
    Arrays.sort(A, Collections.reverseOrder());
    for(int i = 0; i < M; i++){
      if(A[i] < sum / (4 * M)){
        ret = "No";
        break;
      }
    }
    System.out.println(ret);
  }
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    ll n, r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }
    else{
        ll rate = r + 100* (10 - n);
        cout << rate << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
	int h,w,k;cin>>h>>w>>k;
	int p[]={1,1,2,3,5,8,13,21};
	mint dp[101][9];
	dp[0][1]=1;
	for(int i=2;i<=8;i++) dp[0][i]=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			dp[i][j]=dp[i-1][j]*p[j-1]*p[w-j];
			if(j>=2) dp[i][j]+=dp[i-1][j-1]*p[j-2]*p[w-j];
			if(j<=w-1) dp[i][j]+=dp[i-1][j+1]*p[j-1]*p[w-j-1];
		}
	}
	cout<<dp[h][k].x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int a,b,c,k;
   cin >> a >> b >> c >> k;
   if(a >= b){
       while(a >= b){
           b *= 2;
           k--;
       }
   }
   if(b >= c){
       while(b >= c){
           c *= 2;
           k--;
       }
   }
   if(k >= 0) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int ans = 1e3+5;
const int N = 15;

int a[ans], b[ans];
int dp[ans][(1 << N) + 5];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int cs = 0;
		int x; cin >> a[i] >> x;
		for (int j = 0; j < x; j++)
		{
			int t; cin >> t;
			cs |= 1 << (t - 1);
		}
		b[i] = cs;
	}
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 0; j < (1 << n); j++)
		{
			int cs = j | b[i];
			dp[i][cs] = min(dp[i][cs], dp[i-1][j] + a[i]);
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
	}
	if (dp[m][(1 << n) - 1] == inf)	puts("-1");
	else	printf("%d\n", dp[m][(1 << n) - 1]);
	return 0;	
}

Measured memory_bytes: 128896
using System;
using System.Linq;

namespace DIntegerCards
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力 N/M, Card の取得
            var inputsNM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputsNM[0];
            var m = inputsNM[1];

            var cards = Console.ReadLine().Split().Select(long.Parse).ToArray();

            // 操作一覧の取得
            var operations = new CardOperation[m];
            for (var i = 0; i < m; i++)
            {
                var inputsBC = Console.ReadLine().Split().ToArray();
                var b = int.Parse(inputsBC[0]);
                var c = long.Parse(inputsBC[1]);
                operations[i] = new CardOperation(b, c);
            }

            // 操作をカードの値の降順に並び替える
            Array.Sort(operations);
            Array.Reverse(operations);

            // 操作によって手に入るN枚までのカード
            var opCards = operations.SelectMany(op => Enumerable.Repeat(op.Number, op.Count)).Take(n).ToArray();

            // 初期カードと操作のカードを合わせて、大きいものからN枚を合計する
            var sum = cards.Concat(opCards).OrderByDescending(x => x).Take(n).Sum();

            // 解答の出力
            Console.WriteLine(sum);
        }

        class CardOperation : IComparable<CardOperation>
        {
            public readonly int Count;
            public readonly long Number;

            public CardOperation(int b, long c)
            {
                Count = b;
                Number = c;
            }

            public int CompareTo(CardOperation other)
            {
                return this.Number.CompareTo(other.Number);
            }
        }
    }
}


Measured memory_bytes: 35824
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n;cin>>n;
    int t,x,y;
    int ts=0,xs=0,ys=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        cin>>t>>x>>y;
        int root=abs(x-xs)+abs(y-ys);
        if(t-ts>=root&&(t-ts-root)%2==0){
            ts=t;xs=x;ys=y;
            continue;
        }else{
            flag=false;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <deque>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long int LL;
const int Max_N(55);

int N, Father[Max_N], Size[Max_N], P[Max_N];
LL X, D, M[Max_N], F[2][Max_N * Max_N * Max_N], Ans;

inline bool comp(int a, int b)
{
	return Size[a] * 1LL * M[b] > Size[b] * 1LL * M[a];
}

int main()
{
	scanf("%d%lld%lld", &N, &X, &D);
	scanf("%lld", M + 1), Size[1] = 1;
	for (int u = 2;u <= N;++u)
	{
		Size[u] = 1, scanf("%lld", M + u), scanf("%d", Father + u);
		for (int v = Father[u];v;v = Father[v])
			++Size[v], M[v] += M[u];
	}
	int now = 0, lst = 1;
	memset(F[0], 0X3F, sizeof(F[0])), F[0][0] = 0LL;
	for (int u = 1;u <= N;++u)
	{
		now ^= 1, lst ^= 1, memset(F[now], 0X3F, sizeof(F[now]));
		for (int d = 0;d < Size[u];++d)
		{
			deque<int> Q;
			for (int i = 0;i * Size[u] + d <= N * N * N;++i)
			{
				while (Q.empty() == false && F[lst][Q.back() * Size[u] + d] - Q.back() * 1LL * M[u] > F[lst][i * Size[u] + d] - i * 1LL * M[u])
					Q.pop_back();
				Q.push_back(i);
				while (i - Q.front() > N || (u != 1 && i - Q.front() > D))
					Q.pop_front();
				F[now][i * Size[u] + d] = F[lst][Q.front() * Size[u] + d] + (i - Q.front()) * 1LL * M[u];
			}
		}
	}
	for (int i = 1;i <= N;++i)
		P[i] = i;
	sort(P + 1, P + 1 + N, comp);
	for (LL val = 0LL, temp;val <= N * N * N;++val)
	{
		if (F[now][val] > X)
			continue;
		LL Lim = X - F[now][val];
		temp = val;
		for (int i = 1, u;i <= N;++i)
		{
			u = P[i];
			LL cnt = Lim / M[u];
			if (u != 1)
				cnt = min(cnt, D - min(N * 1LL, D));
			Lim -= cnt * M[u], temp += cnt * Size[u];
		}
		Ans = max(Ans, temp);
	}
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  for(;;){
    int n,m;
    cin >> n >> m;
    if(n == 0 || m == 0) break;
    vector<int> v(n);
    for(int i=0; i<n; i++){
      cin >> v[i];
    }
    sort(v.rbegin(),v.rend());
    int sum = 0;
    for(int i=0; i<n; i++){
      if(i % m == m-1) continue;
      sum += v[i];
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
/*
Problem :
Algorithm :
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n,m,cnt;
int f[MAXN];

int find(int x){
	if(x == f[x])
	    return x;
	else
	    return f[x] = find(f[x]);
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++)
	    f[i] = i;
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int fx = find(x);
		int fy = find(y);
		if(fx != fy){
			f[fx] = fy;
			cnt++;
		}
	}
	printf("%d\n",n - cnt);
	return 0;
}


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

int main(){
    char s;
    int n,k;

    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    int cnt=0;
    for(int i=0;i<k;i++) cnt+=arr[i];
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3636