akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int a,b,c,d,e;
    cin >> a>>b>>c>>d>>e;
    int ans =0;
    if(a==0)
    {
        ans = 1;
    }
    if(b==0)
    {
        ans = 2;
    }
    if(c==0)
    {
        ans = 3;
    }
    if(d==0)
    {
        ans = 4;
    }
    if(e==0)
    {
        ans = 5;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

using namespace std;
typedef long long ll;
const int maxn = 205;

int n;
int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int ret = 0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x<a[i])ret+=a[i]-x;
  }
  cout<<ret<<endl;
  return 0;
}

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

int main()
{
    int x;
    cin >> x;
    if(400<=x && x<=599){
        cout << 8 << endl;
    }else if(600<=x && x<=799){
        cout << 7 << endl;
    }else if(800<=x && x<=999){
        cout << 6 << endl;
    }else if(1000<=x && x<=1199){
        cout << 5 << endl;
    }else if(1200<=x && x<=1399){
        cout << 4 << endl;
    }else if(1400<=x && x<=1599){
        cout << 3 << endl;
    }else if(1600<=x && x<=1799){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
int tb[7] = { 0, 30, 60, 90, 120, 150, 180 };
int rb[6] = { 0, 100, 200, 300, 400, 500 };

int main(){
	cin >> n;
	REP(i, n){
		vector<int> ans, rr, tt;
		int r, t;
		cin >> r >> t;
		REP(j, 6){
			if (rb[j] == r){
				rr.push_back(j);
			}
			else if (j != 6 - 1){
				if (rb[j]<r&&rb[j + 1]>r){
					rr.push_back(j);
					rr.push_back(j + 1);
				}
			}
		}
		REP(j, 7){
			if (tb[j] == t){
				tt.push_back(j);
			}
			else if (j != 7 - 1){
				if (tb[j]<t&&tb[j + 1]>t){
					tt.push_back(j);
					tt.push_back(j + 1);
				}
			}
		}
		REP(j, rr.size()){
			REP(k, tt.size()){
				ans.push_back(rr[j] + tt[k] * 5);
			}
		}
		sort(ALL(ans));
		REP(j, ans.size()){
			if (j == 0)cout << ans[j];
			else cout << " " << ans[j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,k);
    vector<int> vec(n);
    set<int> kind;
    in(vec);
    sort(all(vec));
    int ggcd=vec[0];
    kind.insert(vec[0]);
    for(int i=1;i<n;i++){
        ggcd=__gcd(ggcd,vec[i]);
        kind.insert(vec[i]);
    }
    if(ggcd==1||kind.count(k)||(k<=vec[n-1]&&k%ggcd==0))out("POSSIBLE");
    else out("IMPOSSIBLE");
}

Measured memory_bytes: 8312
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

typedef pair<int,int> P;

int n;
int h[16],w[16];
int b[16][3][8][8],b2[16][3][8][8];
bool closed[1<<16];
char t[10][10],ch[]="RGB";

void show(int bit){
  rep(i,16){
    if(bit & (1<<i)){
      cout<<1;
    }
    else{
      cout<<0;
    }
  }
  cout<<endl;
}

void solve(){
  queue<P> open;
  memset(closed,0,sizeof(closed));
  open.push(P(0,0));
  closed[0] = true;

  while(!open.empty()){
    P p = open.front(); open.pop();

    if(p.second == (1<<16)-1){
      printf("%d\n",p.first);
      return;
    }

    rep(k,n){
      rep(color,3){
        REP(si,-h[k]+1,4){
          REP(sj,-w[k]+1,4){
            int bit = p.second;
            bit |= b[k][color][si+4][sj+4];
            bit -= (bit & b2[k][color][si+4][sj+4]);

            if(!closed[bit]){
              closed[bit] = true;
              open.push(P(p.first+1,bit));
            }
          }
        }
      }
    }
  }

  printf("-1\n");
}

int main(void){
  while(scanf("%d",&n) != EOF){
    rep(i,n){
      scanf("%d%d",&h[i],&w[i]);
    }

    rep(i,4){
      scanf("%s",t[i]);
    }

    rep(k,n){
      rep(color,3){
        REP(si,-h[k]+1,4){
          REP(sj,-w[k]+1,4){
            int bit = 0;
            int bit2 = 0;

            REP(i,si,si+h[k]){
              REP(j,sj,sj+w[k]){
                if(i < 0 || j < 0 || 4 <= i || 4 <= j) continue;

                int tmpBit = (1<<(i*4+j));
                if(t[i][j] == ch[color]){
                  bit |= tmpBit;
                }
                else{
                  bit2 |= tmpBit;
                }
              }
            }

            b[k][color][si+4][sj+4] = bit;
            b2[k][color][si+4][sj+4] = bit2;
          }
        }
      }
    }

    solve();
  }
}

Measured memory_bytes: 1228
#include<stdio.h>
int main()
{
    char s[101];
    scanf("%s",&s);
    int i=0;
    while (s[i]!='\0')
    {
        if(((i%2==0)&&(s[i]=='L'))||((i%2==1)&&(s[i]=='R')))
        {
            printf("No");
            return 0;
        }
        i++;
    }
    printf("Yes");
    return 0;
}

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

using namespace std;

typedef long long LL;

LL dp[2][2];

int main(){
	int n, p;
	scanf("%d%d", &n, &p);
	dp[0][0] = 1;

	int pv = 0;
	int cur = 1;

	for(int i=0;i<n;i++){
		int a;
		scanf("%d", &a);
		a %= 2;

		memset(dp[cur], 0, sizeof(dp[cur]));

		for(int j=0;j<2;j++){
			int nt = (j+a)%2;
			dp[cur][nt] += dp[pv][j];
		}

		for(int j=0;j<2;j++) dp[cur][j] += dp[pv][j];

		if(i != n-1) swap(pv, cur);
	}

	printf("%lld\n", dp[cur][p]);
}

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

int main(){
  vector<ll>factorial(100000);
  factorial.at(0)=1;
  
  for(int i=1;i<100000;i++){
    factorial.at(i)=factorial.at(i-1)*(i+1)%mod;
  }
  
  ll M,N; cin>>M>>N;
  ll d=abs(M-N);
  
  if(d>1)
    cout<<0;
  else if(d==1)
    cout<<factorial.at(M-1)*factorial.at(N-1)%mod;
  else if(d==0)
    cout<<2*factorial.at(M-1)*factorial.at(N-1)%mod;
}

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

int main() {
    string s[3];
    string ans = "";
    cin >> s[0] >> s[1] >> s[2];
    ans = s[0][0] - ('a' - 'A');
    ans += s[1][0] - ('a' - 'A');
    ans += s[2][0] - ('a' - 'A');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main (void) {
  string s, t; cin >> s >> t;
  int w = t.length(), ans = INT_MAX;
  for (int i = 0;i + w <= (int)s.length();i++) {
    int count = 0;
    for (int j = i;j < i + w;j++) {
      if (s[j] != t[j - i]) count++;
    }
    ans = min(ans, count);
  }
 
  cout << ans << '\n';
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000
struct Card{
	char suit;
	int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card A[],int n,int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1].value=SENTINEL;
	R[n2].value=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i].value<=R[j].value){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
		}
	}
}
void mergeSort(struct Card A[],int n,int left,int right){
	int mid;
	if(left+1<right){
		mid = (left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right); 
	}
}
int partition(struct Card A[],int p,int r){
	int i,j;
	struct Card x,t;
	x = A[r];
	i = p - 1;
	for(j=p;j<r;j++){
		if(A[j].value<=x.value){
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i+1]; A[i+1] = A[r]; A[r] = t;
	return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
	int q;
	if(p<r){
		q = partition(A,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}
int main(){
	int n,i,v;
	struct Card A[MAX],B[MAX];
	char S[10];
	int stable = 1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S>>v;
		A[i].suit=B[i].suit=S[0];
		A[i].value=B[i].value=v;
	}
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	for(int i=0;i<n;i++){
		if(A[i].suit!=B[i].suit){
			stable = 0;
			break;
		}	
	}
	if(stable == 1)
		cout<<"Stable"<<endl;
	else{
		cout<<"Not stable"<<endl; 
	} 
	for(int i=0;i<n;i++){
		//cout<<A[i].suit<<" "<<A[i].value<<" ";
		cout<<B[i].suit<<" "<<B[i].value<<endl;
	}
	return 0;
}


Measured memory_bytes: 5428
#include <stdio.h>
#include <ctype.h>

int main(void){
    // Your code here!
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    
    if (a == 0) printf("1");
    else if (b == 0) printf("2");
    else if (c == 0) printf("3");
    else if (d == 0) printf("4");
    else printf("5");
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
        int n,q;
        cin>>n>>q;
        vector<int> a(n);
        vector<ll> x(q);
        rep(i,n)cin>>a[i];
        rep(j,q)cin>>x[j];
        rep(i,q){
            ll query=x[i];
            ll res=0;
            int right=0;
            ll sum=0;
            for(int left=0;left<n;left++){
                while(right<n&&sum+a[right]<=query){
                    sum+=a[right]; right++;
                }
                res+=(right-left);
                if(left==right)right++;
                else sum-=a[left];
            }
            cout<<res<<endl;
        }
    return 0;
}





Measured memory_bytes: 3336
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int A,B;
  cin >> A >> B;

  int now=1;
  int i=0;
  while(1){
    if(B<=now) break;
    ++i;
    now=now-1+A;
  }

  cout << i << endl;
  
  return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;  // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {  // d で divide できるか
                can2 = true;
                i += d.size();  // divide できたら i を進める
            }
        }
        if (!can2) {  // divide できなかったら
            can = false;
            break;
        }
    }

    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll n;
    scanf("%lld", &n);
    vector< vector<ll> > d(n, vector<ll>(3)), dp(n, vector<ll>(3));
    for (ll i = 0; i < n; ++i) for (ll j = 0; j < 3; ++j) scanf("%lld", d.at(i).begin() + j);
    dp.front() = d.front();
    for (ll i = 1; i < n; ++i) for (ll j = 0; j < 3; ++j) for (ll k = 0; k < 3; ++k) {
        if (j == k) continue;
        dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i - 1).at(k) + d.at(i).at(j));
    }
    printf("%lld\n", *max_element(dp.back().begin(), dp.back().end()));
    return 0;
}


