akhauriyash/Code-Regression huggingface dataset:
/*input
6
1 53
13 91
37 55
19 51
73 91
13 49
*/

#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      FOR(i, a, n)     for(int i = a; i < (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)

int main(void)
{
  int prime[100005];
  memset(prime, 1, sizeof(prime));
  prime[0]=0, prime[1]=0;
  for(int i=0; i<=100000; ++i){
    if(prime[i]){
        for(int j=2*i; j<=100000; j+=i) prime[j]=0;
    }
  }
  int pre[100005];
  pre[0]=0;
  for(int n=1; n<=100000; ++n){
    if(n&1 and prime[n] and prime[(n+1)/2]) pre[n]=1+pre[n-1];
    else pre[n]=pre[n-1];
  }

  int q; cin>>q;
  while(q--){
    int l, r; cin>>l>>r;
    cout<<pre[r]-pre[l-1]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    ll n, t, r;
    cin >> n >> t;
    r = t;
    vector<ll> h(n+1), ans(n+1,1), v(n+1);
    for(int i=0;i<n;i++) cin >> h[i+1];
    h[0] = IINF;
    ll hmax = 0, id = 0;
    for(int i=1;i<=n;i++){
        if(hmax <= h[i]){
            ans[i] = r/h[i]+1;
            v[i] = r-r/h[i]*h[i];
            if(hmax < h[i]){
                hmax = h[i];
                id = i;
            }
        }
        else{
            if(h[i] <= v[i-1]){
                ans[i] = ans[i-1];
                v[i] = v[i-1] - h[i];
            }
            else{
                ans[i] = ans[i-1]-1;
                v[i] = v[i-1]+hmax-h[i];
            }
        }
        r -= h[i];
        if(r <= 0) break;
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5228
W = input()
alpha = []
num = []
for char in W:
    if char in alpha:
        num[alpha.index(char)] += 1
    else:
        alpha.append(char)
        num.append(1)

ans = 'Yes'
for n in num:
    if n % 2 == 1:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int x[5];
	int i, j, t;

	scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);

	for (i = 0; i < 4; i++) {
		for (j = 4; j > i; j--) {
			if (x[j - 1] < x[j]) {
				t = x[j - 1];
				x[j - 1] = x[j];
				x[j] = t;
			}
		}
	}

	for (i = 0; i < 5; i++) {
		printf("%d", x[i]);
		if (i != 4) {
			printf(" ");
		}
	}

	printf("\n");
	
	return (0);
}

Measured memory_bytes: 600
#include <stdio.h>

 int main()
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 scanf("%d", &n);
for(i = 0; i < n; i++){
 scanf("%d", &a[i]);
 sum += a[i];
 }
 max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
 if(a[i] < min)min = a[i];
 }
 printf("%d %d %lld\n", min, max, sum);

 return 0;
 }


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


