akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;
static const int MOD = (1000000000 + 7);

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3 );
    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 1<<30

int main(){
	int h, w;
	int used[1010][1010] = {0};
	cin >> h >> w;
	queue<pair<int, int>> que;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;
			cin >> c;
			if(c == '#'){
				que.push(mp(i,j));
				used[i][j] = 1;
			}
		}
	}
	int cnt = -1;
	int dx[] = {1,0,-1,0};
	int dy[] = {0,1,0,-1}; 
	while(!que.empty()){
		int n = que.size();
		for(int _ = 0; _ < n; _++){
			pair<int, int> p = que.front();
			que.pop();
			int y = p.fi, x = p.se;
			for(int d = 0; d < 4; d++){
				int i = dy[d], j = dx[d];
				if(y+i >= h || x+j >= w || y+i < 0 || x+j < 0) continue;
				if(used[i+y][j+x] == 0){
					que.push(mp(i+y, j+x));
					used[i+y][j+x] = 1;
				}
			}
		}
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 12560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
class TEST{
	static void Main(){
		Stopwatch sw=new Stopwatch();
		sw.Start();
		
		String s="";
		while(!String.IsNullOrEmpty(s=rs())){
			int n=int.Parse(s);
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
		
		sw.Stop();
		//Console.Error.WriteLine(sw.ElapsedMilliseconds);
	}
	static String rs(){return Console.ReadLine();}
}

class Sol{
	public void Solve(){
		used=new bool[101];
		Max=0;
		for(int i=0;i<101;i++){
			if(Count[i]==0)continue;
			used[i]=true;
			cnt=1;
			for(int j=0;j<Count[i];j++){
				if(used[ARR[i][j]])continue;
				used[ARR[i][j]]=true;
				cnt++;
				if(cnt>Max)Max=cnt;
				dfs(ARR[i][j]);
				cnt--;
				used[ARR[i][j]]=false;
			}
			cnt--;
			used[i]=false;
		}
		
		Console.WriteLine(Max);
	}
	
	
	int Max;
	int cnt;
	bool[] used;
	
	void dfs(int now){
		int jj=0;
		for(jj=0;jj<Count[now];jj++){
			if(used[ARR[now][jj]])continue;
			used[ARR[now][jj]]=true;
			cnt++;
			if(cnt>Max)Max=cnt;
			dfs(ARR[now][jj]);
			cnt--;
			used[ARR[now][jj]]=false;
		}
	}
	
	
	int N;
	int[][] ARR;
	int[] Count;
	public Sol(int n){
		N=n;
		ARR=new int[101][];
		for(int i=0;i<101;i++)ARR[i]=new int[101];
		Count=new int[101];
		for(int i=0;i<N;i++){
			var d=ria();
			Count[d[0]]++;
			ARR[d[0]][Count[d[0]]-1]=d[1];
			Count[d[1]]++;
			ARR[d[1]][Count[d[1]]-1]=d[0];
		}
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
  for(int i=0;i<h;i++){
    if(i<b){
    	string s(a,'0');
    	string t(w-a,'1');
        s+=t;
        char ans[w];
      for(int j=0;j<w;j++){
        ans[j]=s[j];
      }
    	//printf("%s\n",ans);
        cout<<s<<endl;
    }
    else{
        string s(a,'1');
    	string t(w-a,'0');
    	s+=t;
        char ans[w];
      for(int j=0;j<w;j++){
        ans[j]=s[j];
      }
    	//printf("%s\n",ans);
        cout<<s<<endl;
    }
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll sz=1e6+5;

ll fac[sz];

int n;
int a[sz];
char s[sz];

void prec()
{
    for(ll i=2; i<sz; i++) {
        ll n=i, k=0;
        while(!(n&1)) n>>=1, k++;
        fac[i] = fac[i-1] + k;
    }
}

int cmb(int n, int r)
{
    ll x = fac[n] - fac[n-r] - fac[r];
    if(x) x = 0;
    else x = 1;
    return x;
}

int main()
{
    prec();

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

    n--;
    int one=0;
    for(int i=0; i<n; i++) {
        int x = s[i]-'0', y = s[i+1]-'0';
        a[i]=abs(x-y);
        if(a[i]==1) one=1;
    }

    for(int i=0; i<n; i++) if(a[i]==2) a[i]=one^1;

    int ans = 0;
    for(int i=0; i<n; i++) {
        ans ^= cmb(n-1, i) & a[i];
    }

    if(!one && ans) ans=2;

    cout << ans << endl;
}


Measured memory_bytes: 12928
#include<stdio.h>

int main(){
	int a;
	while(~scanf("%d",&a)){
		int ans=0;
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				for(int k=0;k<10;k++)
					for(int l=0;l<10;l++)
						if(i+j+k+l==a)ans++;
		printf("%d\n",ans);
	}
}

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

int main(){
  int N,H;
  cin >> N;
  int ans=0;
  int maxx=0;
  for (int i=0;i<N;i++){
    cin >> H;
    ans=H>=maxx?ans+1:ans;
    maxx=max(H,maxx);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<pair<int,int>> P; // (x,pre_sum)
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	rp(i, 0, mn){
		if(X[x] > -1){
			int cyc_len = P.size() - X[x];
			int nxt_len = (n - X[x]) % cyc_len;
			ll remain = P[X[x]].second;
			ll cyc = (sum_p - remain) * ((n - X[x]) / cyc_len);
			remain +=P[X[x]+nxt_len].second - P[X[x]].second;
			cout<< cyc + remain <<endl;
			return 0;
		}
		P.emplace_back(x, sum_p);
		sum_p += x;
		X[x] = i;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  if(s == "SSS") cout << 0 << endl;
  else if(s == "RRR") cout << 3 << endl;
  else if(s == "RRS" || s == "SRR") cout << 2 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);
		double x1,y1,x2,y2,x3,y3,x4,y4;
		int n=scanner.nextInt();
		for(int i=0;i<n;i++){
			x1=scanner.nextDouble();
			y1=scanner.nextDouble();
			x2=scanner.nextDouble();
			y2=scanner.nextDouble();
			x3=scanner.nextDouble();
			y3=scanner.nextDouble();
			x4=scanner.nextDouble();
			y4=scanner.nextDouble();
			double m1=(y1-y2)/(x1-x2);
			double m2=(y3-y4)/(x3-x4);
			if(m1==m2) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 20588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        int a=j%10,b=j/10;
        if(a<2||b<2) continue;
        if(a*b==i) ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
"""
問題文
英大文字からなる文字列Sが与えられます。
Sの部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。

ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。

注記
文字列 Tの部分文字列とは、Tの先頭と末尾から0文字以上を取り去って得られる文字列です。
例えば、ATCODER の部分文字列には TCO, AT, CODER, ATCODER,  (空文字列) が含まれ、AC は含まれません。

制約Sは長さ1以上10以下の文字列である。Sの各文字は英大文字である。
"""

import re

S = input()
#S = 'HATAGAYA'

S = re.sub('[ACGT]', '1', S)
S = re.sub('[A-Z]', '0', S)

S = S.split('0')

print(len(max(S, key = len)))

Measured memory_bytes: 38640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
 
 
int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    queue<char> qa,qb,qc;
    int as = sa.size(),bs = sb.size(),cs = sc.size();
    rep(i,as) qa.push(sa[i]);
    rep(i,bs) qb.push(sb[i]);
    rep(i,cs) qc.push(sc[i]);

    char card = qa.front();
    qa.pop();

    while(1){
        if(card == 'a') {
            if(qa.size()) {
                card = qa.front();
                qa.pop();
                continue;
            }else{
                cout << "A" << endl;
                break;
                return 0;
            }
        }
        if(card == 'b') {
            if(qb.size()) {
                card = qb.front();
                qb.pop();
                continue;
            }else{
                cout << "B" << endl;
                break;
                return 0;
            }
        } 
        if(card == 'c') {
            if(qc.size()) {
                card = qc.front();
                qc.pop();
                continue;
            }else{
                cout << "C" << endl;
                break;
                return 0;
            }
        }    
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int n;
  cin>>n;
  pair<int,int> p[n];
  rep(i,0,n) cin>>p[i].first>>p[i].second;
  sort(p,p+n);
  co(p[n-1].first+p[n-1].second);

  return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(m)]
imos=[0]*(n+1)
for i,j in LR:
    imos[i-1]+=1
    imos[j]-=1

for i in range(n):
    imos[i+1]+=imos[i]

print(imos.count(m))
    

Measured memory_bytes: 31296
import functools as F

H, W = map(int, input().split())
S = F.reduce(lambda x, y: x + y, [input() for i in range(H)])
s = []
for c in S:
    s.append(0 if c == '.' else -10)
for idx, i in enumerate(s):
    if i < 0:
        if idx >= W and idx % W > 0:
            s[idx - W - 1] += 1
        if idx >= W:
            s[idx - W] += 1
        if idx >= W and idx % W < W - 1:
            s[idx - W + 1] += 1
        if idx % W > 0:
            s[idx - 1] += 1
        if idx % W < W - 1:
            s[idx + 1] += 1
        if idx + W < H * W and idx % W > 0:
            s[idx + W - 1] += 1
        if idx + W < H * W:
            s[idx + W] += 1
        if idx + W < H * W and idx % W < W - 1:
            s[idx + W + 1] += 1

for i in range(H):
    for j in range(W):
        print(s[j + i * W] if s[j + i * W] >= 0 else '#', end='')
    print()


Measured memory_bytes: 4068
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
int main()
{
ios_base::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
ll int n;
cin>>n;
vi a(n);
ll int g=0;
rep(i,0,n)
{cin>>a[i];
	g=__gcd(g,a[i]);
}
cout<<g;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cassert>
#include <numeric>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int solve(const vector<int64_t>& a) {
    unordered_map<int64_t, int> count;

    for (auto aa : a) {
        ++count[aa];
    }

    int ans = 0;
    for (const auto& entry : count) {
        auto v = entry.first;
        auto c = entry.second;

        if (v <= c) {
            ans += c - v;
        } else {
            ans += c;
        }
    }

    return ans;
}

int main() {
    int n;
    cin >> n;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    cout << solve(a) << endl;

    return 0;
}

Measured memory_bytes: 5028
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

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

const int MAX = 1<<18;

ll pref[MAX];
ll pref_i[MAX];
int dist[MAX];
int p[MAX], n, L;

void gen_p() {
  REP(i, n-1)
    dist[i] = p[i+1] - p[i];
  dist[n-1] = L + p[0] - p[n-1];

  REP(i, n) {
    pref[i] = (i ? pref[i-1] : 0) + dist[i];
    pref_i[i] = (i ? pref_i[i-1] : 0) + 2ll * i * dist[i];
  }
}

ll get_sum(ll t[], int poc, int kraj) {
  assert(kraj >= poc);
  return t[kraj] - (poc ? t[poc-1] : 0);
}

ll get_forward(int poc, int kraj, int prvi_koef) {
  //  assert(kraj >= poc);
  if (kraj < poc) return 0;
  return get_sum(pref_i, poc, kraj) +
    get_sum(pref, poc, kraj) * (prvi_koef - 2ll * poc);
}

ll get_backward(int poc, int kraj, int prvi_koef) {
  //  assert(kraj >= poc);
  if (kraj < poc) return 0;
  return -get_sum(pref_i, poc, kraj) +
    get_sum(pref, poc, kraj) * (2ll * kraj + prvi_koef);
}

int main()
{
  scanf("%d%d", &L, &n);
  
  n++;
  p[0] = 0;
  FOR(i, 1, n)
    scanf("%d", &p[i]);

  ll ret = 0;
  REP(st, 2) {
    gen_p();
    FOR(k, 1, n) {
      ll tmp;
      if (k % 2 == n % 2) {
	tmp = (n-k) * get_sum(pref, 0, k-1) +
	  get_backward(k, (n+k-4)/2, 2) +
	  get_forward((n+k)/2, n-1, 1);
      }
      else {
	tmp = (n-k) * get_sum(pref, 0, k-1) +
	  get_backward(k, (n+k-3)/2, 1) +
	  get_forward((n+k+1)/2, n-1, 2);
      }

      ret = max(ret, tmp);
    }
    
    FOR(i, 1, n)
      p[i] = L - p[i];
    reverse(p+1, p+n);
  }

  printf("%lld\n", ret);

  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    COUT(N*(N+1)/2);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int dp[n];
	dp[0]=0;
	for(int i=1;i<k&&i<n;i++){
		int m=INT_MAX;
		for(int j=0;j<i;j++){
			m=min(dp[j]+abs(a[j]-a[i]),m);	
		}
		dp[i]=m;
	}
	for(int i=k;i<n;i++){
		int m=INT_MAX;
		for(int j=i-1;i-j<=k;j--){
			m=min(dp[j]+abs(a[j]-a[i]),m);	
		}
		dp[i]=m;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	int n;
	ll T;
	std::cin >> n >> T;
	std::vector<ll> t(n);
	rep(i, n) std::cin >> t[i];

	ll ans = 0;
	Rep(i, 1, n) {
		if (t[i] - t[i - 1] <= T) {
			ans += t[i] - t[i - 1];
		}
		else ans += T;
	}
	ans += T;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace CODEFEST2016C {
    class Program {
        static void Main(string[] args) {
            // test case input
			string inputString = Console.ReadLine();
            Regex regex=new Regex(".*?C.*?F.*?");
			if (inputString.Length < 2 || inputString.Length > 100) {
				Console.Write("No");
				return;
			}
            if(inputString.IndexOf('C')>-1) {
                var tmp = inputString.Split('C');
                for(var i=1;i<tmp.Length;i++){
                    if(tmp[i].IndexOf("F") > -1) {
                        Console.Write("Yes");
                        return;
                    }
                }
            }
            Console.Write("No");
            return;
        }
    }
}


Measured memory_bytes: 5512
n= input()
a = map(int,raw_input().split())
#print a

l=[ i for i in range(n)]
l_gusu=l[0::2]
l_kisu=l[1::2]

ans=[]
for i in reversed(list(l_gusu)):
	#print i,a[i]
	ans.append(a[i])

for i in l_kisu:
	ans.append(a[i])


ans_str=""
if n%2==0:
	for i in reversed(list(ans)):
		ans_str+=(str(i)+" ")
	print ans_str.strip()
else:
	for i in ans:
		ans_str+=(str(i)+" ")
	print ans_str.strip()
		
	

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

int main(){
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]){
            ans++;
        }
    }
    ans += 2*k;
    if(ans > n-1){
        ans = n-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 1000000
//#define MAX 1000
int main(){
	int p[MAX];
	int target;
	int i,t,r;
	for(i = 0;i < MAX;i++){
		p[i] = 1;
	}
	p[0]=0;p[1]=0;
	for(i = 0;i < MAX;i++){
		if(p[i]){
			for(t=2; t*i<MAX;t++)
				p[t*i] = 0;
		}
	}

	while(scanf("%d", &target)!=EOF){
		r = 0;
		for(i = 1;i <= target;i++)
			if(p[i])r++;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 4500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

class Program
{
    static void Main(string[] args)
    {
        var wrong_answer = new wrong_answer();
        wrong_answer.Solve();
    }
}

public class wrong_answer
{
    const int INF = 1 << 29;
    const long INFL = 1L << 60;
    const int MOD = 1000000007;
    const int MOD2 = 998244353;

    myinout IO = new myinout();






    public void Solve()
    {

        var o = IO.intm;
        var a = o[0];
        var b = o[1];

        string c="";
        for (int i = 0; i < b;++i){
            c += a.ToString();
        }
        string d = "";
        for (int i = 0; i < a; ++i)
        {
            d += b.ToString();
        }
        var e=int.Parse(c);
        var f = int.Parse(d);

        IO.wri(Math.Max(e, f));

    }




}






public static class Math2
{
    public static long pow(long i, long n, long MOD = 1000000007)
    {
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * i % MOD;
            i = i * i % MOD;
            n >>= 1;
        }
        return res;
    }

    public static long gcd(long i, long y)
    {
        while (y != 0)
        {
            var r = i % y;
            i = y;
            y = r;
        }
        return i;
    }

    public static long lcm(long i, long y)
    {
        return i * y / gcd(i, y);
    }

    public static Dictionary<long, int> primefactorization(long N)
    {

        var ret = new Dictionary<long, int>();

        for (long i = 2; i * i <= N; ++i)
        {
            int cnt = 0;
            while (N % i == 0)
            {
                cnt++;
                N /= i;
            }
            if (cnt != 0) ret[i] = cnt;

        }
        if (N >= 2) ret[N] = 1;

        return ret;

    }

    public static List<long> divisorenumrate(long N)
    {
        var ret = new List<long>();

        for (long i = 1; i * i <= N; ++i)
        {

            if (N % i == 0)
            {
                ret.Add(i);
                ret.Add(N / i);
            }

        }

        return ret;

    }

    public static void swap<T>(ref T a, ref T b)
    {
        var i = a;
        a = b;
        b = i;
    }

}

class myinout
{
    //in
    public string str => Console.ReadLine();

    public string[] strm => str.Split(' ');

    public long[] longm => strm.Select(long.Parse).ToArray();
    public int[] intm => strm.Select(int.Parse).ToArray();
    public char[] charm => str.ToArray();
    public double[] doublem => strm.Select(double.Parse).ToArray();
    public long long1 => longm[0];
    public int int1 => intm[0];
    public char char1 => charm[0];
    public double double1 => doublem[0];



    //out
    public void wri<T>(T i)
    {
        Console.WriteLine(i);
    }
    public void wri<T>(T[] i)
    {
        Console.WriteLine(string.Join(" ", i));
    }

    public void yn(bool i)
    {
        if (i) wri("Yes");
        else wri("No");
    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string a[3];
  a[0] = "Sunny";
  a[1] = "Cloudy";
  a[2] = "Rainy";
  
  string s;
  cin>>s;
  REP(i,3){
    if(s==a[i]){
      cout<<a[(i+1)%3]<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main (){
int n,tmp;

int sum[100];
cin >> n; 
vector<int> x(n);
for(int i = 0; i < n; i++)
    cin >> x[i];
for(int j = 1; j <= 100; j++){
     tmp = 0;
    for(int k = 0; k < n; k++){
       
        tmp += (int)pow((x[k] - j),2);
    }
    sum[j-1] = tmp;
  //  cout << "sum" << j << ": "<< tmp  << endl; 
}
sort(sum, sum + 99);

cout << sum[0] << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to return the maximized gcd 
// after removing a single element 
// from the given array 
long long MaxGCD(long long a[], long long n) 
{ 
  
    // Prefix and Suffix arrays 
    long long Prefix[n + 2]; 
    long long Suffix[n + 2]; 
  
    // Single state dynamic programming relation 
    // for storing gcd of first i elements 
    // from the left in Prefix[i] 
    Prefix[1] = a[0]; 
    for (int i = 2; i <= n; i += 1) { 
        Prefix[i] = __gcd(Prefix[i - 1], a[i - 1]); 
    } 
  
    // Initializing Suffix array 
    Suffix[n] = a[n - 1]; 
  
    // Single state dynamic programming relation 
    // for storing gcd of all the elements having 
    // greater than or equal to i in Suffix[i] 
    for (int i = n - 1; i >= 1; i -= 1) { 
        Suffix[i] = __gcd(Suffix[i + 1], a[i - 1]); 
    } 
  
    // If first or last element of 
    // the array has to be removed 
    long long ans = max(Suffix[2], Prefix[n - 1]); 
  
    // If any other element is replaced 
    for (int i = 2; i < n; i += 1) { 
        ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1])); 
    } 
  
    // Return the maximized gcd 
    return ans; 
} 

int main()
{
long long n;
cin>>n;
long long a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cout<<MaxGCD(a,n);
return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;

ll power(const ll a, const ll n, const ll mod)
{
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) {
        return power(a, n - 1, mod) * a % mod;
    } else {
        const ll aa = power(a, n / 2, mod);
        return aa * aa % mod;
    }
}

class ModCombination
{
public:
    ModCombination(const int n, const ll mod) : size{n + 1}, mod{mod}, fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)  // mod should be prime
    {
        for (ll i = 2; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % mod;
            inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod;
            inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod;
        }
    }
    ll combination(const int n, const int k) const
    {
        assert(n < size);
        assert(k <= n);
        return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod;
    }

private:
    const int size;
    const ll mod;
    vector<ll> fact;
    vector<ll> inv;
    vector<ll> inv_fact;
};
int main()
{
    int N;
    cin >> N;
    ll M;
    cin >> M;

    vector<ll> pp(N + 1);
    for (int i = 0; i <= N; i++) { pp[i] = power(2, power(2, i, M - 1), M); }
    ModCombination mod(N + 1, M);
    vector<vector<ll>> b(N + 2, vector<ll>(N + 2, 0));
    b[0][0] = 1;
    for (int i = 1; i <= N + 1; i++) {
        for (int j = 1; j <= i; j++) { b[i][j] = (b[i - 1][j - 1] + j * b[i - 1][j] % M) % M; }
    }
    vector<ll> weight(N + 1, 0);
    for (int k = 1; k <= N; k++) {
        const ll p = power(2, N - k, M);
        const ll PP = pp[N - k] * mod.combination(N, k) % M;
        for (ll x = 1, q = 1; x <= k + 1; x++, (q *= p) %= M) { (weight[k] += b[k + 1][x] * q % M) %= M; }
        (weight[k] *= PP) %= M;
    }
    ll minus = 0;
    for (int i = 1; i <= N; i++) { (minus += (i % 2 == 0 ? weight[i] : M - weight[i])) %= M; }
    cout << (pp[N] + minus) % M << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	rep1(i,n)scanf("%d",&a[i]);
	
	int ret = 0;
	rep1(i,n)if(a[a[i]] == i)ret ++;
	cout << ret/2 << endl;
}



Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import deque

def main():
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x)-1, input().split())
    c = [input() for _ in range(H)]

    adj = [[] for _ in range(W*H)]
    dx = [1,-1,0,0]
    dy = [0,0,1,-1]
    INF = 10**12
    
    for i in range(H):
        for j in range(W):
            if c[i][j] == '@': continue
            for k in range(4):
                y = i + dy[k]
                x = j + dx[k]
                if 0 <= y < H and 0 <= x < W and c[y][x] == '.':
                    adj[W*i+j].append(W*y+x)
    
    queue = deque([W*x1+y1])
    visit = [INF] * (W*H)
    visit[W*x1+y1] = 0
    
    while queue:
        now = queue.popleft()
        for u in adj[now]:
            # nowからuの方向に'.'が続くかぎり（最大K個）
            count = 0
            direct = u - now
            fromC = now
            toC = u
            while count < K and toC in adj[fromC] and visit[now] < visit[toC]:
                count += 1
                if visit[toC] == INF:
                    queue.append(toC)
                    visit[toC] = visit[now] + 1
                fromC = toC
                toC += direct 

    print(visit[W*x2+y2]) if visit[W*x2+y2] < INF else print(-1)
    # print(visit)

if __name__ == "__main__":
    main()

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

typedef long long ll;

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];

    ll res = 1;
    for (int i = 0; i < N; i++) {
        res = lcm(res, T[i]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,x,a[500010],ans,m;
int main(){
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d",&x);
		a[x]++;
	}
	for(i=1;i<=n;i++)printf("%d\n",a[i]);
}

Measured memory_bytes: 4552
#include<stdio.h>
#include<stdlib.h>
typedef struct Graph
{
  int key;
  int numOfAdj;
  int *adj;
  int status;//0:not discovered, 1:discovered, 2:finished
} graph;
int n;//num of vertice
graph *p;//array of vertice
int *d;//array of degree
int *queue;
int head=0,tail=0;
void breadthFirstSearch(int);
void enqueue(int);
int dequeue(void);
int main(void)
{
  int i,j;//counter
  int key,numOfAdj,adj;
  scanf("%d",&n);
  p=(graph*)malloc(sizeof(graph)*n);
  d=(int*)malloc(sizeof(int)*n);
  queue=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&key);
      scanf("%d",&numOfAdj);
      p[key-1].numOfAdj=numOfAdj;
      p[key-1].adj=(int*)malloc(sizeof(int)*numOfAdj);
      for(j=0;j<numOfAdj;j++)
	{
	  scanf("%d",&adj);
	  p[key-1].adj[j]=adj-1;
	}
      p[key-1].status=0;
      d[i]=-1;
    }
  breadthFirstSearch(0);
  return 0;
}
void breadthFirstSearch(int start)
{
  int i;//counter
  int u,v;
  d[start]=0;
  enqueue(start);
  while(head!=tail)
    {
      u=dequeue();
      for(i=0;i<p[u].numOfAdj;i++)
	{
	  v=p[u].adj[i];
	  if(p[v].status==0)
	    {
	      p[v].status=1;
	      d[v]=d[u]+1;
	      enqueue(v);
	    }
	}
      p[u].status=2;
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d\n",i+1,d[i]);
    }
}
void enqueue(int key)
{
  queue[tail]=key;
  tail++;
}
int dequeue(void)
{
  head++;
  return queue[head-1];
}



Measured memory_bytes: 2112
#include<iostream>
#include<vector>

using namespace std;

int main(){

    int N=0;
    int X=0;
    int tmp=0;
    int count =0;

    vector<int> L;

    L.push_back(0);

    cin >> N >> X;

    for(int i=0;i<N;i++){
        cin >> tmp;
        L.push_back(tmp);
    }


    for(int i=0;i<L.size();i++){
        X -= L[i];
        if(X<0){
            break;
        }
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int64_t n,ans=0;
	cin >> n;
	vector<int64_t> a(n);
	for(int64_t i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(ran(a));
	reverse(ran(a));
	for(int64_t i = 1; i < n; ++i) {
		ans += a[i / 2];
	}
	cout << ans << endl;
}

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

int main(){

    int n,m,t;

    cin >> n >> m >> t;

    int ans = 0;
    int now_time = 0;
    int a;
    cin >> a;

    if(m < a){
        ans += a-m;
    }

    now_time = a;

    for(int i=1; i<n; i++){
        
        cin >> a;

        int cost = now_time + 2*m;

        if(cost < a){
            ans += a - cost;
        }
        now_time = a;
    }

    ans += max(0, t - now_time - m);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3108
P=[]
C=[]
point=1001    #全問題数
 
D,G=map(int,input().split())
for i in range(D):
    p,c= map(int,input().split())
    P.append(p)
    C.append(c)
 
#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える
 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  #全正解した大問をスコアに変換
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  #1問も解かなかった問題の中で最も一題あたりの点が高い問題
            needproblem=j+1
    if score>=G :
        point=min(point,solve)
 
#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想
 
    elif score<G :                
        rest=G-score
        sum=(P[needproblem-1]-1)*needproblem*100
        if rest>sum :            #1問も解かなかった問題の中で最も一題あたりの点が高い問題を解いても届かないのでやり直し
            continue
        elif rest<=sum :
            resolve=solve+(rest//(needproblem*100)+(rest%(needproblem*100)>0))
            point=min(point,resolve)
 
print(point)

Measured memory_bytes: 9072
import java.util.*
fun main(args: Array<String>){
    val input = readLine()!!.split(" ")
    val H = input[0].toInt()
    val W = input[1].toInt()

    val purple : ArrayList<String> = arrayListOf<String>()

    for(i in 0..H-1){
        purple.add(readLine()!!)
    }

    val red : ArrayList<String> = arrayListOf<String>()
    val blue : ArrayList<String> = arrayListOf<String>()

    for(i in 0..H-1){
        red.add("")
        blue.add("")
        if(i % 2 == 0){
            for(j in 0..W-2){
                red[i] += "#"
                if(purple[i][j] == '#'){
                    blue[i] += "#"
                }
                else{
                    blue[i] += "."
                }
            }
            red[i] += "."
            blue[i] += "#"
        }
        else{
            red[i] += "#"
            blue[i] += "."
            for(j in 1..W-1){
                if(purple[i][j] == '#'){
                    red[i] += "#"
                }
                else{
                    red[i] += "."
                }
                blue[i] += "#"
            }
        }
    }
    for(i in 0..H-1){
        println(red[i])
    }
    println()
    for(i in 0..H-1){
        println(blue[i])
    }
}


Measured memory_bytes: 128844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  vector<pair<ll, ll>> c(n);
  rep(i, n){
    in2(c[i].second, c[i].first);
  }
  sort(all(c));
  a = 0;
  b = 0;
  rep(i, n){
    a = a + c[i].second;
    if(c[i].first < a)
      b++;
  }
  if(b)
    out("No");
  else
    out("Yes");
  memi;
}

Measured memory_bytes: 3328
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 100005;
const int MAXM = 50005;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
template <typename T> inline T max(T a, T b, T c) { return max(max(a, b),c); }



int vis[MAXN];
int p[MAXN];
ll c[MAXN];
ll sumv[MAXN],preMax[MAXN],val[MAXN];
int n;
ll k;
inline ll go(int st)
{
	int cnt = 0;
	vis[st] = 1;sumv[0] = 0;
	preMax[0] = -1e18;
	while (!vis[p[st]])
	{
		st = p[st];
		++cnt;
		sumv[cnt] = sumv[cnt-1] + c[st];
		val[cnt] = c[st]; 
		//debug(sumv[cnt]);
		preMax[cnt] = max(preMax[cnt-1],sumv[cnt]);
		vis[st] = 1;
	}
	st = p[st];
	++cnt;
	sumv[cnt] = sumv[cnt-1] + c[st];
	// debug(sumv[cnt]);
	val[cnt] = st;
	preMax[cnt] = max(preMax[cnt-1],sumv[cnt]);
	int rd = cnt; //循环节的长度
	//debug(rd);
	ll rdval = sumv[cnt];	//循环节的值
	// debug(rdval);
	//debug(preMax[cnt]);
	preMax[0] = 0;
	ll ans = 0;
	//debug(cnt);
	rep (i,1,rd)
	{
		sumv[rd+i] = sumv[rd+i-1] + val[i]; 
		// debug(val[i]);
		// debug(sumv[rd+i]);
		preMax[rd+i] = max(preMax[rd+i-1],sumv[rd+i]);
		// debug(preMax[rd+i]);
	}
	if (k > rd)
	{
		if (rdval > 0)
		{
			ll rm = k%rd + rd;
			//debug(ans);
			ans += rdval * ((k - rd)/rd);
			//debug(ans);
			
			ans += preMax[rm];
		}
		else 
			ans = preMax[cnt];
	}
	else 
		ans = preMax[k];
	return ans;
}
int main()
{closeSync;
#ifdef DEBUG
	// freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	// freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif  
	cin>>n>>k;
	rep (i,1,n)
		cin>>p[i];
	rep (i,1,n)
		cin>>c[i];
	ll mx = -1e18;
	rep (i,1,n)
	{	
		rep (i,1,n)
			val[i] = sumv[i] = preMax[i] = vis[i] = 0;
		ll temp = go(i);
		// debug(temp);
		mx = max(mx,temp);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3932
#include <algorithm>
#include <complex>
#include <cstdio>
#include <vector>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef complex<double> P;

const double EPS = 1e-8;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		P p[300];
		rep(i, n)
			scanf("%lf%lf", &p[i].real(), &p[i].imag());

		int ans = 1;
		rep(i, n) rep(j, i){
			double l = 1.0 - norm(p[i]-p[j])/4.0;
			if(l < 0.0)
				continue;
			l = sqrt(l);

			P center = (p[i] + p[j]) / 2.0;
			P ll = l * (p[i] - p[j])/abs(p[i] - p[j]) * P(0.0, 1.0);
			P c[] = {center+ll, center-ll};
			rep(k, 2){
				int cnt = 0;
				rep(m, n){
					if(norm(c[k] - p[m]) <= 1.0 + EPS)
						++cnt;
				}
				ans = max(ans, cnt);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> A(m);
    rep(i,m){
        cin >> A.at(i);
    }

    int active = 0;
    rep(i,m){
        active += A.at(i);
    }

    if(active > n){
        cout << "-1" << endl;
    }
    else
    {
        cout << n - active << endl;;        
    }
    


    return 0;
}

Measured memory_bytes: 3636
#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;

class Solution {
public:
    bool solve(vector<int>& A) {
        bool res = true;
        for (auto x : A) {
            if (x % 2 == 0) {
                res = res && (x % 3 == 0 || x % 5 == 0);
            }
        }
    
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;
    if (sol.solve(A)) {
        cout << "APPROVED\n";
    } else {
        cout << "DENIED\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=310;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int mod=1e9+7;
int f[N][N][2],inv[N],fac[N];

int main()
{
	int n=gi(),i,j,k,d,w;
	for (i=fac[0]=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
	for (i=2,inv[0]=inv[1]=1;i<=n;i++) inv[i]=mod-1LL*(mod/i)*inv[mod%i]%mod;
	for (i=3;i<=n;i++) inv[i]=1LL*inv[i]*inv[i-1]%mod;
	f[0][0][0]=1;
	for (i=0;i<n;i++) {
		d=gi()-1;
		for (j=0;j<=i;j++)
			for (k=0;k<2;k++)
				if (w=f[i][j][k]) {
					f[i+1][j][k]=(f[i+1][j][k]+1LL*w*inv[d])%mod;
					if (d) {
						f[i+1][j+1][k]=(f[i+1][j+1][k]+1LL*w*inv[d-1])%mod;
						if (!k&&d>1)
							f[i+1][j+1][1]=(f[i+1][j+1][1]+1LL*w*inv[d-2])%mod;
					}
				}
	}
	for (j=3,d=0;j<n;j++)
		d=(d+1LL*f[n][j][1]*fac[j-1]%mod*fac[n-(j-1)-2])%mod;
	d=(d+1LL*f[n][n][0]*fac[n-1])%mod;
	d=1LL*d*((mod+1)>>1)%mod;
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
        if(i!=minj) ans++;
        swap(A[i],A[minj]);
    }
    for(int i=0;i<N;i++){
        cout<<A[i];
        if(i==N-1) cout<<endl;
        else cout<<' ';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	ll K;
	ll A[100010] = {}; 
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		A[a] += b;
	}
	for (int i = 1; i < 100010; ++i) {
		if (K <= A[i]) {
			cout << i << endl;
			break;
		}
		K -= A[i];
	}
	return 0;
}


Measured memory_bytes: 1024
from math import sqrt

def resolve():
  N, D = map(int, input().split(" "))

  counter = 0
  for _ in range(N):
    X, Y = map(int, input().split(" "))
    if sqrt(X**2+Y**2) <= D:
      counter += 1

  print(counter)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 9188
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int N, K;
	cin >> N >> K;
	int res=1;
	for(int i=0; i<N; i++){
		if(res < K){
			res *= 2;
		}else{
			res += K;
		}
	}
	cout << res << "\n";
}


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

signed main(){
  int N,Al=0,Bb=0;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(rbegin(A),rend(A));
  rep(i,N){
    if(i%2==0)Al+=A[i];
    else Bb+=A[i];
  }
  int ans=Al-Bb;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}


int main()
{
    int s,w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int x;
cin>>x;
if(x==0){
    cout<<1<<endl;
}else{
    cout<<0<<endl;
}
}



Measured memory_bytes: 3636