akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    ll n, s, b;
    cin >> n >> s;

    if(n == s){
      b = n + 1;
      pri(b);
    }else if(n < s){
      b = -1;
      pri(b);
    }else{
      ll rtn = sqrt(n);
      if(rtn * rtn != n)++rtn;
      for(b = 2;b <= rtn;++b){
        int f = 0;
        for(ll t = n;t > 0;t /= b)f += t % b;
        if(f == s){
          pri(b);
          return 0;
        }
      }
      for(ll x = rtn - 1;x >= 1;--x){
        if((n - s) % x == 0){
          b = (n - s) / x + 1;
          ll q = s - x;
          if(0 <= q && q < b && x * b + q == n){
            pri(b);
            return 0;
          }
        }
      }

      pri(-1);
      return 0;
    }



/*/

//*/ break;
  }
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  set<int> s;
  REP(i, N) {
    int temp;
    cin >> temp;
    s.insert(temp);
  }
  cout << s.size() << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;

    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

const int N = 100005;

int n, m, ans;
queue<int> q;
vector<int> v[N];
bool inq[N];

struct Bridge{
	int l, r;
}b[N];
bool cmp(Bridge x, Bridge y){
	if(x.l == y.l)	return x.r < y.r;
	return x.l < y.l;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
		scanf("%d%d", &b[i].l, &b[i].r);
	sort(b+1, b+m+1, cmp);
	for(int i = 1; i <= m; i++){
		v[b[i].l].push_back(i);
		v[b[i].r].push_back(i+m);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < v[i].size(); j++){
			if(v[i][j] <= m){
				q.push(v[i][j]);
				inq[v[i][j]] = 1;
			}
			else{
				if(inq[v[i][j]-m]){
					ans++;
					while(!q.empty()){
						inq[q.front()] = 0;
						q.pop();
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6908
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
	};

	int cnt4 = 0;
	int cnt2 = 0;
	int cntOdd = 0;
	REP(i, N) {
		if (A[i] % 4 == 0) {
			cnt4++;
		} else if (A[i] % 2 == 0) {
			cnt2++;
		} else {
			cntOdd++;
		}
	};

	bool ans = false;
	if (0 < cnt4) {
		if (cntOdd <= cnt4) {
			ans = true;
		} else if (cntOdd == cnt4 + 1) {
			if (0 == cnt2) {
				ans = true;
			}
		}
	} else {
		if (cntOdd == 0) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = [int(input()) - 1 for _ in range(n)]
i = 0
s = set()
c = 0

while True:
  if i == 1:
    print(c)
    break
  elif i in s:
    print(-1)
    break
  else:
    s.add(i)
    i = a[i]
    c += 1

Measured memory_bytes: 13216
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      h: usize,
      w: usize,
      s: [Bytes; h]
   }

   let mut m = vec![vec![0; w]; h];
   for i in 0..h {
      for j in 0..w {
         if s[i][j] == b'#' {
            m[i][j] = 1;
         }
      }
   }

   for i in 0..h {
      m[i].insert(0, 2);
      m[i].push(2);
   }
   m.insert(0, vec![2; w + 2]);
   m.push(vec![2; w + 2]);

   let mut ans = 0;
   for i in 1..=h {
      for j in 1..=w {
         if m[i][j] != 2 {
            let (n, m) = bfs((i, j), &mut m);
            ans += n * m;
         }
      }
   }

   println!("{}", ans);
}

fn bfs((x, y): (usize, usize), m: &mut Vec<Vec<usize>>) -> (usize, usize) {
   let mut n1 = 0;
   let mut n2 = 0;
   if m[x][y] == 0 {
      n1 += 1;
   } else {
      n2 += 1;
   }
   let s = m[x][y];
   m[x][y] = 2;
   for (dx, dy) in [(1, 0), (0, 1), (!0, 0), (0, !0)].iter() {
      let xn = x + dx;
      let yn = y + dy;
      if m[xn][yn] != 2 && m[xn][yn] != s {
         let (dn1, dn2) = bfs((xn, yn), m);
         n1 += dn1;
         n2 += dn2;
      }
   }
   (n1, n2)
}


Measured memory_bytes: 14708
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int d;
  cin >> d;
  cout << "Christmas";
  rep(i,25 - d) cout << " Eve";
  cout << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
int add(int &a, const int &b) {
	a = (a + b) % MOD;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	vector<int> R(N + 1, 0);
	vector<int> B(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		R[i] = R[i - 1];
		B[i] = B[i - 1];

		if (S[i - 1] == '0') {
			R[i] += 2;
		}
		else if (S[i - 1] == '1') {
			R[i]++;
			B[i]++;
		}
		else {
			B[i] += 2;
		}
	}

	vector<vector<int> > dp(R[N] + 1, vector<int>(B[N] + 1, 0));

	dp[0][0] = 1;
	for (int i = 0; i <= R[N]; i++) {
		for (int j = 0; j <= B[N]; j++) {
			int k = i + j;

			if (k > N || (i <= R[k] && j <= B[k])) {
				if (i > 0)add(dp[i][j], dp[i - 1][j]);
				if (j > 0)add(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	/*for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			cerr << dp[i][j] << " ";
		}
		cerr << endl;
	}*/
	cout << dp[R[N]][B[N]] << endl;
}

Measured memory_bytes: 31616
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

    int n;
    cin >> n;
    set<string> ct;
    for(int i = 0; i< n; ++i)
    {
	string s;
	cin >> s;
	ct.insert(s);
    }

    cout << ct.size();
    return 0;
}


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

int main(){
  int r1,r2;
  cin>>r1>>r2;
  printf("%.10f\n",1.0/(1.0/r1+1.0/r2));
}

Measured memory_bytes: 3736
#include<stdio.h>
int main()
{
  int k=0,i=0,p=0,P=0,N=0,m[100000]={};
  int n[4][4]={};
  for(k=0;k<3;k++){
    for(i=0;i<3;i++){
  scanf("%d",&n[k][i]);
    }
  }
  scanf("%d",&N);
  for(p=0;p<N;p++){
  scanf("%d",&m[p]);
  }
  for(p=0;p<N;p++){
    for(k=0;k<3;k++){
    for(i=0;i<3;i++){
  if(m[p]==n[k][i]){
    n[k][i]=0;
  }
  }
    }
  }
  if(n[0][0]+n[0][1]+n[0][2]==0){
    P=1;
  }
  if(n[1][0]+n[1][1]+n[1][2]==0){
    P=1;
  }
  if(n[2][0]+n[2][1]+n[2][2]==0){
    P=1;
  }
  if(n[0][0]+n[1][0]+n[2][0]==0){
    P=1;
  }
  if(n[0][1]+n[1][1]+n[2][1]==0){
    P=1;
  }
  if(n[0][2]+n[1][2]+n[2][2]==0){
    P=1;
  }
  if(n[0][0]+n[1][1]+n[2][2]==0){
    P=1;
  }
  if(n[0][2]+n[1][1]+n[2][0]==0){
    P=1;
  }
  if(P==1){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	ll n,W;
	cin>>n>>W;
	ll wv[n][2];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<2;j++){
			cin>>wv[i][j];
		}
	}
	ll dp[n+1][W+1];
	for(ll j=0;j<=W;j++){
		dp[0][j]=0;
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(j>=wv[i-1][0]){
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-wv[i-1][0]]+wv[i-1][1]);}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 79104
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll c[20];
ll a[20][20];
ll temp[20];
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m,p;
    cin>>n>>m>>p;
    for(i=0;i<n;i++)
    {
        cin>>c[i];
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    ll ans = inf;
    for(i=1;i<(1<<n);i++)
    {
        memset(temp,0,sizeof temp);
        x=  0;
        for(j=0;j<n;j++)
        {
            if(i &(1<<j))
            {
                x+= c[j];
                for(k=0;k<m;k++)
                    temp[k]+= a[j][k];
            }
        }
        //cout<<i<<" "<<x<<endl;
        bool f = false;
        for(j=0;j<m;j++)
        {
           // cout<<temp[j]<<" ";
            if(temp[j]<p)
            {
                f = 1;
                break;
            }
        }
        //cout<<endl;
        if(!f)
            ans=  min(ans,x);
    }
    if(ans==inf)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.rbegin(),A.rend());
    deque<int> dq;
    dq.push_back(A[0]);
    ll ans = 0;
    for(int i=1;i<N;i++){
        ans+=dq.front();
        dq.pop_front();
        dq.push_back(A[i]);
        dq.push_back(A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    int a[M], b[M];
    ll c[M];

    rep(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        c[i] = -c[i];
    }

    ll dist[N];

    rep(i, N) dist[i] = INF2;

    dist[0] = 0;

    ll ans[2] = {};
    rep(l, 2) {
        rep(loop, N-1) {
            rep(i, M) {
                if (dist[a[i]] == INF2) continue;
                dist[b[i]] = min(dist[b[i]], dist[a[i]] + c[i]);
            }
        }
        ans[l] = dist[N-1];
    }
    if (ans[0] != ans[1]) {
        cout << "inf" << endl;
    } else {
        cout << -ans[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main() {
  long int N;
  long int X[200001], Y[200001];
  cin>>N;
  for (int i = 0; i < N; i++) {
    cin>>X[i];
    Y[i] = X[i];
  }
  //memcpy(Y, X, sizeof(long int)*N);
  sort(Y, Y+N);
  
  for (long int i = 0; i < N; i++) {
    if (X[i] <= Y[N/2-1]) cout<<Y[N/2]<<endl;
    else cout<<Y[N/2-1]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)
//map<key,value>

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin >> s[i];

  for(int i=0;i<n;i++){
    sort(ALL(s[i]));
  }

  sort(ALL(s));
  //for(int i=0;i<n;i++)cout << s[i] << "\n";
  ll ans = 0;
  ll count =1;
  int flag = 0;
  for(int i=0;i<n-1;i++){
    if(s[i] == s[i+1]){
      count++;
      flag = 0;
    }
    else{
      ans += count*(count -1);
      count = 1;
      flag = 1;
    }
  }
  if(flag == 0){
    ans += count*(count -1);
  }
  cout << ans/2;
  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int x;
    int i=1;
    while(true){
        cin >> x;
        if(x == 0) break;
        cout << "Case " << i << ": " << x << endl;
        ++i;
    }
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, a, b;
ll v[55], nck[55][55];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> a >> b;
	FOR(i, n) cin >> v[i];
	sort(v, v+n);

	FOR(i, 55) {
		nck[i][0] = 1;
		nck[i][i] = 1;
	}
	for (int i = 1; i < 55; i++) {
		for (int j = 1; j < i; j++) {
			nck[i][j] = nck[i-1][j-1] + nck[i-1][j];
		}
	}

	map<ll, int> mp;
	ll sum = 0;
	FOR(i, a) {
		mp[v[n-i-1]]++;
		sum += v[n-i-1];
	}

	if (mp.size() > 1) {
		mp.clear();
		FOR(i, n) mp[v[i]]++;
		int cnt = 0;
		for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
			if (itr->first == v[n-a]) break;
			cnt += itr->second;
		}
		cout << setprecision(10) << sum / (double)a << endl;
		cout << nck[mp[v[n-a]]][a-cnt] << endl;
	}
	else {
		mp.clear();
		FOR(i, n) mp[v[i]]++;

		b = min(b, mp[v[n-1]]);
		ll ret = 0;
		for (int i = a; i <= b; i++) {
			ret += nck[mp[v[n-1]]][i];
		}
		cout << v[n-1] << endl;
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $a, $b);
if ($b == 1) {
  echo "0";
  exit;
}

$sum_plug = 0;
$i = 0;
while ($sum_plug < $b) {
  if ($i == 0) {
    $sum_plug += $a;
  } else {
    $sum_plug += $a - 1;
  }
  $i++;
}

echo $i;

Measured memory_bytes: 5368
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<pair<int,int> > > axy(n);
    REP(i,n){
        int a;
        cin >> a;
        REP(j,a){
            int x,y;
            cin >> x >> y;
            x--;
            axy[i].pb(make_pair(x,y));
        }
    }
    int now = 0;
    int ans = 0;
    while(now<(1<<n)){
        int t = now;
        vint tf(n);
        int tmp = 0;
        REP(i,n){
            tf[i]=t%2;
            t >>= 1;
            tmp+=tf[i];
        }
        bool f = true;
        REP(i,n){
            if(tf[i]==1){
                for(auto p : axy[i]){
                    if(tf[p.fi]!=(p.se)){
                        f=false;
                        break;
                    }
                }
            }
        }
        if(f){
            ans = max(ans,tmp);
        }
        now++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define Mod 1000000007
#define ll long long
ll l,r;
ll p[130];
int main(){
	cin>>l>>r;
	p[0]=1;
	for(int i=1;i<=120;i++){
		p[i]=p[i-1]*3%Mod;
	}
	for(int i=62;i>=0;i--){
		if((((1ll<<i)&l)^((1ll<<i)&r))!=0){
			break;
		}
		if(l&(1ll<<i)){
			l^=(1ll<<i);
			r^=(1ll<<i);
		}
	}
	ll ans=0;
	ll high,low;
	for(int i=62;i>=0;i--){
		if((1ll<<i)&r){
			high=i;
			break;
		}
	}
	for(int i=62;i>=0;i--){
		if((1ll<<i)&l){
			low=i;
			break;
		}
	}
	if(l==r&&l==0){
		puts("1");
		return 0;
	}
	if(l==0){
		ll now=1;
		for(int i=high;i>=0;i--){
			if((1ll<<i)&r){
				ans+=p[i]*now%Mod;
				ans%=Mod;
				now<<=1;
				now%=Mod;
			}
		}
		ans+=now;
		ans%=Mod;
		cout<<ans<<endl;
		return 0;
	}
	ll now=1;
	for(int i=high-1;i>=0;i--){
		if((1ll<<i)&r){
			ans+=p[i]*now%Mod;
			ans%=Mod;
			now<<=1;
			now%=Mod;
		}
	}
	ans+=now;
	ans%=Mod;
	now=1;
	for(int i=low-1;i>=0;i--){
		if(!((1ll<<i)&l)){
			ans+=p[i]*now%Mod;
			ans%=Mod;
			now<<=1;
			now%=Mod;
		}
	}
	ans+=now;
	ans%=Mod;
	for(int i=low+1;i<high;i++){
		ans+=p[i];
		ans%=Mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,x[50]= {0};
    for(i=0; i<10; i++)
    {
        scanf("%d",&x[i]);
    }
    sort(x,x+10);
    printf("%d\n%d\n%d\n",x[9],x[8],x[7]);
    return 0;
}

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

int h, w;
char field[50][50];

struct obj {
  char pack;
  vector<char> back;
  int ux, uy, dx, dy;
  bool is_visit;
  obj(char pack, vector<char> back, int ux, int uy, int dx, int dy):
    pack(pack), back(back), ux(ux), uy(uy), dx(dx), dy(dy){}
  obj():back(), ux(0), uy(0), dx(100), dy(100), is_visit(false) {}
};

map<char, obj> m;

bool no_loop(char c)
{
  //printf("%c\n", c);
  if (m[c].is_visit) {
    return false;
  }
  m[c].is_visit = true;
    
  for (int i = 0; i < m[c].back.size(); i++) {
    if (!no_loop(m[c].back[i])) {return false;}
  }
  m[c].is_visit = false;
  return true;
}

void solve()
{
  bool is_exist = false;
  for (int k = 0; k < h; k++) {
    for (int l = 0; l < w; l++) {
      char c;
      if (isalpha(c = field[k][l])) {
        is_exist = true;
        m[c].ux = max(l, m[c].ux);
        m[c].uy = max(k, m[c].uy);
        m[c].dx = min(l, m[c].dx);
        m[c].dy = min(k, m[c].dy);
        m[c].pack = c;
      }
    }
  }
  for(map<char, obj>::iterator itr = m.begin(); itr != m.end(); itr++){
    for (int k = itr -> second.dy; k <= itr -> second.uy; k++) {
      for (int l = itr -> second.dx; l <= itr -> second.ux; l++) {
        if (!isalpha(field[k][l])) {
          printf("SUSPICIOUS\n");
          return;
        }
      }    
    }    
  }
  //*/
  if (!is_exist) {
    printf("SAFE\n");
    return;
  }
  //printf("ok\n");
  
  for (map<char, obj>::iterator it = m.begin(); it != m.end(); it++) {
    //printf("pack:%c\n", it->first);
    it->second.is_visit = false;
    bool is_pushed[26];
    fill(is_pushed, &is_pushed[26], false);
    for (int i = it->second.dy; i <= it->second.uy; i++) {
      for (int j = it->second.dx; j <= it->second.ux; j++) {
        if (field[i][j] != it->first && !is_pushed[field[i][j] - 'A']) {
          m[field[i][j]].back.push_back(it->first);
          is_pushed[field[i][j] - 'A'] = true;
        }
      }
    }
  }
  
  for(map<char, obj>::iterator start = m.begin(); start != m.end(); start++){
    if (!no_loop(start -> first)) {
      printf("SUSPICIOUS\n");
      return;
    }
    /*
    for (map<char, obj>::iterator itr = m.begin(); itr != m.end(); itr++) {
      itr->second.is_visit = false;
    }
    */
  }
  printf("SAFE\n");
  return;
}

int main()
{
  int nInput;
  scanf("%d ", &nInput);
  
  for (int input = 0; input < nInput; input++) {
    m.clear();
    scanf("%d %d ", &h, &w);
    
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        scanf("%c ", &field[i][j]);
      }
    }
    solve();
  }
  return 0;
}

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

int main() {
    double x1,y1,x2,y2;
    scanf("%lf%lf%lf%lf", &x1,&y1,&x2,&y2);
    double distance = pow(abs(x2-x1),2) + pow(abs(y2-y1),2);
    printf("%lf\n", sqrt(distance));
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const int N = 109;
int n,arr[N],cnt=1;
int main() {

	scanf("%d", &n);
	for(int i = 0 ; i <n ; i++)
        scanf("%d", &arr[i]);
    sort(arr,arr+n);
    for(int i = 1 ; i <n ; i++)
     if(arr[i]!=arr[i-1])
      cnt++;
      printf("%d ",cnt);
    }



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>n>>a;
    a*=2;
    a++;
    b=n%a;
    n/=a;
    if(b>0) n++;
    cout<<n;
}

Measured memory_bytes: 3548
H, W = map(int, input().split())
S = [input() for i in range(H)]

dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]

flg = True
for h in range(H):
    for w in range(W):
        if S[h][w] == ".":
            continue

        nexts = []
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if nh >= 0 and nh < H and nw >= 0 and nw < W:
                nexts.append(S[nh][nw])
        if all([n == "." for n in nexts]):
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#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)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[10010];
vector<int> c(10010, 0);
int num[10010];
bool used[10010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    string S;
    cin >> S;
    int a[100010];

    rep(i,S.size()){
        a[i]=0;
    }
    int i = 0;
    while (i < S.size()) {
        int r = 0, l = 0;

        while (S[i] == 'R') {
            r++;
            i++;
        }
        a[i - 1] += (r - r / 2);
        a[i] += r / 2;

        int p_left = i - 1;
        int p_right = i;
        while (S[i] == 'L' && i < S.size()) {
            l++;
            i++;
        }
        a[p_left] += l / 2;
        a[p_right] += l - l / 2;

    }

    rep(j, S.size()) {
        cout << a[j] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1344
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() {
  int n;
  string s;
  cin>>n>>s;
  int a,len=s.size();
  rep(i,len){
      a=s[i];
      //cout<<a<<endl;
      a-=65;
      a+=n;
      if(a>=26) a%=26;
      a+=65;
      s[i]=a;
  }
  cout<<s<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   string s;cin>>s;
   reverse(all(s));
   string a="dream",b="dreamer",c="erase",d="eraser";
   reverse(all(a));
   reverse(all(b));
   reverse(all(c));
   reverse(all(d));
   bool ans=true;
//   cout<<s<<endl;
   rep(i,s.size()){
      if(s.substr(i,6)=="resare")i+=5;
      else if(s.substr(i,5)=="esare")i+=4;
      else if(s.substr(i,7)=="remaerd")i+=6;
      else if(s.substr(i,5)=="maerd")i+=4;
      else ans=false;
//      cout<<i<<endl;
   }
   if(ans)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}


Measured memory_bytes: 3740
var
  h,w,i,j,x,y,sum:longint;
  s:array[0..55,0..55] of char;
begin
  readln(h,w);

  for i:= 1 to h do
    begin
      for j:= 1 to w do
        read(s[i,j]);
      readln;
    end;

  for i:= 1 to h do
    begin
      for j:= 1 to w do
        if s[i,j]='.' then
          begin
            sum:=0;
            for x:= i-1 to i+1 do
              for y:= j-1 to j+1 do
                if  s[x,y]='#' then inc(sum);
            write(sum);
          end
          else write('#');
      writeln;
    end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

ll f(int r, int c) {
    return comb(r + c, c) - 1;//負になるかも
}

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r2++; c2++;

    init(r2 + c2);
    ll r = f(r2, c2) - f(r1, c2) - f(r2, c1) + f(r1, c1);

    r %= P;
    if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
struct Vertex {
    vector<ll> node;
};

vector<ll> v;
Vertex V[200005];
ll C[200005];

void dfs(ll index = 0, ll par = -1) {
    ll a = A[index];
    ll mi = lower_bound(v.begin(), v.end(), a) - v.begin();
    ll t = v[mi];
    v[mi] = a;
    C[index] = lower_bound(v.begin(), v.end(), INF) - v.begin();
    REP(i, V[index].node.size()) {
        ll n = V[index].node[i];
        if (n == par)
            continue;
        dfs(n, index);
    }
    v[mi] = t;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        C[i] = 0;
    }
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }
    REP(i, N + 5) {
        v.push_back(INF);
    }
    dfs();

    REP(i, N) {
        cout << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 30300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

void solve()
{
   ll h,w,n;
   cin>>h>>w>>n;
   map<pll,ll> m;
   ll i,j;
   ll row[h+1],col[w+1];
   clr(row);
   clr(col);
   ll res=0;
   for(i=0;i<n;i++)
   {
       ll x,y;
       cin>>x>>y;
       m[mp(x,y)]++;
       row[x]++;
       col[y]++;
   }
    
   vector<pll> roww,coll;
   for(i=0;i<=h;i++)
   {
      roww.pb(mp(row[i],i));
   }
   for(i=0;i<=w;i++)
   {
      coll.pb(mp(col[i],i));
   }
   sort(roww.rbegin(),roww.rend());
   sort(coll.rbegin(),coll.rend());
   ll maxr = roww[0].first;
   ll maxc = coll[0].first;
   res = maxr+maxc-1;
   ll count=0;
   for(i=sz(roww)-1;i>=0;i--)
   {
       if(roww[i].first!=maxr)
       {
           roww.erase(roww.begin()+i);
       }
   }
     for(i=sz(coll)-1;i>=0;i--)
   {
       if(coll[i].first!=maxc)
       {
           coll.erase(coll.begin()+i);
       }
   }
   for(auto i:roww)
   {
       ll f=0;
       for(auto j:coll)
       {
           if(m.find(mp(i.second,j.second))==m.end()){
           f=1;
           ll tans = i.first+j.first;
           res=max(res,tans);
           break;
           }
       }
       if(f)
       {
           break;
       }
   }
   cout<<res<<"\n";




}


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

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

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

    return 0;
}


Measured memory_bytes: 43712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

const double EPS = 1e-8;
typedef vector<double> vd;
typedef vector<vd> mat;

//Ax=b????§£??? A?????£?????????
//?§£??????or????????§?????? ??´????????????0???vector?????????
vd gauss_jordan(const mat& A, const vd& b){
    int n=A.size();
    mat B(n,vd(n+1));
    rep(i,n) rep(j,n) B[i][j]=A[i][j];
    
    //??????A????????????b?????????????????????????????????
    rep(i,n) B[i][n] = b[i];
    
    rep(i,n){
        //??¨????????????????????°????????°?????¶???????????§????????????i??????????????£?????????
        int pivot = i;
        for(int j=i;j<n;j++){
            if(abs(B[j][i])>abs(B[pivot][i]))pivot = j;
        }
        swap(B[i],B[pivot]);
        
        //?§£??????or????????§??????
        if(abs(B[i][i])<EPS)return vd();
           
        //??¨????????????????????°????????°???1?????????
        for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
        rep(j,n){
            if(i!=j){
                //j??????????????°????¶????
                for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
            }
        }
    }
    vd x(n);
    //??????????????????b????§£?????????
    rep(i,n)x[i]=B[i][n];
    return x;
}


int main(){
    int a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        vd vec;
        vec.pb(c);
        vec.pb(f);
        mat mvec;
        vd x,y;
        x.pb(a);
        x.pb(b);
        y.pb(d);
        y.pb(e);
        mvec.pb(x);
        mvec.pb(y);
        vd res = gauss_jordan(mvec, vec);
        printf("%.3lf %.3lf\n",res[0],res[1]);
    }
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long K;
    cin>>K;
    long long N;
    cin>>N;
    vector<long long>A(N);
    for(long long i=0;i<N;i++){
        cin>>A[i];
    }
    long long dis=0;
    for(long long i=0;i<N-1;i++){
        if(A[i+1]-A[i]>dis){
            dis=A[i+1]-A[i];
        }
    }
    if(K-A[N-1]+A[0]>dis){
        dis=K-A[N-1]+A[0];
    }
    cout<<K-dis<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll MAX = 500005;
//https://www.youtube.com/watch?v=zlJDTxahav0--ps -Still miss you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

int main()
{
FAST
ll n;
cin>>n;
if(n%2==1){
    cout<<"No";
}
else{
    string a,b;
  cin>>a;
  for(int i=0,j=n/2;i<n/2;i++,j++){
    if(a[i]==a[j])continue;
    cout<<"No";
    return 0;
  }
  cout<<"Yes";
}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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 ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int k;
  cin >> k;
 
  int sum = 0;
  vec a1,a2;

  RFOR(i, 1, k + 1){
    RFOR(j, 1, k + 1){
      int tmp = min(i, j);
      RFOR(l, 1, tmp + 1){
        if(i % l == 0 && j % l == 0){
          a1.push_back(l);
          break;
        }

      }
    }

  }

  REP(i, a1.size()){
    RFOR(j, 1, k + 1){
      int tmp = min(a1[i], j);
      RFOR(l, 1, tmp + 1){
        
        if(a1[i] % l == 0 && j % l == 0){
          sum += l;
          break;
        }

      }
    }
  }
 
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3888
n, m = map(int, input().split())
l = sorted([list(map(int, input().split())) for _ in range(n)])

ans = 0

for i in range(n):
    buy = min(m, l[i][1])
    ans += l[i][0]*buy
    m -= buy
    if m == 0:
        break

print(ans)

Measured memory_bytes: 28652
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    s=chomp(readline())
    flg=true
    half=trunc(Int,n/2)
    for i in 1:half
        if s[i]!=s[i+half]
            flg=false
            break
        end
    end
    if flg && length(s)%2==0
        println("Yes")
    else
        println("No")
    end
end
main()

Measured memory_bytes: 168184
def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    G = sum(A)
    list.sort(A, reverse=True)
    i = 0
    while i < M:
        if A[i] / G < 1 / (4 * M):
            return "No"
            break
        i += 1
    return "Yes"
print(main())

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    map<int, int> m;
    ll sum = 0;

    int N;
    cin >> N;
    rep(i, N) {
        int A;
        cin >> A;

        m[A]++;
        sum+= A;
    }
    int Q;
    cin >> Q;

    rep(i, Q) {
        int B, C;
        cin >> B >> C;

        sum += (C-B) * m[B];

        m[C] += m[B];
        m[B] = 0;

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 8036
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;
#define whole(xs) xs.begin(), xs.end()
typedef long long Long;

int N, T;
vector<int> D;
void input() {
    cin >> N >> T;
    D.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }
}

Long LowerBound(int begin, int end, int key) {
    int lb = begin, ub = end - 1;
    if (D[ub] > key) return 0;
    if (D[lb] <= key) return end - begin;
    while (lb + 1 < ub) {
        int mid = (lb + ub) / 2;
        if (D[mid] > key) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return end - ub;
}

const int MOD = int(1e9) + 7;
void solve() {
    sort(whole(D), greater<int>());
    Long Ans = 1;
    for (int i = 1; i < N; i++) {
        int K = D[i] + T;
        //cout << D[i] << " " << LowerBound(0, i, K) << endl;
        Ans = Ans * (LowerBound(0, i, K) + 1) % MOD;
    }
    cout << Ans << endl;
}

int main() {
    input();
    solve();
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n);
    
    for(int i=0;i<n;i++){
        cin>>A.at(i);
    }
  
  long long int step=0;
  for(int i=1;i<n;i++){
    if(A.at(i-1)>A.at(i)){
      step+=(A.at(i-1)-A.at(i));
      A.at(i)=A.at(i-1);
    }
  }
  
  cout<<step<<endl;
  
}


Measured memory_bytes: 3956
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        if (K == 0){
            if (S == 1000000000){
                for (int i = 0; i < N; i++){
                    out.print("1 ");
                }
            }
            else{
                S += 1;
                for (int i = 0; i < N; i++){
                    out.print(S + " ");
                }
            }
        }
        else{
            for (int i = 0; i < N; i++){
                if (i < K){
                    out.print(S + " ");
                }
                else{
                    if (S == 1000000000){
                        out.print("1 ");
                    }
                    else{
                        out.print(S + 1);
                        out.print(" ");
                    }
                }
            }
        }


        //テンプレ
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 44752
s = input()

flag = 0
if len(s)%2 != 0:
	print("No")
	exit()
else:
	for i in range(len(s)):
		if i%2 == 0:
			if s[i] != "h" or s[i+1] != "i":
				flag = 1
if flag == 1:
	print("No")
else:
	print("Yes")





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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

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

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

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

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

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

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

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  long long n;
  cin >> n;
  long long mi;
  cin >> mi;
  for (int i = 0; i < 4; i++) {
    long long x;
    cin >> x;
    mi = min(mi, x);
  }
  long long ans = 5 - 1 + (n + (mi - 1)) / mi;
  cout << ans;
  return 0;
}




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

int main() {
    int N;
    cin >> N;
    vector <long long> T(N), A(N), num(N);
    for(int i=0;i<N;i++){
    	cin >> T[i] >> A[i];
    	num[i]=T[i]+A[i];
    }
    for(int i=1;i<N;i++){
    	long long a=T[i-1]/T[i], b=A[i-1]/A[i];
    	if(T[i-1]%T[i]) a++; if(A[i-1]%A[i]) b++;
    	T[i]*=max(a,b); A[i]*=max(a,b); num[i]*=max(a,b);
    	}
    cout << num[N-1] << endl;
    return 0;
}


Measured memory_bytes: 256