akhauriyash/Code-Regression huggingface dataset:
// Lining Up.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
using namespace std;

long long quickpow(long long a, long long b, long long mod)
{
    int res = 1;
    while (b)
    {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int times[100005];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i != n; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp >= n || (tmp % 2) == (n % 2))
        {
            cout << 0;
            exit(0);
        }
        times[tmp]++;
    }
    long long mm = 0;
    for (int i = !(n % 2); i < n; i += 2)
    {
        if (i == 0)
        {
            if (times[i] != 1)
            {
                cout << 0;
                exit(0);
            }
        }
        else
        {
            if (times[i] != 2)
            {
                cout << 0;
                exit(0);
            }
            mm++;
        }
    }
    cout << quickpow(2, mm, 1000000007);
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];
bool visited[8];


int main() {
	ll n, a[100000], count = 1;
	std::cin >> n;
	ll ans = n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	std::sort(a, a + n);
	for (int i = 0;i < n - 1;i++) {
		if (a[i] != a[i + 1])count++;
	}
	if (count % 2 == 1) {
		std::cout << count << std::endl;
	}
	else {
		std::cout << count - 1 << std::endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  int H,W;cin >> H>>W;
  repeat(i,H){
    repeat(j,W){
      string S;
      cin >> S;
      if(S =="snuke"){
        char c = 'A'+j;
        cout << c << i+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, k, ans;
int a[1000];

int main() {
    scanf(" %d", &n);
    if (n%10 == 7) printf("Yes");
    else if ((n/10)%10 == 7) printf("Yes");
    else if ((n/100)%10 == 7) printf("Yes");
    else printf("No");
}

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

int main() {
  int n;
  string s, t, ans = "";
  cin >> n >> s >> t;
  rep(i, n){
    ans += s.at(i);
    ans += t.at(i);
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int n;
vector<string> c(3);

int main(int argc,char const* argv[])
{
  for(int i=0;i<3;i++)
    {
      cin >> c[i];
    }
  for(int i=0;i<3;i++)
    {
      cout << c[i][i];
    }
  cout << endl;
  return 0;
}


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

int main(){


    int n,k,soma=1;

    scanf("%d %d",&n,&k);

    for(int i=0;i<n;i++){
        if(soma*2<=soma+k){
            soma=soma*2;
        }else if(soma+k<=soma*2){
            soma=soma+k;
        }
    }
    printf("%d\n",soma);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  string a,b;
  cin >> a >> b;
  ll ans = 0;
  FOR(i,0,a.size()){
    ans += a[i]!=b[i];
  }
  cout << ans << endl;
}




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

using namespace std;

const int INF = 1 << 30;

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

  string T = S;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'b') T[i] = 'd';
    else if(S[i] == 'd') T[i] = 'b';
    else if(S[i] == 'p') S[i] = 'q';
    else if(S[i] == 'q') S[i] = 'p';
  }
  reverse(begin(T), end(T));

  if(S == T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main()
{
  int t, h;
  while (cin >> t >> h && t && h) {
    int taro[t], hana[h];
    int ts = 0, hs = 0;
    for (int i = 0; i < t; ++i) {
      int c;
      cin >> c;
      taro[i] = c;
      ts += c;
    }
    for (int i = 0; i < h; ++i) {
      int c;
      cin >> c;
      hana[i] = c;
      hs += c;
    }
    int diff = ts - hs;
    if (diff % 2) {
      cout << -1 << endl;
      continue;
    }
    diff /= 2;
    bool found = false;
    for (int i = 0; i < t; ++i) {
      for (int j = 0; j < h; ++j) {
        if (taro[i] - hana[j] == diff) {
          cout << taro[i] << ' ' << hana[j] << endl;
          i = t;
          found = true;
          break;
        }
      }
    }
    if (!found) cout << -1 << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
using namespace std;
int dp[8001][16001];
int a[8001];
int main()
{
	string s;
	int x,y;
	cin>>s>>x>>y;
	int k=0;
	int w=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='T')
		{
			k++;
			a[k]=w;
			w=0;
		}
		else
		{
			w++;
		}
	}
	k++;
	a[k]=w;
    dp[1][a[1]+8000]=1;
 
    
 
	
	
	for(int i=3;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	dp[0][8000]=1;
	for(int i=2;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
			dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
			dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	int ans;
	if(k%2==0){ 
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	}
	else{
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	}
	cout<<(ans==0?"No":"Yes");
	return 0;
}

Measured memory_bytes: 497792
H, W, D, *L = map(int, open(0).read().split())
A = L[:W*H]
Q = L[H*W]
inf = []
for l,r in zip(*[iter(L[H*W+1:])]*2):
  inf += [(l,r)]
dic = {A[i*W+j]:(i,j) for i in range(H) for j in range(W)}
ls = [[] for i in range(D)]
for i in range(D):
  s = i if i!=0 else D
  ls[i].append(0)
  m = s
  n = s
  while True:
    n += D
    if H*W<n:
      n = s
    px, py = dic[m]
    x, y = dic[n]
    ls[i].append(ls[i][-1]+abs(px-x)+abs(py-y))
    m = n
    if m==s:
      break
for l, r in inf:
  i = l%D
  if i==0:
    il = (l-D)//D
    ir = (r-D)//D
  else:
    il = (l-i)//D
    ir = (r-i)//D
  if l<r:
    print(ls[i][ir] - ls[i][il])
  elif l>r:
    print(ls[i][-1]-ls[i][il]+ls[i][ir])
  else:
    print(0)

Measured memory_bytes: 46104
/*  I'm a mess, I'm a loser                  */
/*  I'm a hater, I'm a user                  */
/*  I'm a mess for your love, it ain't new   */
/*  I'm obsessed, I'm embarrassed            */
/*  I don't trust no one around us           */
/*  I'm a mess for your love, it ain't new   */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;


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


ll t=1;
//cin>>t;
while(t--)
{

ll n;
cin>>n;
ll i;
vector<ll>v;

for(i=0;i<n;i++)
{
  ll te;
 cin>>te;
 v.push_back(te);
}
ll ans=0;
sort(v.begin(),v.end());
ans+=v.back();
v.pop_back();

ll h=n-2;

for(i=0;i<n;i++)
{
  if(h==0)
    break;
  if(h==1)
   {
    ans+=v.back();
     break;
   }
    else
    {
     ans+=2*v.back();
     v.pop_back();
     h-=2;
    }

}
cout<<ans<<endl;
}
return 0;
}











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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int k,x;
  cin >> k >> x;
  int max,min;
  min=x+1-k;
  max=k+x-1;
  REP(i,min,max+1){
    cout << i << ' ' ;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int h, w, m;

void solve() {
	
	cin >> h >> w >> m;
	
	map<int, int> row, col;
	map<int, map<int,int> > vis;
	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		row[x]++;
		col[y]++;
		vis[x][y] = 1;
	}
	int x = 0, y = 0;
	for (auto r : row)x = max(x, r.second);
	for (auto c : col)y = max(y, c.second);
	VI a, b;
	for (auto r : row) {
		if (r.second == x) {
			a.push_back(r.first);
		}
	}
	for (auto c : col) {
		if (c.second == y) {
			b.push_back(c.first);
		}
	}
	rep(i, 0, sz(a)) {
		rep(j, 0, sz(b)) {
			if (!vis[a[i]].count(b[j])) {
				cout << x + y << endl;
				return;
			}
		}
	}
	cout << x + y - 1 << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 77640
/*

与えられた整数nの階乗を出力せよ。nは1〜20の範囲とする。

やり方：
	・nを1ずつ減らしながら、resultに掛けていく。nが1以下になったら表示して終わり。

結果：Wrong answer

「20!」を計算した時に、負の数が表示される。
（よく分からないが）扱える値の限界を超えてしまい、一周しているのだろうか。

結論：知識が必要（限界を引き延ばす方法）

*/
#include <stdio.h>

void kaijou(double n);		//nの階乗を表示する関数。

int main()
{
	double n;
	while(1){                        //無限ループ
		scanf("%lf",&n);          //nを入力
		if(1<=n&&n<=20){
			break;          //nが1以上20以下の範囲なら、ループを抜ける。
		}
	}
	kaijou(n);
	return 0;
}

void kaijou(double n)
{
	double result=1.0;
	while(n>=2){
		result*=n;
		n--;
	}
	printf("%.0f\n",result);
}

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

long long n,a[200005],u,v,ft[200005],ans[200005];
vector<int> grafo[200005],diff;
vector<pair<int,int> > op[200005];
map<int,int> ind;

void upd(int pos,long long val,int mode){
	for(int i=pos;i<200005;i+=(i&(-i))){
		op[mode].push_back({i,ft[i]});
		ft[i]=max(ft[i],val);
	}
}

int query(int pos){
	int res=0;
	for(int i=pos;i>0;i-=(i&(-i))){
		res=max(res,(int)ft[i]);
	}
	return res;
}

void rollback(int pos){
	for(int i=0;i<op[pos].size();i++){
		ft[op[pos][i].first]=op[pos][i].second;
	}
}

void dfs(int nodo,int last){
	
	upd(ind[a[nodo-1]],query(ind[a[nodo-1]]-1)+1,nodo);
	
	ans[nodo]=query(200002);
	
	//cout<<ind[a[nodo-1]]<<" "<<ans[nodo]<<" nodo: "<<nodo<<"\n";
	
	for(int i=0;i<grafo[nodo].size();i++){
		if(grafo[nodo][i]!=last){
			dfs(grafo[nodo][i],nodo);
		}
	}
	
	rollback(nodo);
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		diff.push_back(a[i]);
	}
	
	sort(diff.begin(),diff.end());
	
	int cont=1;
	for(int i=0;i<diff.size();i++){
		if(i==0 || diff[i]!=diff[i-1]){
			ind[diff[i]]=cont;
			cont++;
		}
	}
	
	for(int i=0;i<(n-1);i++){
		cin>>u>>v;
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}
	
	dfs(1,-1);
	
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";

return 0;
}


Measured memory_bytes: 68680
import collections

# def get_lim(n):
#     # for i in range(n):
#     #     if i * i > n:
#     #         return i + 1
#     return pow(10, int((len(str(n)) / 2)))

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    # lim = get_lim(n)
    for i in range(2, n):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i * i > n:
            break
        # print(n, i)
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

        soinnsuu = prime_factor(num, length)
        ans = 1
        # print(soinnsuu)
        for data in soinnsuu.keys():
            if soinnsuu[data] >= length:
               ans *= pow(data, int(soinnsuu[data] / length))
        print(ans)

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e6 * 2 + 5;
constexpr double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vl a(n);
    map<ll, ll> dict;
    rep(i, n) cin >> a[i];
    rep(i, n) dict[a[i]]++;

    ll sum = 0;
    foreach (me, dict) {
        auto e = me.second;
        sum += (e - 1) * e / 2;
    }
    ll ans = 0;
    rep(i, n) {
        ans = sum - (dict[a[i]] - 1);
        out(ans);
    }
}


Measured memory_bytes: 11008
mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [1] + [0] * S
for i, a in enumerate(A, 1):
    dp = [(2 * dp[j] + (dp[j - a] if j >= a else 0)) % mod for j in range(S + 1)]

print(dp[S])

Measured memory_bytes: 72036
// ABC173.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int price, change, thousands;

    cin >> price;

    thousands = price / 1000;

    if (price % 1000 == 0) {
        cout << 0;
        return 0;
    }
    else {
        change = (thousands + 1) * 1000 - price;
        cout << change;
        return 0;
    }
}




Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int nCrModp(int n, int r, int p) 
{ 
    // The array C is going to store last row of 
    // pascal triangle at the end. And last entry 
    // of last row is nCr 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; // Top row of Pascal Triangle 
  
    // One by constructs remaining rows of Pascal 
    // Triangle from top to bottom 
    for (int i = 1; i <= n; i++) 
    { 
        // Fill entries of current row using previous 
        // row values 
        for (int j = min(i, r); j > 0; j--) 
  
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
int main()
{
	ll n,k,sum=0,m=1000000007;
	cin>>n>>k;
	for (int i = 1; i <= k; ++i)
	{
		if(n-k-i+1>=0)
		{
			ll x=nCrModp(k-1,i-1,m);
			ll y=nCrModp(n-k+1,i,m);
			cout<<((x*y)%m)<<"\n";
		}
		else cout<<"0\n";
	}
	
}


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

int main() {
    int n, k, red;
    long long const mod = 1e9+7;
    vector< vector<long long> > comb;
    cin >> n >> k;
    red = n - k;
    comb.assign(n*2, vector<long long>());
    for(int i=0;i<n*2;i++){
        comb[i].assign(i+1, 0);
        comb[i][0] = comb[i][i] = 1;
        for(int j=1;j<i;j++){
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1] ) % mod;
        }
    }
    for(int i=1;i<=k;i++){
        int res = k  - i;
        // i H res
        long long ans = comb[i+res-1][res];
        //
        res = red - i + 1;
        if(res < 0){
            ans = 0;
        }else{
            ans *= comb[i+1+res-1][res];
        }
        cout << ans % mod << endl;
    }
	return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
    
    //ll parent
    ll arr[100005];
    map<ll,vector<ll>>m1;
    int main()
    {

         ios_base::sync_with_stdio(false);
         cin.tie(NULL);cout.tie(NULL);
      
      double p=1.0;
      ll i,j;
      ll n;
      cin>>n;
      ll a[n];
      rep(i,0,n)
      {
        cin>>a[i];
        p=p*a[i];
      }
      double sum1=0.0;
      for(i=0;i<n;i++)
      {
        sum1+=(p/a[i]);
      }
      cout<<p/sum1<<endl;
      return 0;
  }
        

        
    


  



Measured memory_bytes: 256
#include <stdio.h>
//mistake
struct st{
  char a;
  int b;
};

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

int main() {
  int n, k;
  scanf("%d %d\n", &n, &k);
  struct st st[n];
  char s, t;
  scanf("%c", &s);
  t = s;
  st[0].a = s;
  st[0].b = 1;
  int j = 0;
  for (int i = 1; i < n; i++) {
    scanf("%c", &s);
    if (s == t) {
      st[j].b += 1;
    } else {
      j++;
      st[j].a = s;
      st[j].b = 1;
      t = s;
    }
  }
  n = j+1;
  int count = 0, max = 0;
  for (int i = 0; i < n; i++) {
    count = 0;
    if (st[i].a == '0') {
      for (int j = 0; j < min(2*k, n-i); j++) {
        count += st[i+j].b;
      }
      if (count > max) {
        max = count;
      }
      if (i > n-2*k) {
        break;
      }
    } else {
      for (int j = 0; j < min(2*k+1, n-i); j++) {
        count += st[i+j].b;
      }if (count > max) {
        max = count;
      }
      if (i > n-2*k-1) {
        break;
      }
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long int int64;

void run(void){
  char *s=(char *)calloc(200000+1,sizeof(char));
  scanf("%s",s);
  int n=strlen(s);
  int64 ans=0;
  int cnt=0;
  int i;
  for(i=n-1;i>=0;i--){
    if(s[i]=='B'){
      ans+=cnt;
    } else {
      cnt++;
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int N;
	cin >> N;

	N %= 1000;

	int ans = 0;

	if(N!=0) ans = 1000 - N;

	cout << ans << endl;

	return 0;
}


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

long long n, h[100005], dp[100005];
int k;

int main(){
	cin>>n>>k;
	for(int i=1; i<=n; i++){
		cin>>h[i];
	}
	dp[0]=0;
	dp[1]=0;
	for(int i=2; i<=n; i++){
		dp[i]=1e9;
		for(int j=max(1, i-k); j<i; j++){
			dp[i]=min(dp[i], abs(h[i]-h[j])+dp[j]);
		}//cout<<dp[n]<<endl;
	}
	cout<<dp[n]<<endl;
}


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

typedef long long ll;

int main(){
    char alp[26] = {
        'z',
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 
        'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y',
    };
    vector<int> ans;
    ll n;
    cin >> n;
    ll tmp = 1;
    int i = 0;
    while(n != 0){
        tmp = n % 26;
        ans.push_back(tmp);
        ++i;
        n /= 26;
        if(0 == tmp){
            --n;
        }
    }
    string a = "";
    for(--i; i >= 0; --i){
        a += alp[ans[i]];
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;

int main(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    cout<<(m1!=m2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;
const int MAXN = 101010;
int dp[MAXN];
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    
    rep(i,MAXN) dp[i] = INF;

    dp[0] = 0;
    rep(i,N) {
        srep(j, 1, K+1) {
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1152
N=int(input())
l=[]
for i in range(N):
    a=int(input())
    l.append([a,i])
l.sort(key=lambda x:x[0])
dif=[]
for i in range(N):
    dif.append(abs(l[i][1]-i)%2)
#print(dif)
print(sum(dif)//2)


Measured memory_bytes: 70360
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  
#include <vector>
#include <stack>
#include <cmath>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;

ll t=1,n,m;
ll s=0;
ll a[N]={0};
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		t=a[i]/2/__gcd(a[i]/2,t)*t;
	}
	for(int i=0;i<n;i++){
		if(t%(a[i])==0){
			cout<<"0"<<endl;
			return 0;
		}
	}
	printf("%lld\n",(m/t+1)/2);
	return 0;
}

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

int main() {
	ll N, D, answer = 0;
	cin >> N >> D;
	D *= D;
	rep(i, N) {
		ll x, y, d;
		cin >> x >> y;
		d = x * x + y * y;
		if (d <= D) { answer++; }
	}
	cout << answer << endl;
}

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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, I n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  I x, y, z;
  cin >> x >> y >> z;
  I d1 = y - x, d2 = z - y;
  rep(i, 0, 1) {
    I x, y, z;
    cin >> x >> y >> z;
    if ((y - x != d1) || (z - y != d2)) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


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

using namespace std;

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

const int MOD = (int)1e9 + 7;

template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int n,w[301];
int dp[301][301];

int main(void){

  while(1){
    cin>>n;
    if(n==0) break;
    REP(i,n) cin>>w[i];

    memset(dp, 0, sizeof(dp));

    for(int i=n-1;i>=0;--i){
      dp[i][i] = 0;
      dp[i][i+1] = 0;
      for(int j=i+1;j<=n;++j){
	if(i+1<j && abs(w[i]-w[j-1])<=1 && dp[i+1][j-1]==j-i-2){
	  dp[i][j] = j-i;
	}
	for(int k=j+1;k<=n;k++){
	  amax(dp[i][k], dp[i][j] + dp[j][k]);
	}
      }
    }

    cout<<dp[0][n]<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3404
#include <bits/stdc++.h>
#define r(i,n) for(long long i = 1; i<=n; i++)
typedef long long ll;
using namespace std;

int main() {
  double n,ans=0;
  int k;
  cin >> n >> k;
    r(i,n){
      double ans1=1/n;
      int t=i;
      while(t<k){
        t*=2; ans1/=2;
      }
      ans+=ans1;
    }
  printf("%.12lf\n",ans);
}

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

int main() {
  int n, ans = 0;
  string s;
  cin >> n >> s;
  char c = s.at(0);
  for (int i = 1; i < n; i++) {
    if (s.at(i) != c) {
      ans++;
      c = s.at(i);
    }
  }
  ans++;
  cout << ans << endl;
}

Measured memory_bytes: 512
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

  ll N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  ll ans = 0;
  rep(i, N) {
    char c = T[i];
    if (c == 'r')
      T[i] = 'p';
    else if (c == 'p')
      T[i] = 's';
    else
      T[i] = 'r';
  }
  debug(T);
  rep(i, K) {
    char last = '_';
    for (int j = i; j < N; j += K) {
      if (T[j] != last) {
        if (T[j] == 'r') {
          ans += R;
        } else if (T[j] == 'p') {
          ans += P;
        } else {
          ans += S;
        }
        last = T[j];
      } else {
        last = '_';
      }
    }
  }
  out(ans);
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 0;
  vector<int>a;
  vector<int>b;
  vector<int>c;
  for(int i = 0;i < N; i++){
    if(S.at(i) == 'R'){
      a.push_back(i);
    }
    else if(S.at(i) == 'G'){
      b.push_back(i);
    }
    else if(S.at(i) == 'B'){
      c.push_back(i);
    }
  }
  for(int j = 0; j < a.size();j++){
    for(int k = 0; k < b.size(); k++){
      int d = a.at(j);
      int e = b.at(k);
      if(d < e){
        if(2*e - d <= N-1){
          if(S.at(2*e - d) == 'B'){
            count++;
          }
        }
        if(2*d - e >= 0){
          if(S.at(2*d - e) == 'B'){
            count++;
          }
        }
        if((d + e) % 2 == 0){
          if(S.at((d + e) / 2) == 'B'){
            count++;
          }
        }
      }
      if(d > e){
        if(2*d - e <= N-1){
          if(S.at(2*d - e) == 'B'){
            count++;
          }
        }
        if(2*e - d >= 0){
          if(S.at(2*e - d) == 'B'){
            count++;
          }
        }
        if((d + e) % 2 == 0){
          if(S.at((d + e) / 2) == 'B'){
            count++;
          }
        }
      }
    }
  }

        
  cout <<a.size() * b.size() * c.size() - count << endl;
}



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

#define _LL long long

int main()
{
    _LL n;
    cin >> n;
    _LL a = 10;
    _LL ans = 0;
    if( n % 2 == 1 )
    {
        cout << 0;
        return 0;
    }
    while( a <= n )
    {
        ans += ( n / a );
        a *= 5;
    }
    cout << ans;
    return 0;
}


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

int main(){
	string S;
	cin >> S;
	
	int N = S.size();
	
	string ans = "yes";
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(S[i]==S[j]){
				ans="no";	
			}
		}
	}
	
	cout << ans << endl;
	

};

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String result = "No";
      String inStr  = br.readLine();
      String target = br.readLine();
      String ring = inStr + inStr;

      if( inStr.length() >= target.length()) {
        if( ring.indexOf(target) != -1) result = "Yes";
      }

      System.out.println(result);
    }
  }
}


Measured memory_bytes: 24452
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

int main()
{
    int x, y, w, h, xf, yf,s;
    cin >> s;
    rep(j,s)
    {
        cin >> x >> y >> w >> h;
        xf = x + w; yf = y + h;
        int cx,cy, ans = 0, n;
        cin >> n;
        REP(n)
        {
            cin >> cx >> cy;
            if(cx >= x && cx <= xf && cy >= y && cy <= yf )ans++;
        }
        cout << ans << endl;


    }
    
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <atcoder/all>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N){
  N*=2;
  using namespace atcoder;
  vector<pll> divisor;
  for (ll i = 1; i*i <= N; ++i)
  {
    if(N%i==0){
      divisor.push_back(pll(i,N/i));
      divisor.push_back(pll(N/i,i));
    }
  }
  ll ans=LLONG_MAX;
  for (auto [x,y] : divisor)
  {
    if(gcd(x,y)>1)continue;
    auto [z,mod] = crt({0,y-1},{x,y});
    if(z==0)z=mod;
    ans=min(ans,z);
  }
  cout<<ans<<endl;
  
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3936
s = int(input())

Y = s//100
M = s%100
flag=0
#YYMM
if(M!=0 and M<13):
    flag+=1
#MMYY
if(Y!=0 and Y<13):
    flag+=2

if(flag==0):
    print('NA')
elif(flag==1):
    print('YYMM')
elif(flag==2):
    print('MMYY')
elif(flag==3):
    print('AMBIGUOUS')

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int k = sc.nextInt();
		int [] in = new int [a];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		Arrays.sort(in);
        int ans = 0;
        for(int i=0;i<k;i++){ans+=in[i];
                            }
       
		System.out.println(ans);
	}
}


Measured memory_bytes: 39012
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>

#define INF 1000000
using namespace std;

int M,N;
int X1[210], Y[210], X2[210], Z[210];

double width(int p[210], int q[210], int n, double x)
{
    double a=INF,b=-INF;
    for(int i=0;i<n;i++)
	{
        double x1=p[i], x2=p[(i+1)%n];
        double y1=q[i], y2=q[(i+1)%n];
        if((x1-x)*(x2-x)<=0 && x1!=x2)
		{
            double y=y1+(y2-y1)*(x-x1)/(x2-x1);
            a=min(a,y);
            b=max(b,y);
        }
    }
    if(b-a>0)
      return b-a;
    else
      return 0.0;
}

double volume()
{
	int x1min, x2min, x1max, x2max;
	x1min=*min_element(X1, X1+M);
	x1max=*max_element(X1, X1+M);
	x2min=*min_element(X2, X2+M);
	x2max=*max_element(X2, X2+M);
	int A[420];
	for(int i=0;i<M;i++)
	{
		A[i]=X1[i];
	}
	for(int i=M;i<M+N;i++)
	{
	   A[i]=X2[i-M];	
	}
	sort(A,A+M+N);
	double total=0.0;
	for(int i=0;i+1<M+N;i++)
	{
		double a=A[i], b=A[i+1];
		double c=(a+b)/2.0;
		if(c>=x1min&&c<=x1max&&c>=x2min&&c<=x2max)
		{
			double fa, fb, fc;
			fa=width(X1,Y,M,a)*width(X2,Z,N,a);
			fb=width(X1,Y,M,b)*width(X2,Z,N,b);
			fc=width(X1,Y,M,c)*width(X2,Z,N,c);
			total+=(b-a)/6*(fa+4*fc+fb);
		}
	}
	return total;
}

int main()
{
    while(cin >> M >> N)
	{
		for(int i=0;i<210;i++)
		{
			X1[i]=0;
			Y[i]=0;
			X2[i]=0;
			Z[i]=0;
		}
		if(!M&&!N)
		  break;
		for(int i=0;i<M;i++)
		   cin >> X1[i] >> Y[i];
		for(int i=0;i<N;i++)
		   cin >> X2[i] >> Z[i];   
		double sum=volume();
		printf("%.10f\n",sum);
	}	
} 


Measured memory_bytes: 3216
#include <cstdio>
#include <algorithm>
using namespace std;
#define reps(i,j,k) for(int i = j;i < k;i++)
#define rep(i,j) reps(i,0,j)
typedef pair < int,int > Pii;
bool F;
char change(int s){
	if(s == 0)return '+';
	if(s == 1)return '-';
	if(s == 2)return '*';
}
int calc(int a,int s,int b){
	if(s == 0)return a+b;
	if(s == 1)return a-b;
	if(s == 2)return a*b;
}
void solve(int num[5],int s[4],int dep){
	if(F)return ;
	if(dep == 3){
		if(calc(calc(calc(num[0],s[0],num[1]),s[1],num[2]),s[2],num[3]) == 10){
			printf("(((%d%c%d)%c%d)%c%d)\n",num[0],change(s[0]),num[1],change(s[1]),num[2],change(s[2]),num[3]);
			F = true;
			return ;
		}
		if(calc(calc(num[0],s[0],num[1]),s[1],calc(num[2],s[2],num[3])) == 10){
			printf("((%d%c%d)%c(%d%c%d))\n",num[0],change(s[0]),num[1],change(s[1]),num[2],change(s[2]),num[3]);
			F = true;
			return ;
		}
		if(calc(num[0],s[0],calc(calc(num[1],s[1],num[2]),s[2],num[3])) == 10){
			printf("%d%c((%d%c%d)%c%d)\n",num[0],change(s[0]),num[1],change(s[1]),num[2],change(s[2]),num[3]);
			F = true;
			return ;
		}
		if(calc(calc(num[0],s[0],calc(num[1],s[1],num[2])),s[2],num[3]) == 10){
			printf("(%d%c(%d%c%d))%c%d\n",num[0],change(s[0]),num[1],change(s[1]),num[2],change(s[2]),num[3]);
			F = true;
			return ;
		}
		if(calc(num[0],s[0],calc(num[1],s[1],calc(num[2],s[2],num[3]))) == 10){
			printf("%d%c(%d%c(%d%c%d))\n",num[0],change(s[0]),num[1],change(s[1]),num[2],change(s[2]),num[3]);
			F = true;
			return;
		}
		return ;
	}
	rep(i,3){
		s[dep] = i;
		if(F)return ;
		solve(num,s,dep+1);
		if(F)return ;
	}
}
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),(a|b|c|d)){
		int num[4];
		F = false;
		num[0] = a;num[1] = b;num[2] = c;num[3] = d;
		sort(num,num+4);
		do{
			int s[4];
			solve(num,s,0);
			if(F)break;
		}while(next_permutation(num,num+4));
		if(!F)puts("0");
	}
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define drep(i,l,r) for(int (i)=(l);(i)>=(r);(i)--)
using namespace std;
int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    a-=k;
    if(a<0){
        b+=a;
        a=0;
    }
    if(b<0)b=0;
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int p,q,r,o[5];
  cin >> p >> q >> r;
  o[0] = p + q;
  o[1] = r + q;
  o[2] = p + r;
  o[3] = q + r;
  o[4] = r + p;
  o[5] = q + p;
  sort (o,o + 5);
  cout << o[0] << '\n';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  return 0; 
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

int main() {
    string s;
    cin>>s;
    int ans=0;
    for(char c:s) ans+=c-'0';
    if(ans%9)cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3748
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s1, s2;
	cin >> s1 >> s2;
	if (s1 + s2.back() == s2) {
		cout << "Yes";
	}
	else cout << "No";
}

Measured memory_bytes: 3632
using namespace std;
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define N 100001
struct dian{
	int x,y,no;
}xx[N],yy[N];
bool cmpx(dian hh,dian aa)
{
	return hh.x<aa.x;
}
bool cmpy(dian hh,dian aa)
{
	return hh.y<aa.y;
}
 
int x[N],y[N];
struct edge{
	int from,to,val;
}E[2*N];
bool cmp(edge hh,edge aa)
{
	return hh.val<aa.val;
}
int cnt=0;
int fa[N];
int ans;
int getf(int no)
{
	return fa[no]==no?no:fa[no]=getf(fa[no]);
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++) 
	{
		xx[i].x=x[i];xx[i].y=y[i];xx[i].no=i;
	}
	sort(xx+1,xx+n+1,cmpx);
	for(int i=1;i<=n-1;i++)
	{
		E[++cnt].from=xx[i].no;
		E[cnt].to=xx[i+1].no;
		E[cnt].val=xx[i+1].x-xx[i].x;
	}
	sort(xx+1,xx+n+1,cmpy);
	for(int i=1;i<=n-1;i++)
	{
		E[++cnt].from=xx[i].no;
		E[cnt].to=xx[i+1].no;
		E[cnt].val=xx[i+1].y-xx[i].y;
	}
	sort(E+1,E+cnt+1,cmp);
	for(int i=1;i<=n;i++) fa[i]=i;
	int zkx=0;
	for(int i=1;i<=cnt;i++)
	{
		if(getf(E[i].from)!=getf(E[i].to))
		{
			fa[fa[E[i].from]]=fa[E[i].to];
			ans+=E[i].val;
			zkx++;
		}
		if(zkx==n-1) break;
	}
	cout<<ans<<endl; 
}

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

int main() {
	long long n, R, minR, ans;
	scanf("%lld", &n);
	scanf("%lld", &R);
	if (n == 1) {
		cout << R << endl;
		return 0;
	}
	minR = R;
	for (long long i = 0; i < n - 1; i++) {
		scanf("%lld", &R);
		if (i == 0) {
			ans = R - minR;
		}
		else {
			if (R - minR > ans) ans = R - minR;
		}
		if (R < minR) minR = R;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3216
A,B,C = map(int,input().split())
cou = 0
if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
  print("0")
  exit()
while(cou < 10**6):
  cou += 1
  a = A
  b = B
  c = C
  A = b/2 + c/2
  B = a/2 + c/2
  C = a/2 + b/2
  if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
    print(str(cou))
    exit()
  else:
    pass
print("-1")

Measured memory_bytes: 3064