int main(){
  int N;
  vector<int> V;
  cin>>N;
  for(int i=0;i<N;i++){
    int v;
    cin>>v;
    V.push_back(v);
  }
  sort(V.begin(),V.end());
  double ans;
  ans=(V[0]+V[1])/2.0;
  //cout<<"0+1:"<<ans<<endl;
  for(int i=2;i<N;i++){
    ans=(ans+V[i])/2.0;
    //cout<<"ans+2:"<<ans<<endl;
  }
  cout<<ans<<endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
  cin >> n >> k;
  int les[n],of[k];
  for(int i=0;i<n;i++)les[i]=1;
  for(int i=0;i<k;i++){
    cin >> of[i];
    int sub[of[i]];
    for(int j=0;j<of[i];j++){
      cin >> sub[j];
      
      les[sub[j]-1]=0;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(les[i]==1)ans++;
    cerr << les[i] <<endl;
  }
  cout <<ans <<endl;
}

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

int main() {
	int h,w,n;
	cin >> h >> w >> n;
	int a = max(h,w),b = min(h,w),cnt = 0;
	for(int i = 0;i < b;i++)
	{
		if(i * a < n)
		{
			cnt++;
		}
	}
	cout << cnt <<endl;
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense
from scipy.sparse import csr_matrix

N,M,L = map(int, input().split())
V = [[ 10**12 for _ in range(N) ] for _ in range(N)]
for _ in range(M):
  a,b,c = map(int, input().split())
  a,b = a-1, b-1
  V[a][b] = c
  V[b][a] = c
  
G = csgraph_from_dense(V, null_value=10**12)
d = floyd_warshall(G)

V2 = [[ 10**9 for _ in range(N) ] for _ in range(N)]
for i in range(N):
  for j in range(N):
    if 0 < d[i][j] <= L:
      V2[i][j] = 1
      
G2 = csgraph_from_dense(V2, null_value=10**9)
d2 = floyd_warshall(G2)

Q = int(input())
for _ in range(Q):
  s,t = map(int, input().split())
  s,t = s-1, t-1
  print(int(d2[s][t])-1 if d2[s][t] < 1000 else -1)


Measured memory_bytes: 44328
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578

using namespace std;

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

    incin(n);
    Vector1 a(n);
    Rap(n,i){
        cin >> a.at(i);
    }
    sort(all(a));
    int c=0;
    int d=0;
    int ans=0;
    for(int i=0;i<n;i=i){
        c=a[i];d=0;
        while(true){
            if(a[i]==c){
                d++;
            }else{
                break;
            }
            i++;
        }
        if(d>=c){
            ans+=(d-c);
        }else{
            ans+=d;
        }
    }
    Pr(ans);
    return 0;
}


Measured memory_bytes: 1024
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 200001
#define LL long long
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n,X,Y;
bool reach[N],ok;
struct tree
{
	int dep[N],fa[N];
	int cnt,head[N],nxt[N+N],to[N+N];
	void add_edge(int u,int v)
	{
		nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v;
	}
	void dfs(int u)
	{
		for(int i=head[u],v;i;i=nxt[i])
			if((v=to[i]) != fa[u])
			{
				dep[v]=dep[u]+1;
				fa[v]=u;
				dfs(v);
			}
	}
}a,b;
bool check(int u,int v)
{
	if(b.dep[u]<b.dep[v])swap(u,v);
	if(b.fa[u]==v)return 0;
	if(b.fa[b.fa[u]]==v)return 0;
	if(b.fa[u]==b.fa[v])return 0;
	return 1;
}
void wfs(int u)
{
	reach[u]=1;
	for(int i=a.head[u],v;i;i=a.nxt[i])
		if((v=a.to[i])!=a.fa[u])
		{
			if(check(u,v))ok=1;
			if(a.dep[v]<b.dep[v])wfs(v);
		}
}
int main()
{
	re(n);re(X);re(Y);
	for(int u,v,i=1;i<n;++i)
	{
		re(u),re(v);
		a.add_edge(u,v);
		a.add_edge(v,u);
	}
	for(int u,v,i=1;i<n;++i)
	{
		re(u),re(v);
		b.add_edge(u,v);
		b.add_edge(v,u);
	}
	a.dfs(X);b.dfs(Y);
	wfs(X);
	if(ok)
	{
		puts("-1");
		return 0;
	}
	int ans=0;
	for(int i=1;i<=n;++i)
		if(reach[i])
			ans=max(ans,b.dep[i]);
	printf("%d\n",2*ans);
}

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

int main() {
 int N;

 cin >> N;
 for (int i = 1; i < 10; ++i){
   for (int j = 1; j < 10; ++j){
   
     if(i*j==N){
       	cout << "Yes" << endl; 
       	return 0;}
 }
 }
 	cout << "No" << endl; 
 }
  


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

using namespace std;

int main(){
	string s;
	int x;
	cin>>s;
	x=atoi(s.c_str());

	for(int i=x;;i++){
		
		if(i/100==(i%100)/10 && (i%100)/10==i%10){
			cout<<i<<endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
 
  ll n;
  cin>>n;
  ll arr[n];
  rep(i,0,n) cin>>arr[i];
  double s=0;
  for(int i=0;i<n;i++)
  {
    s+=1*1./arr[i];
  }
  cout<<fixed<<setprecision(10)<<1/s;


}



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

int main() {
    int64_t N;
    cin >> N;
    
    vector<int64_t> data(N + 1, 0);
    data[0] = 2;
    data[1] = 1;

    int64_t temp = 0;
    for (int i = 2; i < N + 1; i++) {
        temp = data[i - 1] + data[i - 2];
        data[i] = temp;
    
    }
    cout << data[N] << endl;
}

Measured memory_bytes: 3620
import itertools
N, M, Q = map(int, input().split())
a = [list(map(int, input().split())) for l in range(Q)]
b = [1]*N
c = 0
for i in range(Q):
  if b[a[i][1]-1]-b[a[i][0]-1] == a[i][2]:
    c += a[i][3]
C = c
for k in range(1,M):
  nums = [i for i in range(N-1)]
  for balls in itertools.combinations_with_replacement(nums, k):
    b = [1]*N
    c = 0
    for i in range(1,N):
      b[i] = b[i-1] + balls.count(i-1)
    for i in range(Q):
      if b[a[i][1]-1]-b[a[i][0]-1] == a[i][2]:
        c += a[i][3]
    C = max(C,c)
print(C)

Measured memory_bytes: 9220
#include<stdio.h>
int main(){
  int W;
  int H;
  int x;
  int y;
  int r;
  scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
  if(x - r < 0){
    printf("No\n");
  }
  else if(x + r > W){
    printf("No\n");
  }
  else if(y - r < 0){
    printf("No\n");
  }
  else if(y + r > H){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
}

  



Measured memory_bytes: 2104
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int a;
    ll b,n;
    cin>> a>> b>> n;
    ll num=n/b;
    ll y=n;
    ll ans=((a*y)/b)/1-a*((y/b)/1);
    rep2(i,num){
        ll x=b*i-1;
        ll temp=((a*x)/b)/1-a*((x/b)/1);
        ans=max(ans,temp);
    } 
    cout<<ans<<endl;
    return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vl dp(n,oo);
	dp[0] = 0;
	FOR(i,1,n) FOR(j,1,k+1) if (i >= j) {
		dp[i] = min(dp[i], dp[i-j] + abs(a[i]-a[i-j]));
	}
	cout << dp[n-1] << endl;
}



Measured memory_bytes: 1792
N = int(input())
A = map(int, input().split())

accumulated_sums = []
tmp = 0
for a in A:
    tmp += a
    accumulated_sums.append(tmp)

min_cost = 2020202020
for ac_s in accumulated_sums:
    cur_cost = abs(accumulated_sums[-1] - 2 * ac_s)
    min_cost = min(min_cost, cur_cost)

print(min_cost)

Measured memory_bytes: 27596
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int h, w;
LL max1 = 0, max2 = 0, min1 = INF, min2 = INF;
LL ans1 = INF, ans2 = INF; 
/**********************************************/

int main(){
    cin >> h >> w;
    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }
    
    FOR(i, 1, w){
        LL ax = i, ay = h, bx = w-ax, by = h/2, cx = w-ax, cy = h-by;
        if(ax > 0 && ay > 0 && bx > 0 && by > 0 && cx > 0 && cy > 0){
            max1 = max(max(ax * ay, bx * by), cx * cy);
            min1 = min(min(ax * ay, bx * by), cx * cy);
            ans1 = min(max1 - min1, ans1);
        } 
        ax = i, ay = h, bx = (w-ax)/2, by = h, cx = w-ax-bx, cy = h;
        if(ax > 0 && ay > 0 && bx > 0 && by > 0 && cx > 0 && cy > 0){
            max1 = max(max(ax * ay, bx * by), cx * cy);
            min1 = min(min(ax * ay, bx * by), cx * cy);
            ans1 = min(max1 - min1, ans1);
        }
    }
    
    FOR(i, 1, h){
        LL ax = w, ay = i, bx = w/2, by = h-ay, cx = w-bx, cy = h-ay;
        if(ax > 0 && ay > 0 && bx > 0 && by > 0 && cx > 0 && cy > 0){
            max1 = max(max(ax * ay, bx * by), cx * cy);
            min1 = min(min(ax * ay, bx * by), cx * cy);
            ans1 = min(max1 - min1, ans1);
        } 
        ax = w, ay = i, bx = w, by = (h-ay)/2, cx = w, cy = h-ay-by;
        if(ax > 0 && ay > 0 && bx > 0 && by > 0 && cx > 0 && cy > 0){
            max1 = max(max(ax * ay, bx * by), cx * cy);
            min1 = min(min(ax * ay, bx * by), cx * cy);
            ans1 = min(max1 - min1, ans1);
        }
    }
    
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string lcs(const string& s, const string& t)
{
    int n = s.size();
    int m = t.size();
    vector<vector<int> > dp(n+1, vector<int>(m+1, 0));
    vector<vector<int> > step(n+1, vector<int>(m+1, -1));
    for(int i=n; i>=0; --i){
        for(int j=m; j>=0; --j){
            if(i > 0 && j > 0 && s[i-1] == t[j-1] && dp[i][j] + 1 > dp[i-1][j-1]){
                dp[i-1][j-1] = dp[i][j] + 1;
                step[i-1][j-1] = 0;
            }
            if(i > 0 && dp[i][j] > dp[i-1][j]){
                dp[i-1][j] = dp[i][j];
                step[i-1][j] = 1;
            }
            if(j > 0 && dp[i][j] > dp[i][j-1]){
                dp[i][j-1] = dp[i][j];
                step[i][j-1] = 2;
            }
        }
    }

    string ret;
    int a = 0, b = 0;
    while(step[a][b] != -1){
        if(step[a][b] == 0){
            ret += s[a];
            ++ a;
            ++ b;
        }else if(step[a][b] == 1){
            ++ a;
        }else{
            ++ b;
        }
    }
    return ret;
}

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == "#END")
            return 0;

        string ret;
        for(unsigned i=1; i<s.size(); ++i){
            string t = lcs(s.substr(0, i), s.substr(i));
            if(t.size() > ret.size())
                ret = t;
        }

        cout << ret << endl;
    }
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i,n) {
        cin >> p[i]; 
    }

    int max = p[0];
    int count = 0;
    int min = 0;
    rep(i,n) {
        if(max >= p[i] && min <= p[i]) {
            count++;
        }
        if(max > p[i]) {
            max = p[i];
        }
        if(min > p[i]) {
            min = p[i];
        }
    }

    cout << count << endl;
}

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