Measured memory_bytes: 11136
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
using namespace std;

struct edge {
	int from, to, cost;
	bool operator>(const edge& other) const{
		return cost > other.cost;
	}
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cost) {
	g[from].push_back(edge{ from,to,cost });
	g[to].push_back(edge{ to,from,cost });
}

edges prim(const graph& g)
{
	const int N = g.size();
	
	vector<bool>visited(N,false);
	visited[0] = true;
	priority_queue<edge,vector<edge>,greater<edge>>p_que;
	edges mst;
	for (auto e : g[0]) {
		p_que.push(e);
	}
	while (!p_que.empty()) {
		auto e = p_que.top();
		p_que.pop();
		if (visited[e.to]) {
			continue;
		}
		mst.push_back(e);
		visited[e.to] = true;
		for (auto new_e : g[e.to]) {
			p_que.push(new_e);
		}
	}
	return mst;
}

int main() {
	int V, E;
	cin >> V >> E;
	graph g(V);
	for (int i = 0; i < E; i++) {
		int from, to, cost;
		cin >> from >> to >> cost;
		add_edge(g, from, to, cost);
	}
	const auto mst = prim(g);
	int ans = 0;
	for (auto e : mst) {
		ans += e.cost;
	}
	cout << ans << endl;
	return 0;
}






















