akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_164_SheepandWolves
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            
            long s = inputLongArray[0];
            long w = inputLongArray[1];

            if (s > w)
            {
                Console.WriteLine("safe");
            }
            else if (s <= w)
            {
                Console.WriteLine("unsafe");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }

  int main(){
     lint N;
     cin>>N;
     --N;
     lint A[N],B[N],C[N];
     rep(i,N){
         cin>>A[i]>>B[i]>>C[i];
     }
     lint ans;
     rep(i,N){
         ans=0;
         repp(j,i,N){
            if(j==i)ans+=A[j]+B[j];
            else if(ans%C[j]==0&&ans>=B[j])ans+=A[j];
             else if(ans%C[j]==0&&ans<B[j])ans=A[j]+B[j];
             else if(ans+C[j]-ans%C[j]>=B[j])ans+=(A[j]+C[j]-ans%C[j]);
             else ans=A[j]+B[j];
     }
     cout<<ans<<endl;
     }
     cout<<0;
  }
  

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int nc = scanner.nextInt();
			int[] s = new int[n], t = new int[n], c = new int[n];
			IntStream.range(0, n).forEach(i -> {
				s[i] = scanner.nextInt();
				t[i] = scanner.nextInt();
				c[i] = scanner.nextInt() - 1;
			});
			int maxT = Arrays.stream(t).max().getAsInt();
			int[][] channel = new int[nc][maxT * 2 + 2];
			IntStream.range(0, nc).forEach(i -> Arrays.fill(channel[i], 0));
			IntStream.range(0, n).forEach(i -> {
				Arrays.fill(channel[c[i]], s[i] * 2, t[i] * 2 + 1, 1);
			});
			System.out.println(IntStream.range(0, maxT * 2 + 2)
					.map(i -> IntStream.range(0, nc).map(j -> channel[j][i]).sum()).max().getAsInt());
		}
	}
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b;
	cin >> a >> b;
	int count = 1,sum = a;
	if(b == 1)cout << 0 << endl;
	else if(a >= b)cout << count << endl;
	else{
		while(sum < b){
			sum += a - 1;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> a(3*n);
  REP(i,3*n) cin>>a[i];

  sort(ALL(a),greater<int>());

  ll ans=0;
  REP(i,n) ans+=a[2*i+1];
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1408
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		stack <ll> s;
		ll n;
		cin>>n;
		ll a[n+1];
		rep(i,0,n) cin>>a[i];
		ll ans=0;
		ll i=0;
		while(i<n-1){
			ll j=i;
			while((j<n-1)&&(a[j]>=a[j+1])) j++;
			ans=max(ans,j-i);
			i=max(i+1,j);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 1024
def main():
    n = list(input())

    if n[0] == '1':
        n[0] = '9'
    else:
        n[0] = '1'

    if n[1] == '1':
        n[1] = '9'
    else:
        n[1] = '1'

    if n[2] == '1':
        n[2] = '9'
    else:
        n[2] = '1'

    print(''.join(n))

main()

Measured memory_bytes: 38256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

use std::collections::BinaryHeap;
use std::collections::HashMap;
fn main() {
  let n = read::<i64>();
  let k = read::<i64>();
  let mut bh: BinaryHeap<i64> = BinaryHeap::new();
  let mut dist: HashMap<i64, i64> = HashMap::new();
  let mut ans = 0;
  for _ in 0..n {
    let a = read::<i64>();
    let current = dist.entry(a).or_insert(0);
    *current += 1;
  }

  let dist_len: i64 = dist.len() as i64;
  for (k, v) in dist.iter() {
    bh.push(-v)
  }

  if 0 < dist_len - k {
    for _ in 0..dist_len - k {
      ans += -bh.pop().unwrap();
    }
  }

  println!("{}", ans);
}



Measured memory_bytes: 16796
int bw(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n, o[100010] = {}, e[100010] = {};
	int o1[100010] = {}, e1[100010] = {};
	int oo, ee;
    int ans1,ans2,ans;
	scanf("%d", &n);
	for (int i = 0; i < n; i+=2)
	{
		scanf("%d%d", &oo,&ee);
		o[oo]++; e[ee]++;
		o1[oo]++; e1[ee]++;
	}
	qsort(o1, 100010, sizeof(int), bw);
	qsort(e1, 100010, sizeof(int), bw);
	int maxe = 0, maxo = 0;
	oo = 0, ee = 0;
	for (int j = 0; j < 100010; j++)
	{
		if (e[j] == e1[0]) maxe = j;
		if (o[j] == o1[0]) maxo = j;
	}
	if (maxe != maxo)
	{
		printf("%d", n - e[maxe] - o[maxo]);
		return 0;
	}
	else
	{
        ans1 = n - e1[1] - o1[0];
        ans2 = n - e1[0] - o1[1]; 
        if (ans1 > ans2){
            ans = ans2;
        }
        else{
            ans = ans1;
        }
    	printf("%d", ans);
		return 0;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned int uint;

template <class T> inline T max(const T& a, const T& b) { return a > b ? a : b; }
template <class T> inline T min(const T& a, const T& b) { return a < b ? a : b; }
template <class T> inline void cmax(T& a, const T& b) { if (b > a) a = b; }
template <class T> inline void cmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void swap(T& a, T& b) { T c = a; a = b; b = c; }
template <class T> inline void swap(T* a, T* b) { T* c = a; a = b; b = c; }

namespace io {
inline int in() {
    int ans = 0, neg = 0; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') neg = 1; ch = getchar(); }
    do { ans = ans * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9');
    return neg ? -ans : ans;
}
} // namespace io

const int N = 1e5 + 5;
const ll mod = 998244353;

inline ll qpow(ll a, ll b) {
    ll ans = 1;
    for (; b; b >>= 1, a = (a * a) % mod)
        if (b & 1)
            ans = (ans * a) % mod;
    return ans;
}

int n, d[N], a[N];

int main() {
    using io ::in;
    n = in();
    int maxdep = 0;
    for (int i = 1; i <= n; ++i) {
        d[i] = in();
        ++a[d[i]], cmax(maxdep, d[i]);
    }
    //for (int i = 1; i <= n; ++i)
    //    printf("%d ", d[i]); puts("");
    if (d[1] != 0 || a[0] != 1) {
        puts("0");
        return 0;
    }
    for (int i = 1; i <= n; ++i)
        if (a[i] != 0 && a[i - 1] == 0) {
            puts("0");
            return 0;
        }
    ll ans = 1;
    for (int i = 2; i <= maxdep; ++i) {
        ans = (ans * qpow(a[i - 1], a[i])) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

ll go(ll n){
	if(n == 1) return 1;
	else return 1 + 2*go(n/2);
}

int main()
{
    ll a; cin >> a;

    cout << go(a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
 
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	REP(i,n) scanf("%d",a+i);
	REP(i,n-1) if(a[i]+a[i+1]>=d){
		printf("Possible\n");
        for(int j=1;j<=i;j++) printf("%d\n",j);
        for(int j=n-1;j>i+1;j--) printf("%d\n",j);
        printf("%d\n",i+1);
        return 0;
	}
	printf("Impossible");
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;

int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n-k;i++){
    int j=i+k;
    if(a.at(i)<a.at(j))
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
  }
}



Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using min_pqueue = priority_queue<ll, vector<ll>, greater<ll>>;

int main() {  
  ll N, K;
  cin >> N >> K;

  vector<ll> v(N);
  for (ll i = 0; i < N; i++) {
    cin >> v[i];
  }

  ll ans = 0;
  for (ll l = 0; l <= min(N, K); l++) {
    for (ll r = 0; l + r <= min(N, K); r++) {
      ll cnt = 0;
      min_pqueue q;
      for (ll i = 0; i < l; i++) {
        q.push(v[i]);
        cnt += v[i];
      }
      for (ll i = 0; i < r; i++) {
        q.push(v[N - i - 1]);
        cnt += v[N - i - 1];
      }

      for (ll i = 0; i < K - (l + r); i++) {
        if (!q.empty() && q.top() < 0) {
          cnt -= q.top();
          q.pop();
        }
      }
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> x(5);
  for (auto &it : x)
    cin >> it;
  for (int i = 0; i < 5; i++)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
unsigned long int a,b;
cin>>a>>b;
if(a%2 == 0 && b%2 ==0 || a%2!=0 && b%2!=0){
    unsigned long int k = (a+b)/2;
    cout<<k;
} else{
    cout<<"IMPOSSIBLE";
}
}


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

string str;
int sum[100005];


int main(void){
	cin >> str;
	int n=str.size();
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		if(str[i]=='0')sum[i+1]++;
	}
	int ans=(n+1)/2;
	int b=0;
	for(int i=n;i>=(n+1)/2;i--){
		if(sum[n-b]-sum[b]==0)ans=max(i,ans);
		if(sum[n-b]-sum[b]==(n-2*b))ans=max(i,ans);
		b++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    
    if (S == U) {
        A--;
    }
    else if (T == U)
    {
        B--;
    }
    
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m + 1];
    for (int i = 0; i < n; ++i)
    {
        cin >> c[i];
        for (int j = 1; j <= m; ++j)
            cin >> a[i][j];
    }
    int ans = 1e18;
    int cur[15];
    for (int mask = 0; mask < (1 << n); mask++)
    {
        //cout << mask << "\n";
        memset(cur, 0, sizeof(cur));
        int cost = 0;
        for (int i = 0; i < n; ++i)
        {
            //gives all the permutation of numbers from 0 to 5
            if (mask >> i & 1)
            {
                cost += c[i];
                for (int j = 1; j <= m; ++j)
                    cur[j] += a[i][j];
            }
        }
        int flag = 1;
        for (int i = 1; i <= m; ++i)
            flag &= (cur[i] >= x);
        if (flag)
            ans = min(ans, cost);
    }
    if (ans > 1e15)
        ans = -1;
    cout << ans;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
     
    typedef long long ll;
     
    using namespace std;
     
    int main() {
        int x, y, z;
        cin >> x >> y >> z;
     
        x -= z * 2;
     
        int a = y + z;
     
        int b = x / a;
     
        if (x - b * (y + z) >= y) {
            cout << b + 1 << endl;
        } else {
            cout << b << endl;
        }
    }

Measured memory_bytes: 3632
from math import gcd #or import math
K = int(input())#or K = int(input())+1
plus = 0

for i in range(1,K+1):# range(1,K)
    for a in range(1,K+1):# range(1,K)
        x = gcd(i,a) #or math.gcd(i,a)
        for j in range(1,K+1):# range(1,K)
            plus += gcd(x,j) #or math.gcd(x,j)
            
print(plus)

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound


signed main() {
    int n;
    cin >> n;
    rep(i, n) {
        char s;
        cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

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

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  long long lim = 998244353;

  vector<int> D(N, 0);
  int dmax=0;
  int num;

  for (int i = 0; i < N; i++)
  {
    cin >> num;
    if(num==0 && i!=0){
        cout << 0 << endl;
        return 0;
    }
    D[num] += 1;
    if(dmax<num){
      dmax=num;
    }
  }

  long long result=1;
  for (int i = 0; i < dmax; i++)
  {
    if (D[i] == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    long long sum=1;
    for(int j=0;j<D[i+1];j++){
      sum*=D[i];
      sum%=lim;
    }
    result*=sum;
    result%=lim;
  }
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 768
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int N=4e5+5;
int n,m,now,v[N],a[N],nex[N],pre[N],head[N];
void add(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
queue<int>que;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	que.push(1),a[1]=1;
	while(!que.empty()){
		int x=que.front();	que.pop();
		for(int i=head[x];i;i=nex[i])
			if(!a[v[i]]){
				a[v[i]]=1,que.push(v[i]);
				pre[v[i]]=x;
			}
	}
	for(int i=1;i<=n;i++)
		if(!a[i]){
			puts("No");
			return 0;
		}
	puts("Yes");
	for(int i=2;i<=n;i++)
		printf("%d\n",pre[i]);
	return 0;
}


Measured memory_bytes: 8004
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <iostream>
#define ll long long
using namespace std;
char s[105];
int main() {
	int res = 0;
	scanf("%s", s);
	int len = strlen(s);
	int start = 0;
	int end = len - 1;
	while (start <= end) {
		if (s[start] == s[end]) {
			start++;
			end--;
		}
		else {
			res++; start++; end--;
		}
	}
	printf("%d\n", res);
}



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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    int c = 0;
    for (int i = a; i <= b; i++) {
        string og = to_string(i);
        string re = og;
        reverse(re.begin(), re.end());
        if (og == re) {
            c++;
        }
    }
    cout << c << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	gcd(long A, long B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	lcm(long A, long B) {
	long G=gcd(A, B);
	return A/G*B;
}

long	GCD(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =gcd(B, A.at(i));
	return B;
}

long	LCM(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =lcm(B, A.at(i));
	return B;
}
*/

int	main() {
	int N, K, S;
	cin >>N >>K >>S;
	bool First=true;
	for (int i=0; i<K; i++) {
		if (First) {
			cout <<S;
			First=false;
		} else
			cout <<' ' <<S;
	}
	if (S==1000000000)
		S -=2;
	for (int i=K; i<N; i++) {
		if (First) {
			cout <<S+1;
			First=false;
		} else
			cout <<' ' <<S+1;
	}
	cout <<endl;
	return 0;
}



Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX],n;
	
	cin >> n;
	for(int i = 0; i < n; i++ ) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i = 1; i < n; i++ ){
		maxv = max(maxv,R[i] - minv);
		minv = min(minv,R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}
		

Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    vint b;
    REP(i,N) if(i%2!=N%2) b.push_back(a[i]);
    reverse(ALL(b));
    REP(i,N) if(i%2==N%2) b.push_back(a[i]);

    REP(i,N) cout<<b[i]<<' '; 

}


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

#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)

signed main() {
    int N;
    cin >> N;

    vector<int> P(N);
    rep(i, 0, N) cin >> P[i];

    vector<int> Index(N+1);
    rep(i, 0, N) Index[P[i]] = i;

    multiset<int> S;
    S.insert(-1);
    S.insert(-1);
    S.insert(N);
    S.insert(N);

    int ans = 0;

    for (int p = N; p > 0; p--) {
        int i = Index[p];
        auto pos = S.lower_bound(i);

        pos++;
        int d = *pos;

        pos--;
        int c = *pos;

        pos--;
        int b = *pos;

        pos--;
        int a = *pos;

        int cp = (i - b) * (d - c) + (c - i) * (b - a);
        ans += cp * p;

        S.insert(i);
    }

    cout << ans << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll INF = 1001001001001001001;
int N, W;
int ws[110], vs[110];
ll dp[110][100100];

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

    std::cin >> N >> W;

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

    std::fill(&dp[0][0], &dp[0][0] + 110 * 100100, INF);
    dp[0][0] = 0;

    for(int i=0;i<N;++i){
        for(int j=0;j<=100000;++j){
            dp[i+1][j] = std::min(dp[i+1][j], dp[i][j]);

            if(j + vs[i] <= 100000){
                dp[i+1][j+vs[i]] = std::min(dp[i+1][j+vs[i]], dp[i][j] + ws[i]);
            }
        }
    }

    int res = 0;
    for(int i=0;i<=100000;++i){
        if(dp[N][i] <= W){
            res = i;
        }
    }

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


Measured memory_bytes: 86272
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> A(N + 1, 0);

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	int Bcnt = 0;
	vector<int> B(N + 1, 0);

	for (int i = N; i >= 1; i--)
	{
		int total = 0;
		for (int j = i + i; j <= N; j += i)
		{
			total += B[j];
		}

		if (total % 2 != A[i])
		{
			Bcnt++;
			B[i] = 1;
		}
	}

	cout << Bcnt << "\n";
	for (int i = 1; i <= N; i++)
	{
		if (B[i])
		{
			cout << i << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 2560
M=10**6+1
f=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))
n,*l=map(int,open(0).read().split())
from math import *
g,C=0,[0]*M
for x in l:
  g=gcd(g,x)
  C[x]=1
if g>1: f(2)
if any(sum(C[i::i])>1 for i in range(2,M)): f(1)
f(0)

Measured memory_bytes: 231216
import sys

s = input()
K = int(input())
subs=[]
for i in range(len(s)):
    for j in range(i+1,min(len(s)+1,i+K+1)):
        subs.append(s[i:j])

subset = set(subs)
subset = sorted(subset)
print(subset[K-1])


Measured memory_bytes: 41072
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<string, int> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

int main(){
	string s;
	cin >> s;
	int sz = s.size();
	int n = (sz + 1) / 2;
	int res = 0;
	for(int i = 0; i < n; i++){
		char a = s[i];
		char b = s[sz-1-i];
		if(a == '(' && b == ')') res++;
		else if(a == ')' && b == '(') res++;
		else if((a == 'i' || a == 'w') && a == b) res++;
	}
	cout << n - res << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=1e5+5;
char s[N];
int n,a[N];
signed main(){
	//freopen("a","r",stdin);
	scanf("%s",s+1);n=strlen(s+1);rep(i,1,n)a[i]=s[i]-'a';
	rep(i,1,n-1)if(a[i]==a[i+1])return cout<<i<<' '<<i+1,signed();
	rep(i,1,n-2)if(a[i]==a[i+2])return cout<<i<<' '<<i+2,signed();
	return cout<<"-1 -1",signed();
}

Measured memory_bytes: 4132
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)

        
using namespace std;

int main()
        { 
        int num[5],rem,round[5],m=0,i,sum=0;
        for(i=0;i<5;i++)
        {
        cin>>num[i];
        rem=10-num[i]%10;
        if(rem==10)
        rem=0;
        round[i]=num[i]+rem;
        m=max(m,rem);
        sum+=round[i];
        }
        cout<<sum-m;
        //system("pause");
        return 0;
        } 
        




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

const int N = 105;
const int W = 1e5 + 5;

int p[N], w[N];
ll dp[W][N];

int n, wt;

ll solve(int i, int bag) {
  if (i == n)
    return 0;
  if (dp[bag][i] != -1)
    return dp[bag][i];
  ll& cur = dp[bag][i];
  if (bag - w[i] >= 0)  
    cur = p[i] + solve(i+1, bag - w[i]);
  cur = max(cur, solve(i+1, bag));
  return cur;
}

int main () {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  memset(dp, -1, sizeof(dp));
  cin >> n >> wt;
  for (int i = 0; i < n; i++)
    cin >> w[i] >> p[i];
  cout << solve(0, wt);
  return 0;
}

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

int main() {
  int N,A,cou=-1,sub,i;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> A;
    sub=0;
    while(!(A%2)){
      A/=2;
      sub++;
    }
    if(cou==-1)cou=sub;
    if(sub<cou)cou=sub;
  }
  cout << cou << endl;
}

Measured memory_bytes: 256
//27
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(char c;cin.get(c);){
    if(c!='@'){
      cout<<c;
    }else{
      char r,l;
      cin>>r>>l;
      cout<<string(r-'0',l);
    }
  }
  return 0;
}

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

using namespace std;
int arr[4];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a,b;
    cin>>a>>b;
    arr[a]++;
    arr[b]++;

    for(int i=1;i<=3;i++)
        if(!arr[i])
        cout<<i;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int mx = 0;
  int now = 0;
  for(int i=0; i<N; i++){
    if(S[i] == 'I') now++;
    else now--;
    chmax(mx,now);
  }
  cout << mx << "\n";
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
vector<string> bit;


void subBin(string str, int n)
{
    if (n == 0){
        bit.push_back(str);
    }
    if (n > 0) {
        subBin(str + "0", n - 1);
        subBin(str + "1", n - 1);
    }
}

string toBin(int n){
    if(n == 1)return "1";
    else if(n == 0)return "0";

    return toBin(n/2)  + to_string(n%2);
}

int main(){
    int abcd;
    cin >> abcd;
    
    int a = abcd / 1000;
    int b = (abcd % 1000)/100;
    int c = (abcd  % 100)/10;
    int d = abcd %10;

    rep(i, 8){
        string str = toBin(i);
        if(str.size() < 3){
            rep(j, 4 - str.size())str = "0" + str;
        }
        string ans = to_string(a);
        int isseven = a;
        if(str[0] == '1'){
            isseven += b;
            ans = ans + "+" + to_string(b);
        }
        else{
            isseven -= b;
            ans = ans + "-" + to_string(b);
        }
        if(str[1] == '1'){
            isseven += c;
            ans = ans + "+" + to_string(c);
        }
        else{
            isseven -= c;
            ans = ans + "-" + to_string(c);
        }
        if(str[2] == '1'){
            isseven += d;
            ans = ans + "+" + to_string(d);
        }
        else{
            isseven -= d;
            ans = ans + "-" + to_string(d);
        }
        if(isseven == 7){
            cout << ans + "=7";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,Q = (int(i) for i in input().split())
S = input()
acl = [0 for i in range(N)]
cnt = 0
for j in range(1,N):
  if S[j-1] == 'A' and S[j] == 'C':
    cnt += 1
  acl[j] = cnt
      
for k in range(Q):
  x,y = map(int, input().split())
  print(acl[y-1]-acl[x-1])

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int h,w;
    cin >> h >> w;

    vector<string> s(h);

    rep(i, h){
        cin >> s[i];
    }

    rep(i, w + 2) cout << '#';
    cout << endl;

    rep(i, h){
        cout << '#';
        cout << s[i];
        cout << "#" << endl;
    }

    rep(i, w + 2) cout << '#';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	cout << a + b + c - max({ a,b,c }) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    s1 = s1.toUpperCase();
    s2 = s2.toUpperCase();
    s3 = s3.toUpperCase();
    System.out.println("" + s1.charAt(0) + s2.charAt(0) + s3.charAt(0)); 
  }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
int32_t main(){
    int n,m;
    cin>>n>>m;
    vi v(n);
    int sum=0;
    for(int i =0 ; i < n; i++ ){
        cin>>v[i];
        sum+=v[i];
    }
    sort(v.rbegin(),v.rend());
    // int lit  = sum/(4*m) + (sum%(4*m) == 1);
    int i =0 ;
    for(i =0 ; i < m ; i++  ){
        
        if(v[i]*4*m >= sum)
            continue;
        
        break;    
    }
    if(i==m)
        cout<<"Yes\n";
    else
            cout<<"No\n";
    
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  //l:array[0..6] of Integer = (1,2,4,8,16,32,64);
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);

    if (n mod 10)=(n div 100) then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ss =br.readLine().split(" ");
        int N = Integer.parseInt(ss[0]), C = Integer.parseInt(ss[1]);
        int[][] rec = new int[C][200001];
        for (int i = 0; i < N; i++) {
            ss = br.readLine().split(" ");
            int s = Integer.parseInt(ss[0]) * 2 - 1;
            int t = Integer.parseInt(ss[1]) * 2;
            int c = Integer.parseInt(ss[2]) - 1;
            rec[c][s]++;
            rec[c][t]--;
        }
        for (int i = 0; i < C; i++) {
            for (int j = 1; j < rec[0].length; j++) {
                rec[i][j] += rec[i][j - 1];
            }
        }
        int ans = 0;
        for (int i = 0; i < rec[0].length; i++) {
            int tmp = 0;
            for (int j = 0; j < C; j++) {
                tmp += rec[j][i] > 0 ? 1 : 0;
            }
            ans = Math.max(ans, tmp);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 84116
#include<stdio.h>
int main(void){
    int a = -1001,b = -1001;
    while(-1000 > a || a > 1000 || -1000 > b || b > 1000){
        scanf("%d %d", &a, &b);
    }
    if(a == b){
        printf("a == b\n");
    }
    else if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    return 0;
}


Measured memory_bytes: 2052
n, m = map(int,input().split())
ps = [input().split() for _ in range(m)]

check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
    if ps[i][1] == 'AC' and check[int(ps[i][0])]:
        check[int(ps[i][0])] = False
        wa_ans += wa[int(ps[i][0])]
    if ps[i][1] == 'WA':
        wa[int(ps[i][0])] += 1
ans = 0
for i in check:
    if not i:
        ans += 1

print(ans,wa_ans)

Measured memory_bytes: 33692
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int n;
int x[100],y[100],r[100],c[100];
bool vis[1<<24];

void solve(){
  rep(i,n) cin >> x[i] >> y[i] >> r[i] >> c[i];
  CLR(vis);
  int ans=0;
  queue<int> q;
  q.push((1<<n)-1);
  int up[24]={};
  rep(i,n)rep(j,i){
    int dx=x[i]-x[j];
    int dy=y[i]-y[j];
    if(dx*dx+dy*dy<(r[i]+r[j])*(r[i]+r[j])) up[i] |= 1<<j;
  }
  
  while(!q.empty()){
    int cv=q.front();
    q.pop();
    if(vis[cv]) continue;
    vis[cv] = true;
    ans = max(ans ,n-__builtin_popcount(cv));

    rep(i,n){
      if((~cv>>i)&1) continue;
      if(up[i]&cv) continue;
      rep(j,i){
	if(c[i]!=c[j]) continue;
	if(up[j]&cv) continue;	
	if((~cv>>j)&1) continue;
	q.push(cv&~(1<<i)&~(1<<j));
      }
    }
      
  }
  cout << ans << endl;
}

int main(){
  while(cin >> n && n) solve();
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n; cin >> n;
    vec<int> A(n);
    loop (n, i) cin >> A[i];
    int ans = 0;
    loop (n, i) ans += A[i] - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
using namespace std;

struct UnionFind {
  ll size,*par,*rk;
  UnionFind(ll sz){
    size=sz;
    par=new ll[size]; REP(i,size) par[i]=i;
    rk=new ll[size]; REP(i,size) rk[i]=0;
  }
  ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
  }
  void unite(ll x,ll y){
    x=find(x); y=find(y);
    if(rk[x]>rk[y]) par[y]=x;
    else if(rk[x]<rk[y]) par[x]=y;
    else {par[x]=y;rk[y]++;}
  }
  bool same(ll x,ll y) {
    return find(x)==find(y);
  }
};

int main(){
  ll N,M; cin>>N>>M;
  vi p(N); for(ll i=0;i<N;i++) cin>>p[i];
  for(ll i=0;i<N;i++) p[i]--;
  vi x(M),y(M);
  for(ll i=0;i<M;i++){
    cin>>x[i]>>y[i]; x[i]--; y[i]--;
  }

  UnionFind uf(N);

  for(ll i=0;i<M;i++){
    uf.unite(x[i],y[i]);
  }

  ll ans=0;
  for(ll i=0;i<N;i++){
    if(uf.same(i,p[i])) ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int n,e=0,w=0;
	string s;
	cin >> n >> s;
	vector<char> S;
	vector<int> E(300000,0);
	vector<int> W(300000,0);
	vector<int> ANS;
	for (int i = 0; i < n; i++){
		S.push_back(s[i]);
	}
	for (int i = 0; i < n; i++){
		if(s[i]=='E'){
			e++;
		}
		else{
			w++;
		}
		E[i]=e;
		W[i]=w;
	}
	for(int i = 0; i < n; i++){
		int EEE,WWW;
		EEE=E[n-1] - E[i];
		if(s[i]=='W'){
			WWW=W[i]-1;
		}
		else{
			WWW=W[i];
		}
		ANS.push_back(EEE+WWW);
	}
	sort(ANS.begin(),ANS.end());
	cout << ANS[0] << endl;
}

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin >> n;
    for(i=111; i<=999; i+=111)
    {
        if(i>=n)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);

            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = 1;

            for(int i = 0; i < k; i++)
            {
                int d = int.Parse(Console.ReadLine());
                str = Console.ReadLine().Split(' ');
                for (int j = 0; j < d; j++)
                {
                    int t = int.Parse(str[j]);
                    a[t - 1] = 0;
                }
            }

            Console.WriteLine(a.Sum());

            //ここまで
        }

        static long Max(long a, long b)
        {
            if (a > b) return a;
            else return b;
        }


    }

}


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

bool isPrime(int n){
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;

    for(int k=3; k<sqrt(n); k+=2){
        if(n%k==0) return false;
    }

    return true;
}
int main(){
    int x;
    cin >> x;
    while(1) {
        if(isPrime(x)){
            cout << x << endl; 
            break;
        }
        x++;
    }
}

Measured memory_bytes: 256
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse= True)
B.sort(reverse= True)
C.sort(reverse= True)
LIS = []
for i in range(X):
    INTB = 3000//(i+1)
    for j in range(min(INTB+1,Y)):
        INT = 3000//((i+1)*(j+1))
        for k in range(min(INT+1,Z)):
            SUM = A[i] + B[j] + C[k]
            LIS.append(SUM)
LIS.sort(reverse = True)
for i in range(K):
    print(LIS[i])

Measured memory_bytes: 9784
conv = {?N=>[-1,0], ?S=>[1,0], ?W=>[0,-1], ?E=>[0,1]}

loop {
	h, w, l = gets.split.map &:to_i
	break if w == 0
	
	loop_start = nil
	x = y = dx = dy = nil

	maze = (1..h).map{ "#" + gets.chomp + "#" }
	maze.unshift "#" * (w+1)
	maze << "#" * (w+1)
	(1..h).each{|i|
		(1..w).each{|j|
			if maze[i][j] =~ /[NSWE]/
				dy, dx = conv[maze[i][j]]
				y = i
				x = j
				break
			end
		}
	}

	hash = {[x, y, dx, dy] => 0}
	loop {
		while maze[y+dy][x+dx] == ?#
			dx, dy = -dy, dx 
		end
		x += dx
		y += dy
		l -= 1

		break if hash[[x, y, dx, dy]] || l == 0
		hash[[x, y, dx, dy]] = hash.size
	}

	if l == 0
		puts "#{y} #{x} #{conv.invert[[dy, dx]]}"
	else
		i = hash[[x, y, dx, dy]]
		x, y, dx, dy = hash.invert[i + l % (hash.size - i)]
		puts "#{y} #{x} #{conv.invert[[dy, dx]]}"
	end
}

Measured memory_bytes: 6736