int main() {
  int H,W;cin>>H>>W;
  int ans =0;
  for(int i=0;i<H;++i){
    string S;cin>>S;
    for (auto c:S) if(c=='#') ++ans;
  }
  if (ans==H+W-1)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

vector<int> xa;
long long suma[51][51][2501];   //[枚数][和]
int N, A;

int main() {
	cin >> N >> A;
	xa.resize(N);
	in(xa);
	//for (int codeb = 0; codeb < (1 << (N - N / 2)); codeb++) {
	//	int nn = 0, SS = 0;
	//	for (int n = 0; n < N - N / 2; n++) {
	//		if ((codeb >> n) & 1) {
	//			nn++;
	//			SS += xb[n];
	//		}
	//	}
	//	sumb[nn][SS]++;
	//}
	//for (int codea = 0; codea < (1 << (N / 2)); codea++) {
	//	int n = 0, S = 0;
	//	for (int c = 0; c < N / 2; c++) {
	//		if ((codea >> c) & 1) {
	//			n++;
	//			S += xa[c];
	//		}
	//	}
	//	suma[n][S]++;
	//}
	suma[0][0][0] = 1;
	for (int n = 1; n <= N; n++) {
		for (int used = 0; used <= n; used++) {
			for (int s = 0; s <= 2500; s++)suma[n][used][s] = suma[n - 1][used][s];
		}
		for (int used = 1; used <= n; used++) {
			for (int s = xa[n-1]; s <= 2500; s++) {
				suma[n][used][s] += suma[n-1][used - 1][s - xa[n-1]];
			}
		}
	}
	long long ans = 0;
	for (int n = 1; n <= N; n++) {
		ans += suma[N][n][A * n];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49152
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,q;cin >> n >> q;
  vector<int> s(n),t(n),x(n);
  rep(i,n) cin >> s[i] >> t[i] >> x[i];
  map<int,int> mp;
  vector<int> d(q);
  rep(i,q){ cin >> d[i];mp[d[i]]=i; }

  vector<pair<int,pair<int,int>>> imos;
  rep(i,n){
    imos.push_back({s[i]-x[i],{1,x[i]}});
    imos.push_back({t[i]-x[i],{0,x[i]}});
    //    cout << st << ":" << go << ":" << x[i] << "\n";
  }
  rep(i,q) imos.push_back({d[i],{2,1e+9+10}});

  sort(imos.begin(), imos.end());
  set<int> se;
  vector<int> res(q);
  rep(i,imos.size()){
    //    cout << imos[i].first << ":" << imos[i].second.first << ":" << imos[i].second.second << "\n";
    if(imos[i].second.first==1){
      se.insert(imos[i].second.second);
    }
    else if(imos[i].second.first==0){
      se.erase(imos[i].second.second);
    }
    else{
      if(se.empty()) res[mp[imos[i].first]] = -1;
      else res[mp[imos[i].first]] = *se.begin();
    }
  }

  rep(i,q) cout << res[i] << "\n";
  
  return 0;
}


Measured memory_bytes: 31720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,a,m=0;
  cin>>h>>w;
  int c[10][10];
  for(int i=0;i<10;i++)
  for(int j=0;j<10;j++) cin>>c[i][j];
  for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
        c[i][j]=min(c[i][k]+c[k][j],c[i][j]);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a;
      if(a!=-1) m+=c[a][1];
    }
  }
  cout<<m;
}