Measured memory_bytes: 10172
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val set = mutableSetOf<Pair<Int,Int>>()
    val a = readLine()!!.split(' ').map { it.toInt() }
    println(a.withIndex().count {
        val idx = it.index + 1
        val value = it.value
        val p = Pair(Math.min(idx, value), Math.max(idx, value))
        if (set.contains(p)) {
            true
        } else {
            set.add(p)
            false
        }
    })
}

Measured memory_bytes: 59804
N,T=map(int,input().split())
cost=10**3
ans=0
for i in range(N):
  c,t=map(int,input().split())
  if t<=T:
    if c<=cost:
      cost=c
      ans=i+1
if ans==0:
  print("TLE")
else:
  print(cost)

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    i64 N, K;
    cin >> N >> K;
    auto rem = N % K;
    auto ans = min(rem, abs(K - rem));
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#include<iomanip>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
double arr[200010]; 
double brr[200010];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		double a;
		cin>>a;
		arr[i]=(a+1)/2;
		brr[i+1]=brr[i]+arr[i];
	}
	double maxn=0;
	for(int i=0;i<=n-k;i++){
		maxn=max(brr[i+k]-brr[i],maxn);
	}
	pf("%.8lf",maxn);
	
}


Measured memory_bytes: 3328
def main():
    s = input()
    mudancas=0;
    mudancasn=0;
    s=list(s)
    n=[]
    for i in range(0, len(s)):
        n.append(s[len(s)-1-i])
    
    if(len(s)==1):
        print("0")
        return;

    for i in range(1, len(s)):
        if(s[i]==s[i-1]):
            mudancas+=1
            if(s[i]=='0'):
                s[i]='1'
            else:
                s[i]='0'

        if(n[i]==n[i-1]):
            mudancasn+=1
            if(n[i]=='0'):
                n[i]='1'
            else:
                n[i]='0'

    if(mudancas>mudancasn):
        print(mudancasn)
    else:
        print(mudancas)
        
    return 0
    
