akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
int n,q,a,b; 
ll x[222222];

struct node
{
	ll lazy;
	ll ans;
};

node st[2][800111];

void build(int ty, int id, int l, int r)
{
	if(r-l<2)
	{
		st[ty][id].lazy=0;
		st[ty][id].ans=ll(1e14);
		if(l==a)
		{
			st[ty][id].ans=abs(x[0] - b);
		}
		if(ty==0) st[ty][id].ans-=l;
		else st[ty][id].ans+=l;
		return ;
	}
	int mid=(l+r)>>1;
	build(ty,id*2,l,mid); build(ty,id*2+1,mid,r);
	st[ty][id].ans=min(st[ty][id*2].ans,st[ty][id*2+1].ans);
}

void push(int ty, int id, int l, int r)
{
	if(st[ty][id].lazy!=0)
	{
		st[ty][id].ans+=st[ty][id].lazy;
		if(r-l>=2)
		{
			st[ty][id*2].lazy+=st[ty][id].lazy;
			st[ty][id*2+1].lazy+=st[ty][id].lazy;
		}
		st[ty][id].lazy=0;
	}
}

void update(int ty, int id, int l, int r, int pos, ll v)
{
	push(ty,id,l,r);
	if(pos>=r||pos<l) return ;
	if(r-l<2)
	{
		st[ty][id].ans=min(v,st[ty][id].ans);
		return ;
	}
	int mid=(l+r)>>1;
	update(ty,id*2,l,mid,pos,v); update(ty,id*2+1,mid,r,pos,v);
	st[ty][id].ans=min(st[ty][id*2].ans,st[ty][id*2+1].ans);
}

void add(int ty, int id, int l, int r, int ql, int qr, ll v)
{
	push(ty,id,l,r);
	if(ql>=r||l>=qr) return ;
	if(ql<=l&&r<=qr)
	{
		st[ty][id].lazy+=v;
		push(ty,id,l,r);
		return ;
	}
	int mid=(l+r)>>1;
	add(ty,id*2,l,mid,ql,qr,v); add(ty,id*2+1,mid,r,ql,qr,v);
	st[ty][id].ans=min(st[ty][id*2].ans,st[ty][id*2+1].ans);
}

ll query(int ty, int id, int l, int r, int ql, int qr)
{
	push(ty,id,l,r);
	if(ql>=r||l>=qr) return ll(1e15);
	if(ql<=l&&r<=qr) return st[ty][id].ans;
	int mid=(l+r)>>1;
	return min(query(ty,id*2,l,mid,ql,qr), query(ty,id*2+1,mid,r,ql,qr));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>q>>a>>b; a--; b--;
	for(int i=0;i<q;i++) {cin>>x[i]; x[i]--;}
	ll ans=ll(1e18);
	for(int z=0;z<2;z++)
	{
		for(int ty=0;ty<2;ty++) build(ty,1,0,n);
		for(int i=1;i<q;i++)
		{
			ll real = min(query(0,1,0,n,0,x[i]) + x[i], query(1,1,0,n,x[i],n) - x[i]);
			for(int j=0;j<2;j++) add(j,1,0,n,0,n,abs(x[i-1]-x[i]));
			update(0,1,0,n,x[i-1],real-x[i-1]);
			update(1,1,0,n,x[i-1],real+x[i-1]);
		}
		for(int i=0;i<n;i++)
		{
			ans=min(ans,query(0,1,0,n,i,i+1)+i);
			assert(query(0,1,0,n,i,i+1)+i==query(1,1,0,n,i,i+1)-i);
		}
		swap(a,b);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 22784
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        long minval = Integer.MAX_VALUE, maxVal = Integer.MIN_VALUE;
        long minVal2 = minval, maxVal2 = maxVal;
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            long a = Integer.parseInt(inp[0]), b = Integer.parseInt(inp[1]);
            long res = a+b, res2 = a-b;
            minval = Math.min(minval, res);
            maxVal = Math.max(maxVal, res);
            minVal2 = Math.min(minVal2, res2);
            maxVal2 = Math.max(maxVal2, res2);
        }
        long res = Math.max(maxVal-minval, maxVal2-minVal2);
        System.out.println(res);
    }
}


Measured memory_bytes: 54556
#4
#入力
N=int(input())

A=list(map(int,input().split()))

#処理
B=[]

for i in A:
    if len(B)==0:
        B.append(i)
    else:
        B.append(B[-1]+i)
        

C=[0 for i in range(N)]

for i in range(N):
    C[i]=abs(B[N-1]-2*B[i])