Measured memory_bytes: 256
(N,M,X),*A=$<.map{_1.split.map &:to_i}
p (0...2**N).map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}}
t.any?{_1<X}?p: c}.compact.min||-1

Measured memory_bytes: 14528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

//nCk 繰り返し高速
ll comb1(ll n, ll k) {
  ll res=1;
  if(n-k<k) {
    k=n-k;
  }
  ll k1=k;
  set<ll> al;
  for(ll i=n;i>=n-k+1;i--) {
    res=res*i;
    for(ll j=2;j<=k;j++) {
      if(al.count(j)) continue;
      if(res%j==0) {
        res/=j;
        al.insert(j);
      }
    }
  }
  return res;
}

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vec v(n);
  map<ll,ll> count;
  for(ll i=0;i<n;i++) {
    cin >> v[i];
    count[v[i]]++;
  }
  sort(v.rbegin(),v.rend());
  double sum=0;
  for(ll i=0;i<a;i++) {
    sum+=v[i]/double(a);
  }
  cout << fixed << setprecision(10) << sum << endl;
  ll ans=0;
  if(v[a-1]==v[0]) {
    for(ll i=a;i<=min(b,count[v[0]]);i++) {
      ans+=comb1(count[v[0]],i);
    }
  }
  else {
    ll temp=0;
    for(ll i=0;i<a;i++) {
      if(v[i]!=v[a-1]) temp++;
    }
    ans=comb1(count[v[a-1]],a-temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n=int(input())
a=list(map(int, input().split())) 
f=0
for i in a:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            f = 1
            break
if f == 1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;



int main()
{
  flash
  ll r;
  cin>>r;
  // cout<<setprecision(20);
   long double pi =(double)(6.28318530717958623200/2);
   //cout<<pi<<"\n";
  double circ=(double) 2*pi*r;
  printf("%.21f", circ);
  //6.28318530717958623200


}


Measured memory_bytes: 3772
prime=[2]
lst=[1]*(10**4+1) 

for i in range(3,10**4,2):
    if lst[i]:
        prime.append(i)
        token=3
        while i*token<10**4:
            if lst[i*token]: lst[i*token]=0
            token+=2

n=int(input())
sm=0
for _ in range(n):
    np=int(input())
    if np<=10**4:
        sm+=np in prime
    else :
        for p in prime:
            if np%p==0 : break
        else : sm+=1

print(sm)



Measured memory_bytes: 5704
from collections import Counter

N, K = map(int, input().split())
c = Counter(map(int, input().split()))
current_kinds = len(c.keys())
remove_ball = 0

for kind, num in sorted(c.items(), key=lambda x: x[1]):
    if current_kinds <= K:
        break
    current_kinds -= 1
    remove_ball += num
print(remove_ball)


Measured memory_bytes: 41500
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
const unsigned int M = 1000000007;
typedef long long ll;
const int mx=2e5+125;
int ar[mx],br[mx],pos[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
void solve()
{
   ll a,b;
   cin>>a>>b;
   for(int i=1; ; i++){
    ll ans=b*i;
    if(ans%a==0){
        cout<<ans<<endl;
        return;
    }
   }

}
int main()
{
    faster();
    int tc;
    tc=1;
    while(tc--)
        solve();
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;

  if (A*500<B) {
    cout << "No" << endl;
    return 0;
  }
  else{
    cout << "Yes" << endl;
    return 0;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define ll long long
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
using namespace std;
// int ans=0;

// int dp(int b[],int n)
// {
//     if(n==0) return b[0];
//     else {ans+=min(abs(b[n-1]-dp(b,n-1)),abs(b[n-1]-dp(b,n-2))); cout<<ans<<endl;return ans;}
// }

int dp1(int a[], int n,int k)
{
    int ans[n+1],l=1e9;
    ans[0]=0;
    ans[1]=abs(a[1]-a[0]);
    if(n==2) return(ans[1]);
    loop(i,0,k)
    ans[i]=abs(a[0]-a[i]);
    loop(i,k,n)
    {
        l=1e9;
       loop(j,i-k,i)
       {
           l=min(ans[j]+abs(a[j]-a[i]),l);
        //   cout<<l<<"a[i]"<<" ";
       }
       ans[i]=l;
    }
    // loop(i,0,n) cout<<ans[i]<<" ";
    // cout<<endl;
    
    return ans[n-1];
}

int32_t main()
{
   int t=1;
   //cin>>t;
   while(t--)
   {
        int n,k;
        cin>>n>>k;
        int a[n+1];
        loop(i,0,n) cin>>a[i];
        cout<<dp1(a,n,k)<<endl;
   }
    return 0;
}

Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    SP = [input().split() for _ in range(N)]

    SP = enumerate(SP)
    SP = sorted(SP, key=lambda x: (x[1][0], -int(x[1][1])))
    for i in SP:
        print(i[0]+1)    

if __name__ == '__main__':
    resolve()


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

int main()
{
    int d,sum;
    while( cin >> d ) {
      sum = 0;
      for(int i = 1;i < 600/d;i++){
        sum += (i*d)*(i*d)*d;
      }
      cout << sum << endl;
    }
    return 0;
}

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

typedef long long ll;

ll a, b, c, d;

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

bool solve(ll a, ll b, ll c, ll d){
    if(d < b || a < b) return false;
    if(c >= b) return true;
    ll g = gcd(b, d);
    ll rem = g - a % g;
    return (b - c) <= rem;
}

int main(){
    int T;
    cin >> T;
    while(T--){
        cin >> a >> b >> c >> d;
        if(solve(a, b, c, d)) printf("Yes\n");
        else printf("No\n");
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, d;
  //string a, b;
  cin >> a >> b;
  
  int ans = 0;
  //string ans = "Hello World";
  ans = a * a * a;

  //cout << ans << endl;
  cout << a * b << " " << 2 * (a + b) << endl;
}


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

using namespace std;

const int MOD = 1e9+7;

inline long long qpow(long long a, int p)
{
    long long res = 1;
    while (p) {
        if (p&1) res = res*a%MOD;
        a = a*a%MOD;
        p >>= 1;
    }
    return res;
}

inline long long C(int p, int q)
{
    long long res = 1;
    for (int i = p-q+1; i <= p; ++i)
        res = res*i%MOD;
    for (int i = 2; i <= q; ++i)
        res = res*qpow(i, MOD-2)%MOD;
    return res;
}

int main()
{
    int x, y;
    cin >> x >> y;
    for (int i = 0, j; i <= x && 2*i <= y; ++i) {
        // i (1, 2)
        j = y-2*i;
        if (2*j+i == x) {
            cout << C(i+j, min(i, j)) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        s[i]='x';
    }
    cout << s << endl;
    return 0;
}


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

inline void Yes(){
    cout << "Yes" << "\n";
}
inline void No(){
    cout << "No" << "\n";
}
typedef pair<int,int> P;

int main(){
    int h,n;
    cin >> h >> n;
    int sum=0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
    }
    if (h > sum) No();
    else Yes();
}

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

int main(){ 
int n,k,q;
cin>>n>>k>>q;
vector<int> ans(n);
for(int i=0; i<n; i++){
ans[i]=k-q;
}
vector<int> a(q);
for(int i=0; i<q; i++){
cin>>a[i];
}

for(int i=0; i<q; i++){
  ans[a[i]-1]++;
}
for(int i=0; i<n; i++){
  if(ans[i]>0){
    cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}
}


Measured memory_bytes: 1408
d,n = map(int,input().split())
if n == 100:
    if d == 0:
        print(101)
    elif d == 1:
        print(10100)
    elif d == 2:
        print(101*10000)
else:
    if d == 0:
        print(n)
    elif d == 1:
        print(n*100)
    elif d == 2:
        print(n*10000)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int A[100001] = {};
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		A[a] ^= 1;
		A[b] ^= 1;
	}
	int ikeru = 1;
	rep1(i, N) if (A[i]) ikeru = 0;
	
	if (ikeru) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 640
#include<iostream>

const int MAX_N = 100;
//memo[i][j][k]: i日目jをk+1日続けた総数
int memo[MAX_N+1][3][2], plan[MAX_N+1];

void pass(int day, int source){
	if(source != -1){
		memo[day][source][1] = memo[day-1][source][0];

		for(int j=0;j<3;j++){
			if(j != source){
				memo[day][source][0] += memo[day-1][j][0];
				memo[day][source][0] += memo[day-1][j][1];
				memo[day][source][0] %= 10000;
			}
		}
	}
}

int main(){
	int n, k;

	std::cin >> n >> k;

	std::fill(plan, plan+MAX_N+1, -1);

	for(int i=0;i<=MAX_N;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<2;k++){
				memo[i][j][k] = 0;
			}
		}
	}

	// a, b; a日目はbですよー
	for(int i=0;i<k;i++){
		int a, b;
		std::cin >> a >> b;
		plan[a] = b-1;
	}
	
	if(plan[1] != -1){
		memo[1][plan[1]][0] = 1;
	}else{
		memo[1][0][0] = 1;
		memo[1][1][0] = 1;
		memo[1][2][0] = 1;
	}

	for(int day=2;day<=n;day++){
		if(plan[day] != -1){//決まっている
			pass(day, plan[day]);
		}else{//決まっていない
			for(int source=0;source<3;source++){
				pass(day, source);
			}
		}
	}

	int res = 0;
	for(int i=0;i<3;i++){
		for(int j=0;j<2;j++){
			res += memo[n][i][j];
			res %= 10000;
		}
	}

	std::cout << res << std::endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int H, W;
	cin >> H >> W;

	vector<vector<int>> a(H, vector<int>(W, 0));
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> a[i][j];

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

	vector<int> hist(H*W, -1);
	for(int i=0; i<H; i++){
		for(int j=0; j<W-1; j++){
			if(a[i][j]%2 == 0)
				continue;

			a[i][j]--;
			a[i][j+1]++;
			hist[i*W+j] = i*W + j+1;
		}
		if(a[i][W-1]%2 == 1 && i+1<H){
			a[i][W-1]--;
			a[i+1][W-1]++;
			hist[i*W+W-1] = (i+1)*W + W-1;
		}
	}

	int cnt = H*W - count(hist.begin(), hist.end(), -1);
	cout << cnt << endl;

	int n, x, y;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			n = hist[i*W+j];
			if(n == -1)
				continue;

			y = n / W + 1;
			x = n % W + 1;
			cout << i+1 << " " << j+1 << " " << y << " " << x << endl;
		}
	}

	//cnt = 0;
	//for(int i=0; i<H; i++)
	//	for(int j=0; j<W; j++)
	//		cnt += a[i][j]%2;
	//cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

// const i64 INF = 1e18;
const int INF = 2e9;
const i64 M = 1e9 + 7;
const int MXB = 20;
using bin = bitset<MXB + 1>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    int n, t;
    while (read(n, t)) {
        ivec a(n);
        read(a);
        ivec ma(n + 1, INF);
        forn(i, n) {
            ma[i + 1] = min(ma[i], a[i]);
        }

        map<int, int> cc;
        forn(i, n) {
            int mn = ma[i];
            if (a[i] > mn) {
                cc[a[i] - mn]++;
            }
        }

        cout << cc.rbegin()->second << endl;
    }
}

Measured memory_bytes: 8764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
typedef pair<int,int> pii;
int n;
pii p[51];
int ans=51;
int f[51],A,B;
map<pii,int> id;
int dfs(int x)
{
	if(f[x]!=-1)
		return f[x];
	int& res=f[x];
	res=0;
	if(id.find(make_pair(p[x].first-A,p[x].second-B))!=id.end())
	{
		int y=id[make_pair(p[x].first-A,p[x].second-B)];
		if(f[y]!=-1)
			return 0;
		else
		{
			res=0;
			return dfs(y);
		}
	}
	return res=1;
}
void solve(int a,int b)
{
	if(a==-3 && b==-2)
	{
		int d=1;
	}
	A=a,B=b;
	int res=0;
	memset(f,-1,sizeof f);
	for(int i=1;i<=n;++i)
		if(f[i]==-1)
			res+=dfs(i);
	ans=min(ans,res);
}
int main()
{
	n=read();
	if(n==1)
	{
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		p[i].first=read();
		p[i].second=read();
		id[p[i]]=i;
	}	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(i!=j)
				solve(p[i].first-p[j].first,p[i].second-p[j].second);
	cout<<ans<<endl;
	return 0;
}


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

int64_t r(int N, vector<int64_t> &R) {
  if (N == 0) return 2;
  else if (N == 1) return 1;
  else if (R[N] == 0) R[N] = r(N - 1, R) + r(N - 2, R);
  else return R[N];
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> R(N + 1);
  R[0] = 2;
  R[1] = 1;
  cout << r(N, R) << endl;
}

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

int X,Y,Z;
ll K, A[1100],B[1100],C[1100];


int main(){
    cin >> X >> Y >> Z >> K;
    REP(i,X) cin >> A[i];
    REP(i,Y) cin >> B[i];
    REP(i,Z) cin >> C[i];

    // 最悪　X * Y ()= 1000 * 1000) + (sort = log 1000 * 1000)
    vector<ll> v1(X*Y);
    REP(i,X){
        REP(j,Y){
            v1.push_back(A[i]+B[j]);
        }
    }
    sort(v1.begin(),v1.end(),greater<ll>());

    // 最悪 K * Z ()= 3000 * 1000) + sort (= log 3000 * 1000)
    vector<ll> v2(K*Z);
    REP(i,K){
        REP(j,Z){
            v2.push_back(v1[i]+C[j]);
        }
    }
    sort(v2.begin(),v2.end(),greater<ll>());
    REP(i,K) cout << v2[i] << endl;

    return 0;
}



Measured memory_bytes: 64760
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};


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

	int n,m;
	cin >> n >> m;
	
	vector<int> es[n];
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
	}

	int d[n];
	d[0]=0;
	for(int i=1;i<n;i++) d[i] = INF;
	
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,0));
	while(!que.empty()){
		P tmp = que.top(); que.pop();
		int cost=tmp.first,t=tmp.second;
		if(d[t] < cost) continue;
		for(int i=0;i<es[t].size();i++){
			int e=es[t][i];
			if(d[e] > cost+1){
				d[e] = cost+1;
				que.push(P(d[e],e));
			}
		}
	}
	cout << (d[n-1]<=2?"":"IM") << "POSSIBLE\n";

	return 0;
}