main()


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int INF = 1e9+10;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int q;
    cin >> q;
    vector<int> v(q);
    vector<int> d(q);
    vector<int> c(q);
    for(int i = 0; i < q; i++)
    {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    vector<int> dis(n, -1);
    vector<int> color(n, 0);
    function<void(int, int, int)> dfs = [&](int v, int d, int c)
    {
        if(color[v] == 0) color[v] = c;
        dis[v] = d;
        if(d == 0) return;
        d--;
        for(int nx : g[v])
        {
            if(dis[nx] < d) dfs(nx, d, c);
        }
    };
    for(int i = q-1; i >= 0; i--)
    {
        if(dis[v[i]] < d[i]) dfs(v[i], d[i], c[i]);
    }
    for(int col : color)
    {
        cout << col << endl;
    }
}


Measured memory_bytes: 11056
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b >> c >> k;
  while (1) {
    if (a < b) break;
    b *= 2;
    cnt++;
  }
  while (1) {
    if (b < c) break;
    c *= 2;
    cnt++;
  }
  k -= cnt;
  if (k >= 0)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <functional>
#include <algorithm>
#include <string>
#include <cassert>

using namespace std;

int parse_impl(string::const_iterator &begin, string::const_iterator end) {
	assert(*begin == '[');
	begin++;
	if (*begin == '[') {
		vector<int> nodes;
		do {
			nodes.push_back(parse_impl(begin, end));
		} while (*begin != ']');
		begin++;
		std::sort(nodes.begin(), nodes.end());
		int min_win = 0;
		for (int i = 0; i < nodes.size() / 2 + 1; i++) {
			min_win += nodes[i];
		}
		return { min_win };
	}
	else {
		int value = 0;
		do {
			value *= 10;
			value += *begin - '0';
			begin++;
		} while (*begin != ']');
		begin++;
		return { value / 2 + 1 };
	}
}

int parse(string line) {
	auto it = line.cbegin();
	return parse_impl(it, line.end());
}

void solve() {
	string line;
	cin >> line;
	cout << parse(line) << endl;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		solve();
	}
}

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

ll A, B, N;