print(min(C[:N-1]))

Measured memory_bytes: 29316
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int N, x;
    std::cin >> N >> x;

    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    int count = 0;
    int sum = 0;
    int i;
    for (i = 0; i < N - 1; i++) {
        if (sum + a[i] > x) {
            break;
        }

        sum += a[i];
        count++;
    }

    if (i == N - 1 && sum + a[i] == x) {
        count++;
    }

    std::cout << count << std::endl;
    
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 300
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char st[MN+5];
int f[MN/2+5][MN/2+5][MN/2+5],g[MN/2+5][MN/2+5][MN/2+5],n,K,ans=0;
inline void R(int&x,int y){y>x?x=y:0;}
void Solve()
{
	memset(f,200,sizeof(f));f[0][0][0]=0;
	for(int k=0;k<=K;++k)
		for(int i=0;i<=n>>1;++i)
			for(int j=0;j<=n>>1;++j) if(f[k][i][j]>=0)
			{
				R(f[k+1][i][j],f[k][i][j]);
				R(f[k][i+1][j],f[k][i][j]);
				R(f[k][i][j+1],f[k][i][j]);
				if(i<n>>1&&j<n>>1&&st[i+1]==st[n-j]) R(f[k][i+1][j+1],f[k][i][j]+1);
				else R(f[k+1][i+1][j+1],f[k][i][j]+1);
			}
	memset(g,200,sizeof(g));
	for(int i=1;i<=n+1>>1;++i) for(int j=0;j<=K;++j) g[j][i][i]=1,g[j][i+1][i]=0;
	for(int k=0;k<=K;++k)
		for(int i=n+1>>1;i;--i)
			for(int j=i;j<=n+1>>1;++j)
			{
				R(g[k][i][j],g[k][i][j-1]);
				R(g[k][i][j],g[k][i+1][j]);
				if(k) R(g[k][i][j],g[k-1][i][j]),R(g[k][i][j],g[k-1][i+1][j-1]+2);
				if(st[i]==st[j]) R(g[k][i][j],g[k][i+1][j-1]+2);
				//cout<<k<<" "<<i<<" "<<j<<" "<<st[i]<<" "<<st[j]<<" "<<g[k][i][j]<<endl;
			}
	for(int i=0;i<=n>>1;++i) for(int j=0;j<=K;++j)
		ans=max(ans,f[j][i][n>>1]*2+(i<n+1>>1?g[K-j][i+1][n+1>>1]:0));
	if(n&1) ans=max(ans,2*f[K][n>>1][n>>1]+1);
}
int main()
{
	scanf("%s",st+1);n=strlen(st+1);K=read();
	if(K>n>>1) return 0*printf("%d\n",n);
	Solve();
	for(int l=1,r=n;l<r;++l,--r) swap(st[l],st[r]);
	Solve();
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 29440
x,d,m[];main(h,X,Y,S){for(;x--||~scanf("%d,%d,%d",&X,&Y,&S,x=99);)hypot(x%10-X,x/10-Y)*2<=S+1?h-=!m[x],d=fmax(++m[x],d):0;d=!printf("%d\n%d\n",x+h,d);}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1000000000010LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<int> A(X), B(Y), C(Z);
    for(int i=0; i<X; i++) cin >> A[i];
    for(int i=0; i<Y; i++) cin >> B[i];
    for(int i=0; i<Z; i++) cin >> C[i];

    vector<int> AB;
    for(int i=0; i<X; i++) {
        for(int j=0; j<Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end());
    sort(C.begin(), C.end());

    int ub = INF, lb = 0;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        int cnt = 0;
        for(int i=0; i<Z; i++) {
            int idx = lower_bound(AB.begin(), AB.end(), mid - C[i]) - AB.begin();
            cnt += max(0LL, X*Y - idx);
        }
        
        if(cnt >= K) lb = mid;
        else ub = mid;
    }

    // K 番目の値
    int rK = lb;

    vector<int> ans;
    for(int i=0; i<Z; i++) {
        int idx = lower_bound(AB.begin(), AB.end(), rK - C[i]) - AB.begin();
        for(int k=idx; k<X*Y; k++) ans.push_back(AB[k] + C[i]);
    }
    sort(ans.rbegin(), ans.rend());

    for(int i=0; i<K; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
using P = pair <ll, ll>;

const int N = 1e3 + 5;

P ar[N];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> ar[i].fr >> ar[i].sc;
	}
	ll cura = ar[1].fr, curb = ar[1].sc;
	for (int i = 2; i <= n; i ++) {
		int a = ar[i].fr, b = ar[i].sc;
		if (cura == a && curb == b) continue;
		if (cura <= a && curb <= b) {
			cura = a;    curb = b;
		} else if (cura <= a && curb >= b) {
			ll cnt = (curb + b - 1) / b;
			cura = cnt * a;
			curb = cnt * b;
		} else if (cura >= a && curb <= b) {
			ll cnt = (cura + a - 1) / a;
			cura = cnt * a;
			curb = cnt * b;
		} else if (cura >= a && curb >= b) {
			ll cnt = (cura + a - 1) / a;
			if (cnt * b < curb) {
				cnt = (curb + b - 1) / b;
				cura = cnt * a;
				curb = cnt * b;
			} else {
				cura = cnt * a;
				curb = cnt * b;
			}
		}
	}
	cout << cura + curb << endl;
	return 0;
}