Measured memory_bytes: 10360
#include <stdio.h>


int main(void)
{	
	int a, b;
	char ch;
	for( ; ; ){
		scanf(" %d %c %d", &a, &ch, &b );
		if(ch == '?') break;
		
		switch (ch)
		{
			case '+':
				printf("%d\n", a + b );
				break;
			case '-':
				printf("%d\n", a - b );
				break;
			case '*':	
				printf("%d\n", a * b );			
				break;
			case '/':
				printf("%d\n", a / b );
				break;
		}
	
	}
	
	
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 600
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		dp[0]=1e9;
		fn1{
			cin >> ar[i];
			dp[i] = min(dp[i-1],ar[i]);
		}
		int ans=0;
		map<int,int>mp;
		fn1{
			mp[dp[i]]++;
		}
		ans= mp.size();
		cout<<ans;
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 18432
n= int(input())
ac=str("AC x")
wa=str("WA x")
tle=str("TLE x")
re=str("RE x")
a=0;b=0;c=0;d=0
for i in range(n):
    p=input()
    if(p=="AC"):
        a+=1
    if(p=="WA"):
        b+=1
    if (p == "TLE"):
        c += 1
    if (p == "RE"):
        d += 1
print(ac,a)
print(wa,b)
print(tle,c)
print(re,d)

Measured memory_bytes: 9224
<?php

class Scanner
{
  private $arr = [];
  private $count = 0;
  private $pointer = 0;

  public function next()
  {
    if ($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    ++$this->pointer;

    return $result;
  }

  public function hasNext()
  {
    return $this->pointer < $this->count;
  }

  public function nextInt()
  {
    return (int) $this->next();
  }

  public function nextDouble()
  {
    return (float) $this->next();
  }
}

$sc = new Scanner();
$n = $sc->nextInt();
$k = $sc->nextInt();
$sum = 0;

for($i=0;$i<$n;$i++){
  $array[] = $sc->nextInt();
}

foreach($array as $key=>$value){
  $dev_one = $value;
  $dev_two = $k - $value;
  $sum += min($dev_one, $dev_two)*2;
}

echo $sum . PHP_EOL;


Measured memory_bytes: 16232
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

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

int main(){
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    LL e = c * d / gcd(c, d);
    LL k = (b/c - (a-1)/c) + (b/d - (a-1)/d) - (b/e - (a-1)/e);
    LL ans = (b+1-a) - k;
    cout << ans << endl;
    return 0;
}



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

int N;

int X[31],Y[31],R[31],C[31];

bool overlap(int a,int b){
    int x=X[a]-X[b];
    int y=Y[a]-Y[b];
    int r=x*x+y*y;
    if(r<(R[a]+R[b])*(R[a]+R[b])) return true;
    else return false;
}

int dp[(1<<24)];

int rec(int state){
    if(dp[state]>0) return dp[state];
    vector<int> col[5];
    for(int i=0;i<N;i++){
        if((state&(1<<i))==0) continue;
        bool ok=true;
        for(int j=0;j<i;j++){
            if((state&(1<<j))==0) continue;
            if(overlap(i,j)){
                ok=false;
                break;
            }
        }
        if(ok) col[C[i]].push_back(i);
    }

    int res=0;
    for(int i=1;i<=4;i++){
        for(int j=0;j<col[i].size();j++){
            for(int k=j+1;k<col[i].size();k++){
                int nstate=state^(1<<col[i][j]);
                nstate^=(1<<col[i][k]);
                res=max(res,rec(nstate)+2);
            }
        }
    }
    return dp[state]=res;
}

void solve(){
    for(int i=0;i<(1<<N);i++) dp[i]=0;
    for(int i=0;i<N;i++) cin>>X[i]>>Y[i]>>R[i]>>C[i];

    cout<<rec((1<<N)-1)<<endl;
}

int main(){
  while(1){
      cin>>N;
      if(N==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 68584