int main(){
  cin >> A >> B >> N;

  if(N < B) cout << (A * N) / B - A * (N / B) << endl;
  else if(N >= B) cout << (A * (B-1)) / B << endl;
  return 0;
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s[6] >= '5' || s[5] == '1')
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
#define F first
#define S second
signed main() {
	int n, ans = 0; cin >> n;
	pair<int, int>r[110], b[110];
	bool r_[110];

	for (int i = 0; i < n; i++)cin >> r[i].F >> r[i].S; sort(r, r + n);
	for (int i = 0; i < n; i++)cin >> b[i].F >> b[i].S; sort(b, b + n);
	for (int i = 0; i < n; i++)r_[i] = 0;

	for (int i = 0; i < n; i++) {
		int k = -1, j = 0;
		for (int j = 0; j < n&&r[j].F < b[i].F; j++) {
			if (!r_[j] && r[j].S < b[i].S) {
				if (k < 0)k = j;
				else {
					if (r[k].S < r[j].S)k = j;
				}
			}
		}
		if (k >= 0) {
			r_[k] = 1; ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
int main(void){
int n;
int max;
int num;
int a[103];
int alice=0,bob=0;
scanf("%d",&n);
for(int count=0;count<n;count++){
scanf("%d",&a[count]);
}




for(int count=0;count<n;count++){
    max=0;
    for(int count2=0;count2<n;count2++){
        if(max<=a[count2]){max=a[count2];num=count2;}
    }
    if(count%2==0){alice=alice+max;a[num]=-999;}
    else{bob=bob+max;a[num]=-999;}
}
printf("%d",abs(alice-bob));

}

Measured memory_bytes: 128
import numpy as np
from collections import Counter
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N = int(input())
A = np.array([0] + list(map(int, input().split())))

A_cum = A.cumsum()
c = Counter(A_cum)
answer = 0
for k, v in c.items():
    if v >= 2:
        answer += combinations_count(v, 2)
print(answer)

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

using namespace std;

int main()
{
    long long a,b,n,x,sum1;
    cin>>a>>b>>n;
    if(n>b-1)
        x=b-1;
    else
        x=n;
    sum1=floor(a*x/b)-a*floor(x/b);
    cout<<sum1;
}


Measured memory_bytes: 3592
list_1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

s = int(input())
print(list_1[s-1])

Measured memory_bytes: 3060
n, k = gets.chomp.split(" ").map(&:to_i)
pd = []

n.times do
	a, b = gets.chomp.split(" ").map(&:to_i)
	pd[a] ||= 0
	pd[a] += b
end

pd.each_with_index do |b, a|
	next unless b
	
	if k <= b
		puts a
		break
	end
	
	k -= b
end

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

set<int> s;
int n;

int main() {
#ifdef HOME
	freopen("agc85b.in", "r", stdin);
	freopen("agc85b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int t, i = 0; i < n; ++i) {
		cin >> t;
		s.insert(t); }

	cout << s.size() << endl;

	return 0; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,y,z,k;
long long cnt,cnt2;
long long a[10005],b[10005],c[10005],w[10000005],p[10000005];
bool cmp(long long x,long long y) {
	return x>y; 
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	cout.tie();
	cin>>x>>y>>z>>k;
	for (long long i=1;i<=x;++i) cin>>a[i];
	for (long long i=1;i<=y;++i) cin>>b[i];
	for (long long i=1;i<=z;++i) cin>>c[i];
	for (long long i=1;i<=x;++i) {
		for (long long j=1;j<=y;++j) {
			w[++cnt]=a[i]+b[j];
		}
	}
	sort(w+1,w+cnt+1,cmp);
	for (long long i=1;i<=min(k,cnt);++i) {
		for (long long j=1;j<=min(k,z);++j) {
			p[++cnt2]=w[i]+c[j];
		}
	}
	sort(p+1,p+cnt2+1,cmp);
	for (long long i=1;i<=k;++i) cout<<p[i]<<endl;
	return 0;
}

Measured memory_bytes: 33152
from collections import deque
n,q = map(int,input().split())
ki = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
score = [0 for i in range(n)]

for i in range(q):
    p,x = map(int,input().split()) 
    score[p-1] += x

#print(ki,score)
ans = [0 for i in range(n)]

ans[0] = score[0]
visited = [False]*n
visited[0] = True
Q = deque([0])

while Q:
    d = Q.pop()
    #print(d)
    for to in ki[d]:
        if visited[to]:
            continue
        
        ans[to] = ans[d] + score[to]
        #print(ans[to],ans[d],score[to],d)
        visited[to] = True
        Q.append(to)
print(*ans)

Measured memory_bytes: 62732
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
int dp[M][N];

signed main()
{
    Arena
    
    int n,W;
    cin>>n>>W;
    int w[n+1],v[n+1],i,j;
    for(i=1;i<=n;++i)
        cin>>w[i]>>v[i];
    
    int ma=0;
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=W;++j)
        {
            dp[i][j]=max({dp[i-1][j], dp[i][j], j>=w[i] ? dp[i-1][j-w[i]]+v[i]:0});
            ma=max(ma,dp[i][j]);
        }   
    }
    cout<<ma<<'\n';
    
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
//typedef unordered_map<int,int> umi;
//typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


int main()
{
	IOS;
	ll n,W,i,j;
	cin >> n >> W;
	ll w[n+1],v[n+1];
	forn(1,n+1,i)
	{
		cin >> w[i] >> v[i];
	}
	ll dp[n + 1][W + 1];
	forn(0,W+1,i)
		dp[0][i] = 0;
	forn(0,n+1,i)
		dp[i][0] = 0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=W;j++)
		{
			if(w[i] <= j)
			{
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]) ;
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][W] << '\n';
}


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

int main() {
	// your code goes here
	long long int n,c,v,s=0,ss=0,i,j,a,mx=0;
	cin>>n;
	vector <long long int> va , vb;
	vector <pair<long long int , long long int > > vc;
	for(i=0;i<n;i++)
	{
		cin>>c;
		va.push_back(c);
	}
	for(i=0;i<n;i++)
	{
		cin>>v;
		vb.push_back(v);
	}
	for(i=0;i<n;i++)
	{
		vc.push_back(make_pair(va[i],vb[i]));
	}
	sort(vc.begin(),vc.end());
	for(i=0;i<n;i++)
	{
		if(vc[i].first>vc[i].second)
		{
			s+=vc[i].first;
			ss+=vc[i].second;
			mx=max(mx,s-ss);
		}
		
	}
	cout<<mx<<endl;
	return 0;
}

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

#define ios ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define FOR(i, a, b) for(int i=(int)a; i<(int)b; i++)
#define len(a) a.length()
#define ndl "\n";
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++)
#define debug cout << "DEBUG" << ndl;
#define in(a) cin >> a
#define out(a) cout << a << ndl
const int N = 1e5+7;
const int LOGN = log(N) + 2;
const int MOD = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	ios;
	string n; cin >> n;
	for(int i=0, j=len(n)-1; i<=j; i++, j--) {
		if (n[i] != n[j]) {
			cout << "No" << ndl; return 0;
		}
	}
	cout << "Yes" << ndl; return 0;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 1005