Measured memory_bytes: 256
char s[1001],*S="JOI";
int N,n,M[1000][8];
int dfs(d,prev){
	if(d==N)return 1;
	if(M[d][prev])return M[d][prev];
	int i=1,r=0;
	for(;i<8;i++)if((s[d]&i)&&(prev&i))r=(r+dfs(d+1,i))%10007;
	return M[d][prev]=r;
}
main(){
	scanf("%d%s",&N,s);
	for(;n<N;n++)s[n]=1<<(strchr(S,s[n])-S);
	printf("%d\n",dfs(0,1));
exit(0);}

Measured memory_bytes: 692
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d ",a);
using namespace std;
int n;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read();
	out(48-n);
}

Measured memory_bytes: 256
n=int(input())
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
c=0
for i in range(15):
  a=n
  b=0
  while a>=P[i]:
    a=a//P[i]
    b=b+a
  if b>=74:
    c=c+1
for i in range(15):
  a=n
  b=0
  while a>=P[i]:
    a=a//P[i]
    b=b+a
  if b>=24:
    d=0
    for j in range(15):
      if j==i:
        continue
      a=n
      b=0
      while a>=P[j]:
        a=a//P[j]
        b=b+a
      if b>=2:
        c=c+1
for i in range(15):
  a=n
  b=0
  while a>=P[i]:
    a=a//P[i]
    b=b+a
  if b>=14:
    d=0
    for j in range(15):
      if j==i:
        continue
      a=n
      b=0
      while a>=P[j]:
        a=a//P[j]
        b=b+a
      if b>=4:
        c=c+1
for i in range(15):
  a=n
  b=0
  while a>=P[i]:
    a=a//P[i]
    b=b+a
  if b>=4:
    d=0
    for j in range(i+1,15):
      if j==i:
        continue
      a=n
      b=0
      while a>=P[j]:
        a=a//P[j]
        b=b+a
      if b>=4:
        d=0
        for k in range(15):
          if k==i or k==j:
            continue
          a=n
          b=0
          while a>=P[k]:
            a=a//P[k]
            b=b+a
          if b>=2:
            c=c+1
print(c)

Measured memory_bytes: 3192
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int N, M;
  	cin >> N >> M;
  	int sz = 2*M;
  	vector<int> A(sz);
  	for(int i; i<sz; i+=2) {      	
      	cin >> A[i] >> A[i+1];
    }
	
  	for(int i=1;i<=N;i++){
     	 int count = 0;
      	rep(j,sz){
			if(A[j] == i){count++;}
        }
      	cout << count << endl;
    }

  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    ll n, k;
    cin >> n >> k;
    // vector<ll> arr(n+1,0);
    ll cum_sum=0, tmp;
    vector<ll> p(n+1,0);
    for(int i=1; i<=n ; i++){
        cin >> tmp;
        cum_sum += tmp;
        p[i] = (cum_sum-i)%k;
    }

    unordered_map<ll, int> hmap;
    ll ans=0;
    hmap[0]=1;
    
    for(int i=1; i<=n; i++){
        if((i-k) >= 0){
            hmap[p[i-k]]--;
            if(hmap[p[i-k]] <= 0)
                hmap.erase(p[i-k]);
        }
        ans += hmap[p[i]];
        hmap[p[i]]++;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10056
#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()
{
    string s, t;
    cin >> s >> t;
    string u = s;
    rep(i, s.size())
    {
        if (u.substr(0, s.size()) == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        char tmp = u.back();
        u.erase(u.size() - 1);
        u = tmp + u;
        // cout << u << endl;
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int n;
  string ans = "No";
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (n == i * j) {
        ans = "Yes";
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N,M;
  int tmp1, tmp2;
  vector<int> vec(N);
  
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    cin >> tmp1 >> tmp2;
    vec.at(tmp1-1) += 1;
    vec.at(tmp2-1) += 1;
  }
  
  for (int i=0; i<N; i++) {
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 24832
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

int main(){
	int N,M;
	cin>>N>>M;

	if(M<=1){
		ote(0);
		return 0;
	}

	vi X(M);
	rp(i,M)cin>>X[i];
	sort(all(X));

	// for(auto e:X){
	// 	cout<<e<<",";
	// }cout<<"\n----\n";


	vector<pair<int,int>> P;//<xi,index>
	int pre = X[0];
	rp(i,M-1){
		int now = X[i+1];
		P.emplace_back(abs(now-pre), i);
		pre = now;
	}

	// for(auto p:P){
	// 	cout<<p.first<<","<<p.second<<"\n";
	// }cout<<"----\n";

	sort(all(P));

	// for(auto p:P){
	// 	cout<<p.first<<","<<p.second<<"\n";
	// }cout<<"----\n";

	ll ans = 0;
	rp(i,M-N){
		ans += (ll)P[i].first;
	}

	ote(ans);
}


Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000];
    bool factor[1000001] = {};
    cin >> N;
    REP(i, N) cin >> A[i];
    map<int, int> checked;
    REP(i, N) {
        checked[A[i]]++;
        if (checked[A[i]] >= 2) continue;
        for (int j = A[i] * 2; j <= 1000000; j += A[i]) factor[j] = true;
    }
    int ans = 0;
    REP(i, N) {
        if (checked[A[i]] == 1 && !factor[A[i]]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14776
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

string str = "abcdefghijklmnopqrstuvwxyz";

int main(){
  
  string s;
  int K;

  cin >> s >> K;

  rep(i,s.size()){
    if(s[i] == 'a' && i != s.size()-1) continue;
    else if(i==s.size()-1){
      s[i]=str[((s[i]-'a')+K)%26];
    }
    else if(('z'+1)-s[i] <= K ){
      K-=('z'+1)-s[i];
      s[i]='a';
    } 
  }

  cout << s << endl;
}




Measured memory_bytes: 764
n = int(input())
nums = list(map(int, input().split()))
q = int(input())

total = sum(nums)

lst = [0] * 100001

for num in nums:
  lst[num] += 1

for _ in range(q):
  b, c = map(int, input().split())
  total += lst[b] * (c - b)
  lst[c] += lst[b]
  lst[b] = 0
  print(total)

Measured memory_bytes: 21060
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	P := make([]int, N)
	for i := 0; i < N; i++ {
		P[i] = nextInt()
	}
	ans := 1
	for i := 1; i < N; i++ {
		if P[i] < P[i-1] {
			ans++
		}
		P[i] = min(P[i], P[i-1])
		// log.Println(ans)
	}
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define piii pair<ll, pii>
#define MOD 1000000007
#define M 3005
#define inf 1000000001
using namespace std;
ll n;
double prob[M], dp[M][M];

void solve(){
    dp[0][0] = 1;
    for(ll i =1;i<=n;i++){ // no of coin
        for(ll j = 0;j <=i;j++){ // no of head
            if(j==0) dp[i][j] = dp[i-1][j]*(1-prob[i]);
            else dp[i][j]= dp[i-1][j-1]* prob[i] + dp[i-1][j] * (1-prob[i]);
        }//cout<< endl;
    }
    double ans=0;
    //for(ll i =1;i<=n;i++){ // no of coin
        for(ll j = 0;j <=n;j++){ // no of head
            if(j> n/2) ans = (double)ans+ dp[n][j];
        }
    //}
    cout<< setprecision(10)<< ans<< endl;
}


int main(){
    //ll t; cin>> t; while(t--){
        cin>> n;
        for(ll i =1;i<=n;i++){ // no of item
            cin>> prob[i];
        }
        solve();
}


Measured memory_bytes: 68992
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[1050][1000],mp[1050][1050];
void floyd(int n){	
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
          	for(int j=1;j<=n;j++){
            	if(dp[i][j]>dp[i][k]+dp[k][j]){
            		dp[i][j]=dp[i][k]+dp[k][j];
         		}
          	}
    	}
    }
}
void floyd2(int n){	
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
          	for(int j=1;j<=n;j++){
            	if(mp[i][j]>mp[i][k]+mp[k][j]){
            		mp[i][j]=mp[i][k]+mp[k][j];
         		}
          	}
    	}
    }
}
void solve(){
	int n,m,l,u,v,q,tmpu,tmpv,flu;
	ll ans=0;
	ll w;
	scanf("%d%d%d",&n,&m,&l);
	flu=l;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=1e18;
			if(i==j)dp[i][j]=0;
		}
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d%lld",&u,&v,&w);
		if(w>l)continue;
		dp[u][v]=w;
		dp[v][u]=w;
	}
	floyd(n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(dp[i][j]<=l)mp[i][j]=1;
			else mp[i][j]=1e18;
		}
	}
	floyd2(n);
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d %d",&u,&v);
		if(mp[u][v]==1e18){
			printf("-1\n");
			continue;
		}
		printf("%lld\n",mp[u][v]-1);
	}
}
signed main(){
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 7660
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n;cin >> n;
	bool flag = false;
	int k = 0;
	for(int i = 1;i <= n;i++){
		//cout << (ll(i)*ll(i+1)/2) << endl;
		if((ll(i)*ll(i+1)/2)==n){
			flag = true;
			k = i+1;
			break;
		}
	}
	if(!flag) {
		cout <<"No"<< endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << k << endl;

	int ans[k][k-1];
	int las = 1;
	for(int i = 0;i < k-1;i++){
		for(int j = i;j<k-1;j++){
			ans[i][j] = las;
			ans[j+1][i] = las;
			las++;
		}
	}
	rep(i,k){
		cout << k-1 << " ";
		rep(j,k-1) cout << ans[i][j] << " ";
		cout << endl;
	}

	// vector<vector<int> ans(k,vector<int>(k-1));
	// vector<int> ind(k);
	// int las = 0;
	// int m = 0;
	// while(las < n){
	// 	for(int i = 0;i < k-1-ind[m];i++){
	// 		las++;
	// 		ans[m][i+ind[m]] = las;
	// 		ans[m+1+i][ind[m+1+i]] = las;
	// 		ind[m+1+i]++;
	// 	}

	// }


	
}
 
 

Measured memory_bytes: 4144
from itertools import product

n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    a, *b = map(int, input().split())
    k.append(a)
    s.append(b)
p = list(map(int, input().split()))
print(
    sum(
        all(sum(i[b - 1] for b in a) % 2 == x for a, x in zip(s, p))
        for i in product((0, 1), repeat=n)
    )
)

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s, t;
  cin >> s >> t;
  ll ns = s.size();
  ll nt=t.size();
  ll ans = 1e18;
  for(ll i=0;i<=ns-nt;i++){
    ll tmp=0;
    rep(j, nt){
      if(s[i+j]!=t[j])tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans;
  return 0;
}


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

int main(){
    int nomal = 700;
    char e,c,n;
    cin >> e >> c >> n;
    if(e == 'o'){
        nomal += 100;
    }
    if(c == 'o'){
        nomal += 100;
    }
    if(n == 'o'){
        nomal += 100;
    }
    cout << nomal << '\n';
}

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

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

    vector<int> joshi(n + 1, 0);
    for (int i = 2; i <= n; i++)
    {
        joshi[a[i]]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << joshi[i] << endl;
    }
}


Measured memory_bytes: 4756
a=[list(map(int,input().split())) for _ in range(3)]
f=[[0]*3 for _ in range(3)]
for _ in range(int(input())):
  x=int(input())
  for i in range(3):
    for j in range(3):
      if x==a[i][j]:
        f[i][j]=1
ans=0
for i in range(3):
  if all(f[i][j] for j in range(3)) or all(f[j][i] for j in range(3)):
    ans=1
if f[0][0]==f[1][1]==f[2][2]==1 or f[0][2]==f[1][1]==f[2][0]==1:
  ans=1
print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=500010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans, sum;
string N;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>N;
	reverse(all(N));
	N+="00";
	n=N.size();
	int car=0;
	for (int i=0; i<n; i++){
		int x=(N[i]-'0')*9 + car;
		N[i]='0'+(x%10);
		sum+=(x%10);
		car=x/10;
	}
//	debug(N)
//	debug(sum)
	while (1){
		ans++;
		car=9;
		for (int i=0; i<n && car; i++){
			int x=(N[i]-'0') + car;
			sum=sum - (N[i]-'0')+ (x%10);
			N[i]='0'+(x%10);
			car=x/10;
		}
//		debug(N)
//		debug(sum)
		if (sum<=9*ans) break ;
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3868
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b){
			System.out.println("a < b");
		}
		else if(a > b){
			System.out.println("a > b");
		}
		else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26180
#include <iostream>
#include <queue>
#include <set>
#include <utility>

using namespace std;


class Solver {
  public:
    int n, k;
    int nums[10];
    int solve() {
      bool has_used[10];
      set<int> integers;
      for (int i = 0; i < n; ++i) {
        has_used[i] = false;
      }
      search(integers, has_used);
      return integers.size();
    }
  private:
    void search(set<int> &integers, bool has_used[], int x = 0, int ki = 0) {
      if (ki < k) {
        for (int ni = 0; ni < n; ++ni) {
          if (has_used[ni]) {
            continue;
          }
          has_used[ni] = true;
          if (nums[ni] < 10) {
            search(integers, has_used, 10 * x + nums[ni], ki + 1);
          } else {
            search(integers, has_used, 100 * x + nums[ni], ki + 1);
          }
          has_used[ni] = false;
        }
      } else {
        integers.insert(x);
      }
    }
};

int main() {
  Solver s;
  while (true) {
    cin >> s.n >> s.k;
    if (s.n == 0) {
      return 0;
    }
    for (int i = 0; i < s.n; ++i) {
      cin >> s.nums[i];
    }
    cout << s.solve() << endl;
  }
}

Measured memory_bytes: 1316
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if ((a==b||b==c||c==a)&&(a==5||b==5||c==5)&&(a==7||b==7||c==7)&&(a+b+c==17)) {
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


Measured memory_bytes: 128
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
    int k;
    cin >> k;
    vector<int> a(32);
    a[0]=1;
    a[1]=1;
    a[2]=1;
    a[3]=2;
    a[4]=1;
    a[5]=2;
    a[6]=1;
    a[7]=5;
    a[8]=2;
    a[9]=2;
    a[10]=1;
    a[11]=5;
    a[12]=1;
    a[13]=2;
    a[14]=1;
    a[15]=14;
    a[16]=1;
    a[17]=5;
    a[18]=1;
    a[19]=5;
    a[20]=2;
    a[21]=2;
    a[22]=1;
    a[23]=15;
    a[24]=2;
    a[25]=2;
    a[26]=5;
    a[27]=4;
    a[28]=1;
    a[29]=4;
    a[30]=1;
    a[31]=51;
    cout << a[k-1] << endl;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer x;
  x = nil->next;
  while((x != nil) && (x->key != key)) {
    x = x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  NodePointer t;
  t = listSearch(key);
  if(t == nil) return;
  else deleteNode(t);
  
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32948
#include <stdio.h>
int main(void){
    int a,b,c;    
    scanf("%d %d %d",&a,&b,&c);
    if(c>b&&b>a){ 
        printf("%d %d %d\n",a,b,c);
        }    
        if(b>c&&c>a){
            printf("%d %d %d\n",a,c,b);
            }
            if(c>a&&a>b){
                printf("%d %d %d\n",b,a,c);
                } 
                if(a>c&&c>b){
                    printf("%d %d %d\n",b,c,a); 
                    } 
                    if(a>b&&b>c){  
                        printf("%d %d %d\n",c,b,a);
                        }
                        if(b>a&&a>c){
                            printf("%d %d %d\n",c,a,b);
                            } 
                            if(c==b&&b<a){
                                printf("%d %d %d\n",b,b,a);
                                }
                                if(b==a&&a<c){
                                    printf("%d %d %d\n",a,a,c);
                                    } 
                                    if(a==c&&c<b){ 
                                        printf("%d %d %d\n",c,c,b); 
                                        }    return 0;
                                        }


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <string>

#define rep(i,n)  for(int i=0;i<n;++i)

using namespace std;

struct lit
{
	char c;
	bool is_not;
};

struct clause
{
	lit l[3];
};

typedef vector<clause> expr;

string text;
int p;

bool end() { return p >= text.length(); }
char peek() { return text[p]; }
void succ() { if (!end()) p++; }

lit parse_literal()
{
	lit l = { 0, false };
	if (peek() == '~')
	{
		succ();
		l.is_not = true;
	}
	l.c = peek();
	succ();
	return l;
}

clause parse_clause()
{
	clause c;
	if (peek() == '(') succ();
	rep(i,3)
	{
		if (i != 0 && peek() == '&') succ();
		c.l[i] = parse_literal();
	}
	if (peek() == ')') succ();
	return c;
}

expr parse_expr()
{
	p = 0;

	expr e;
	e.push_back(parse_clause());
	while (!end() && peek() == '|')
	{
		succ();
		e.push_back(parse_clause());
	}
	return e;
}

bool sat_clause(clause c)
{
	char decision[128] = { 0 };
	rep(i,3)
	{
		char v = c.l[i].c;
		char tf = c.l[i].is_not ? -1 : 1;
		if (!decision[v]) decision[v] = tf;
		else if (decision[v] != tf) return false;
	}
	return true;
}

bool sat(expr e)
{
	rep(i,e.size())
	{
		if (sat_clause(e[i])) return true;
	}
	return false;
}

int main()
{
	while(cin>>text, text != "#")
	{
		expr e = parse_expr();
		cout << (sat(e) ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 900
lines = readlines.map(&:strip)
N = lines[0].to_i
A = lines[1].split.map(&:to_i)
A.unshift(0)
A.push(0)

D = []
(0..A.length-2).each do|index|
  diff = A[index+1] - A[index]
  diff = diff*-1 if diff<0
  D.push(diff)
end

drawn_D = []
(0..A.length-3).each do|index|
  diff = A[index+2] - A[index]
  diff = diff*-1 if diff<0
  drawn_D.push(diff)
end

sum_D = D.inject(0){|memo, elem|memo+elem}

#puts D.inspect
#puts drawn_D.inspect
#puts sum_D
#puts('---')

(0..N-1).each do |index|
  puts sum_D -(D[index] + D[index+1]) + drawn_D[index]
end



Measured memory_bytes: 14092
class Union:

  def __init__(self, num):
    self.T = [-1 for i in range(num)]

  def root(self, x):
    if self.T[x] < 0: return x
    return self.root(self.T[x])

  def size(self, x):
    return -self.T[self.root(x)]

  def merge(self, x, y):
    a = self.root(x)
    b = self.root(y)
    if a == b: return False
    if self.size(a) < self.size(b): a, b = b, a
    self.T[a] += self.T[b]
    self.T[b] = a
    return True

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]

AB.reverse()

uni = Union(N + 1)
L = []
Ans = N * (N - 1) // 2
for i in AB:
  L.append(Ans)
  if uni.root(i[0]) != uni.root(i[1]):
    Ans -= uni.size(i[0]) * uni.size(i[1])
    uni.merge(i[0], i[1])

for i in L[::-1]:
  print(i)

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

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


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=505,M=10000;
int n,p[M+5],p2[M+5],mu[M+5],ps;
ll a[N][N],h[N],l[N];
bool b[M+5];
ll gcd(ll x,ll y){
	for(;y;y%=x)swap(x,y);
	return x;
}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
int main(){
	n=500;
	fo(i,2,M){
		if(!b[i])p[++ps]=i,mu[i]=1;
		for(int j=1,u;(u=i*p[j])<=M;++j){
			b[u]=1;
			if(i%p[j]==0)break;
			mu[u]=mu[i];
		}
	}
	ps=0;
	for(int i=2;i<=n+n;i+=2){
		++ps;
		fo(j,max(1,i-n),min(n,i-1)){
			int k=i-j;
			a[j][k]=p[ps];
		}
	}
	
	for(int i=n-2;i>=2-n;i-=2){
		++ps;
		fo(j,max(i+1,1),min(n,n+i)){
			int k=j-i;
			a[j][k]*=p[ps];
		}
	}
	
	fo(i,1,n)fo(j,1,n)if(i+j&1){
		a[i][j]=1;
		if(i>1)a[i][j]=lcm(a[i][j],a[i-1][j]);
		if(i<n)a[i][j]=lcm(a[i][j],a[i+1][j]);
		if(j>1)a[i][j]=lcm(a[i][j],a[i][j-1]);
		if(j<n)a[i][j]=lcm(a[i][j],a[i][j+1]);
		++a[i][j];
	}
	cin>>n;
	fo(i,1,n){
		fo(j,1,n)printf("%lld ",a[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 5248
#include <stdio.h>

int main(void){
	int a,b,c,i,ans=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b && b==c) cout<<"No"<<endl;
    else if(a!=b && b!=c && c!=a) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else if(c <= a && b <= c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double a = 0.5 * w * h;
    cout << setprecision(10) << fixed << a << " " << (2 * x == w && 2 * y == h) << endl;
    return 0;
}


Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 2;
const long long MNN = 2e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong a[MXN], k, n, sum, b[MXN], ans;
llong p[502];

bool check(llong x){
    vector<int> v;
    v.pb(0);
    llong lol = 0;
    for(int i = 1; i <= n; i++){
        p[i] = 0;
        if(a[i] % x != 0)
            v.pb(a[i] % x);
    }
    sort(v.begin(), v.end());
    for(int i = 1; i < v.size(); i++){
        p[i] = p[i - 1] + v[i];
    }
    if(v.size() == 1) return 1;
    for(int i = v.size() - 1; i > 0; i--){
        lol += (x - v[i]);
        if(lol + p[i - 1] <= 2 * k && lol == p[i - 1]){
            return 1;
        }
    }
    return 0;
}

int main () {
    ios;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(llong i = 1; i <= sqrt(sum); i++){
        if(sum % i == 0){
            if(sum / i != i){
                if(check(sum / i)){
                    ans = max(ans, sum / i);
                }
            }
            if(check(i)){
                ans = max(ans, i);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
M = 200000
UD = [[] for _ in range(2*M+10)]
RL = [[] for _ in range(2*M+10)]
RU = [[] for _ in range(2*M+10)]
RD = [[] for _ in range(2*M+10)]
LU = [[] for _ in range(2*M+10)]
LD = [[] for _ in range(2*M+10)]
for i in range(N):
    x, y, u = readline().decode().split()
    x = int(x); y = int(y)
    if u == 'R':
        RL[y].append((x,0))
        RU[x+y].append((x-y,0))
        RD[x-y+M].append((x+y,0))
    if u == 'L':
        RL[y].append((x,1))
        LU[x-y+M].append((x+y,1))
        LD[x+y].append((x-y,1))
    if u == 'U':
        UD[x].append((y,0))
        RU[x+y].append((x-y,1))
        LU[x-y+M].append((x+y,0))
    if u == 'D':
        UD[x].append((y,1))
        RD[x-y+M].append((x+y,1))
        LD[x+y].append((x-y,0))
        

def calc(X):
    dist = INF
    X = sorted(X)
    for i in range(len(X)-1):
        if X[i][1] == 0 and X[i+1][1] == 1:
            dist = min(dist,X[i+1][0]-X[i][0])
    return dist 
    
INF = 10**31 
dist = INF
for i in range(2*M+5):      
    dist = min(dist,calc(UD[i]))
    dist = min(dist,calc(RL[i]))
    dist = min(dist,calc(RU[i]))
    dist = min(dist,calc(RD[i]))
    dist = min(dist,calc(LU[i]))
    dist = min(dist,calc(LD[i]))

if dist == INF:
    print('SAFE')
else:
    print(dist*5)      


Measured memory_bytes: 228952
import Control.Monad

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ts <- getInts
  m <- (read :: String -> Int) <$> getLine
  ps <- replicateM m getInts
  --mapM_ print ps
  mapM_ print $ solve (map toPair ps) ts


getInts :: IO [Int]
getInts = map read . words <$> getLine

toPair :: [Int] ->  (Int, Int)
toPair (a:b) = (a, head b)
toPair [] = (0, 0)

solve :: [(Int, Int)] -> [Int] -> [Int]
solve ps ts = map f ps
  where
    f :: (Int, Int) -> Int
    f (a, b) = sum . concat $ [take (a - 1) ts , [b], drop a ts]


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll n,a,b,c,d;

int main()
{
	read(n,a,b,c,d); --n;
	ll hani = n*(d-c);
	for(ll i=0; i<=n; ++i){
		ll p = a + c*i - d*(n-i);
		if(p<=b && b<=p+hani){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


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

int main(){
  int k;
  string s;
  cin>>k >>s;
  if((int)s.size()<=k){
    cout<<s<<endl;
  }else{
    cout<<s.substr(0, k)<<"..."<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int X;
	bool buy[100001]={0};
	cin>>X;
	buy[0]=true;
	for(int i=100;i<=105;i++){
		for(int j=0;j<=X-i;j++){
			if(buy[j]){
				buy[j+i]=true;
			}
		}
	}
	cout<<buy[X];
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
 
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define so(v) sort(v.begin(),v.end())
#define re(s) reverse(s.begin(),s.end())
#define lb(v,a) lower_bound(v.begin(),v.end(),a)
#define ub(v,a) upper_bound(v.begin(),v.end(),a)
#define mp1(a,b,c) piii(a,pii(b,c))
 
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const ll mod=1e9+7;

int main(){

  int n,l;
  string s[200];
  cin>>n>>l;
  rep(i,n) cin>>s[i];
  for(int i=0;i<n;i++)
    for(int j=n-1;j>0;j--)
      if(s[j]<s[j-1]){
	string t;
	t=s[j];
	s[j]=s[j-1];
	s[j-1]=t;
      }
  rep(i,n) cout<<s[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    lint n,a,b;
    cin >> n >> a >> b;
    lint sum = 0;
    sum = (n / (a + b)) * a;
    lint remain = n % (a + b);
    if(remain > a)
        sum += a;
    else
        sum += remain;
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256