using namespace std;
int n, x;
int pre[maxn];

int main()
{
    scanf("%d%d",&n, &x);
    for(int i=1;i<=n;i++){
        scanf("%d", &pre[i]);
    }
    int d = 0;
    int cnt = 1;
    for(int i=1;i<=n;i++){
        d = d + pre[i];
        if(d > x){
            break;
        }
        cnt ++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] a){
    	int c, no=0;
    	Scanner in = new Scanner(System.in);
      while (true){
      	c = in.nextInt();
      	if(c == 0) break;
      	no++;
        System.out.println("Case " + no + ": " + c);
      }
    }
}

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

int main(void){

    int k, a, b, i;

    scanf("%d",&k);
    scanf("%d%d",&a,&b);

    for(i=a;i<=b;i++){
        if(i%k==0){
            printf("OK");
            return 0;
        }
    }

    printf("NG");
    return 0;
}

Measured memory_bytes: 1708
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> A(m);
    vector<int> B(m);
    vector<int> C(m);

    const long long INF = 1LL << 50;
    vector<vector<long long>> dis(n, vector<long long>(n, INF));
    for (int i = 0; i < m; ++i) {
        cin >> A[i] >> B[i] >> C[i];
        --A[i], --B[i];
        dis[A[i]][B[i]] = C[i];
        dis[B[i]][A[i]] = C[i];
    }
    for (int i = 0; i < n; ++i) {
        dis[i][i] = 0;
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }


    int res = 0;
    for (int i = 0; i < m; ++i) {
        int u = A[i], v = B[i];
        bool ok = false;
        // for (int s = 0; s < n && !ok; ++s) {
        //     for (int t = 0; t < n; ++t) {
        //         if (dis[s][u] + C[i] + dis[v][t] == dis[s][t]) {
        //             ok = true;
        //             break;
        //         }
        //     }
        // }
        ok = dis[u][v] == C[i];
        if (!ok) {
            ++res;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#include<math.h>
int main()
{
	int n, i;
	double x1, y1, x2, y2, x3, y3;
	double a, b, c, d, e, f;
	double R, xp, yp;
	scanf("%d", &n);
	for (i = 0; i < n; i ++) {
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
		a = 2*(x1-x2);
		b = 2*(y1-y2);
		c = x1*x1 + y1*y1 - x2*x2 - y2*y2;
		d = 2*(x1-x3);
		e = 2*(y1-y3);
		f = x1*x1 + y1*y1 - x3*x3 - y3*y3;
		xp = (double)c*e-(double)b*f;
		if (xp) xp /= (double)a*e-(double)b*d;
		yp = (double)c*d-(double)a*f;
		if (yp) yp /= (double)b*d-(double)a*e;
		R = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
		printf("%.3f %.3f %.3f\n", xp, yp, R);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void)
{
    char s[13];
    char t[13];
    scanf("%s", s);
    scanf("%s", t);
    int i;
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] != t[i])
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct UnionFind
{
	/*
		ã\ÌÝTCYð-1{µ½àÌð¿A»êÈOÍã\ÌÔðÂ 
	 */
	
	vint data;
	
	UnionFind(int size) : data(size, -1) { }
	
	bool Union(int x, int y)
	{
		x = Root(x), y = Root(y);
		
		if(x != y)
		{
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		
		return x != y;
	}
	
	bool Same(int x, int y)
	{	return Root(x) == Root(y);	}
	
	int Root(int x)
	{	return data[x] < 0 ? x : data[x] = Root(data[x]);	}

	int Size(int x)
	{	return -data[Root(x)];	}
};


int main()
{
    int n, m;
	
	while(cin >> n >> m && n)
	{
		vector<vint> G(n, vint(n, 10000));
		
		rep(i, m)
		{
			int a, b;
			cin >> a >> b;
			
			G[a - 1][b - 1] = G[b - 1][a - 1] = 1;
		}
		
		rep(k, n) rep(i, n) rep(j, n) chmin(G[i][j], G[i][k] + G[k][j]);
		
		int res = 0;
		
		REP(i, 1, n) res += G[0][i] <= 2;
		
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int d,g;
    cin>>d>>g;
    vector<int>p(d),c(d);
    rep(i,d){
        cin>>p[i]>>c[i];
    }
    int ans=1e9;
    for(int mask=0;mask<(1<<d);mask++){
        int s=0,num=0,rest_max=-1;
        for(int i=0;i<d;i++){
            if(mask>>i&1){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<g){
            int s1=100*(rest_max+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ba = []
for i in range(M):
    a, b = map(int, input().split())
    ba.append((b, a))
ba.sort()
ans = 0
last = 0
for b, a in ba:
    if a >= last:
        ans += 1
        last = b
print(ans)

Measured memory_bytes: 17008
using System;

namespace ALDS1_4_D {
    class Problem {
        private int n, k, totalWeights;
        private int[] weights;

        public Problem(int n, int k) {
            this.n = n;
            this.k = k;
        }

        public void Read() {
            weights = new int[n];
            for (int i = 0; i < n; i++) {
                int weight = int.Parse(Console.ReadLine());
                weights[i] = weight;
                totalWeights += weight;
            }
        }

        public int Run() {
            return SearchMaxCapacity(totalWeights);
        }

        private int SearchMaxCapacity(int totalWeights) {
            int left = 0;
            int right = totalWeights;
            while (left < right) {
                int mid = (left + right) / 2;
                if (IsAllGainOn(mid))
                    right = mid;
                else
                    left = mid + 1;
            }
            return right;
        }

        private bool IsAllGainOn(int capacity) {
            int nextCargo = 0;
            for (int i = 0; i < k; i++) {
                if (nextCargo == n)
                    return true;
                int sumWeights = 0;
                for (int j = nextCargo; j < n; j++) {
                    sumWeights += weights[j];
                    if (sumWeights > capacity)
                        break;
                    nextCargo++;
                }
            }
            return nextCargo == n;
        }
    }

    class Program {
        static void Main(string[] args) {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);

            Problem p = new Problem(n, k);
            p.Read();
            Console.WriteLine(p.Run());
        }
    }
}

Measured memory_bytes: 9844
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();

        scan.close();


        if(a < b){
            for(int i = 0; i < b; i++){
                System.out.print(a);
            }
            
        }else{
            for(int i = 0; i < a; i++){
                System.out.print(b);
            }
        }
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

void solve(){
    int N;
    string S,T;
    cin>>S>>T;
    N=S.size();
    int pos;
    for(int i=N-1;i>=0;i--)if(S[i]=='1'){pos=i;break;};

    int uku=-1;
    rep(i,N)if(S[i]!=T[i]){uku=i;break;}
    if(uku==-1){
        cout<<0<<endl;
        return;
    }

    int ans=0;
    if(uku<=pos){
        ans+=pos-uku;
        pos=uku;
    }

    S[pos]='1';
    for(int i=pos+1;i<N;i++)S[i]='0';

    int beet=-1;
    rep(i,N)if(S[i]!=T[i])beet=i;
    if(beet==-1);
    else if(pos<beet){
        ans+=beet-pos;
    }
    else if(pos==beet&&T[pos]=='0'){
        int latte;
        for(int i=pos-1;i>=0;i--)if(S[i]=='1'){latte=i;break;}
        ans+=pos-latte;
    }
    cout<<ans<<endl;
}


signed main(){
    int Q;cin>>Q;
    while(Q--)solve();

    return 0;
}



Measured memory_bytes: 3204
N,T = map(int,input().split())
ct = []

for x in range(0,N):
    c,t = map(int,input().split())
    ct.append([c,t])


for x in range(N-1,-1,-1):
    if ct[x][1] > T:
        ct.remove(ct[x])
    
if len(ct) == 0:
    print("TLE")
else:
    print(min(ct)[0])


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final int N = stdin.nextInt();
	int[][] number = new int[ 3 ][ N ];

	for ( int i = 0; i < N; i++ ) {
	    for ( int j = 0; j < 3; j++ ) {
		number[ j ][ i ] = stdin.nextInt();
	    }
	}

	int[] score = new int[ N ];
	for ( int i = 0; i < 3; i++ ) {
	    int[] existed = new int[ 101 ];
	    for ( final int val : number[ i ] ) {
		existed[ val ]++;
	    }
	    for ( int j = 0; j < N; j++ ) {
		if ( existed[ number[ i ][ j ] ] == 1 ) {
		    score[ j ] += number[ i ][ j ];
		}
	    }
	}

	for ( final int val : score ) {
	    System.out.println( val );
	}
    }    
}

Measured memory_bytes: 20924
N, L = map(int,input().split())

aji = [0]*N
for i in range(1,N+1):
  aji[i-1]=L+i-1

pi = sum(aji)
ans = 0
diff = []
for i in range(N):
  if pi - aji[i] == pi:
    print(pi)
    exit()
  diff.append(pi - aji[i])
if pi > 0:
  print(max(diff))
else:
  print(min(diff))

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

int main()
{
  int n, d;
  int x[10][10];
  cin >> n >> d;
  for (auto ndx(0); ndx < n; ++ndx) {
    for (auto ddx(0); ddx < d; ++ddx) {
      cin >> x[ndx][ddx];
    }
  }
  auto count = 0;
  for (auto ndx(0); ndx < n - 1; ++ndx) {
    for (auto mdx(ndx + 1); mdx < n; ++mdx) {
      auto sum = 0;
      for (auto ddx(0); ddx < d; ++ddx) {
      	sum += (x[ndx][ddx] - x[mdx][ddx]) * (x[ndx][ddx] - x[mdx][ddx]);
      }
      auto result = sqrt(sum);
      if (result == round(result)) {
        ++count;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	long long n,a,b;
	cin>>n>>a>>b;
	long long res = n/(a+b)*a+min(a,n%(a+b));
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  string c1,c2,c3;
  cin >> c1 >> c2 >> c3;
  cout << c1[0] << c2[1] << c3[2] << endl;
}


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

using namespace std;

int const max_n = 3002;

int dp[max_n][max_n];

int main(){
	string s, t;
	cin>>s;
	cin>>t;
	int n = s.size(), m = t.size();
	dp[0][0] = 0;
	for(int x=0;x<=n;x++) {
		for(int i=0;i<=m;i++){
			if(x ==0 || i == 0) dp[x][i] = 0;
			else{
				if(s[x-1] == t[i-1]) dp[x][i] = dp[x-1][i-1]+1;
				else dp[x][i] = max(dp[x-1][i], dp[x][i-1]);
			}
		}
	}
	int i = n, j = m;
	string ans;
	while(i>0 && j>0) {
		if(dp[i-1][j] == dp[i][j]) i--;
		else if(dp[i][j-1] == dp[i][j]) j--;
		else if(dp[i-1][j-1] + 1 == dp[i][j]) {
			ans.push_back(s[i-1]);
			i--;
			j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
}

Measured memory_bytes: 4152