akhauriyash/Code-Regression huggingface dataset:
while True:
    h, w = map(int, input().split())
    if h == 0:
        break
    else:
        for i in range(h):
            if i % 2 == 0:
                for j in range(w):
                    if j % 2 == 0:
                        print('#', sep='', end='')
                    else:
                        print('.', sep='', end='')
            else:
                for j in range(w):
                    if j % 2 == 0:
                        print('.', sep='', end='')
                    else:
                        print('#', sep='', end='')
            print('')
        print('')


Measured memory_bytes: 7012
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace TOPSIC
{
	public class Program
	{
		/// <summary>
		/// ABC 102
		/// </summary>
		public static void Main()
		{
			int n = int.Parse(ReadLine());
			var list = ReadLine().Split()
				.Select(x => int.Parse(x))
				.Select((x, i) => x - i + 1)
				.ToList();
			list.Sort();
			int b = list[0];
			if (n > 1)
			{
				if (n % 2 == 1)
				{
					b = list[n / 2];
				}
				else
				{
					b = (list[n / 2 - 1] + list[n / 2]) / 2;
				}
			}
			double ans = list.Sum(x => (double)Math.Abs(x - b));
			WriteLine(ans);
		}
	}
}


Measured memory_bytes: 30940
H, W, N = map(int, input().split())
sy, sx = map(int, input().split())
S = input()
T = input()
S = S[::-1]
T = T[::-1]

safe_y = [1, H]
safe_x = [1, W]
flg = 1
for i in range(N):
    if T[i] == 'L':
        if safe_x[1] != W:
            safe_x[1] += 1
    elif T[i] == 'R':
        if safe_x[0] != 1:
            safe_x[0] -= 1
    elif T[i] == 'U':
        if safe_y[1] != H:
            safe_y[1] += 1
    elif T[i] == 'D':
        if safe_y[0] != 1:
            safe_y[0] -= 1
    if S[i] == 'L':
        safe_x[0] += 1
    elif S[i] == 'R':
        safe_x[1] -= 1
    elif S[i] == 'U':
        safe_y[0] += 1
    elif S[i] == 'D':
        safe_y[1] -= 1
    if safe_y[1] - safe_y[0] < 0 or safe_x[1] - safe_x[0] < 0:
        flg = 0
        break

if flg:
    if safe_y[0] <= sy <= safe_y[1] and safe_x[0] <= sx <= safe_x[1]:
        pass
    else:
        flg = 0

print('YES' if flg else 'NO')


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long ll;
const ll INF=1e+7;
const ll MAX=6005;
ll a,b,c,d,a2,b2,c2,d2,ans,n;
int main(){
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
    a2=8*a,b2=4*b,c2=2*c,d2=d;
    ll t=min(min(a2,b2),min(c2,d2));
    ans=(n/2)*t;
    if(n%2){
        ll t=min(min(a2,b2),c2)/2;
        ans+=t;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<max((ll)0,(b*(n-1)+a)-(a*(n-1)+b)+1)<<endl;
}


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

int main() {
  int n;
  cin >> n;
 vector<int> p(n);
 vector<int> q(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
   for(int i = 0; i < n; i++){
    cin >> q.at(i);
  }
  vector<int> t(n);
  for(int i = 0; i < n; i++){
    t[i] = i + 1;
  }
  int cnt = 0;
  int a,b;
   do {
      if(t == p) a = cnt;
      if(t == q) b = cnt;
      cnt++;
  } while (next_permutation(t.begin(), t.end()));
  cout << abs(a-b) << endl;
}

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


    int A,B;double T; cin >> A >> B >> T;
    if(A > T){
        cout << 0 << endl;
        return 0;
    }

    int count= (T + 0.5) / A ;

    cout << (B * count) << endl;



    
    
}



Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//233
	string s;
	cin>>s;
	int mcnt = 0,cnt =0;
	for(char c:s) {
		if(c=='A'||c=='C'||c=='G'||c=='T'){
			cnt++;
			mcnt=max(mcnt,cnt);
		} else{
			cnt=0;
		}
	}
	cout<<mcnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {
	int N;
	cin >> N;
	int big[N];
	for(int i = 0; i < N; i++){
		cin >> big[i];
	}
	int count = 1;
	for(int j = 1; j < N; j++){
		for(int k = 0; k < j; k++){
			if(big[j] == big[k]){
				break;
			}	
			if(k == (j - 1)){
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n,d,a;
    cin>>n>>d>>a;
    vector< pair <ll,ll> > r(n);
    ll arr[200005]={0};
    fore(i,0,n){cin>>r[i].x>>r[i].y;}
    sort(r.begin(),r.end());
    ll fans=0;
    for(ll i=0;i<n;i++)
    {
    if(r[i].y>arr[i])
    {
        ll e=r[i].y-arr[i];
        ll ans=(e+a-1)/a;
        arr[i]+=ans*a;
        fans+=ans;
        ll ee=(ll)(upper_bound(r.begin(),r.end(),make_pair(r[i].x+2*d,(ll)1e18))-r.begin());
        arr[ee]-=ans*a;
    }
      arr[i+1]+=arr[i];
    }
    
    cout<<fans<<endl;
    return 0;
}












Measured memory_bytes: 4992
A,B = map(int, input().split())

if A > B:
  text = ""
  for i in range(A):
    text = text + str(B)
  print(text)

elif A < B:
  text = ""
  for i in range(B):
    text = text + str(A)
  print(text)

else:
  text = ""
  for i in range(A):
    text = text + str(A)
  print(text)

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

using namespace std;

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

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

   for(int i = 1; i < n + 1; ++i){
      int min = a[i] * 2;
      if(min > (k - a[i]) * 2){
         min = (k - a[i]) * 2;
      }
      ans += min;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int N,M;
int H[SIZE];
bool check[SIZE];


int main(){

	scanf("%d %d",&N,&M);

	for(int i = 1; i <= N; i++){

		check[i] = true;
	}

	for(int i = 1; i <= N; i++){

		scanf("%d",&H[i]);
	}

	int from,to;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		if(H[from] == H[to]){

			check[from] = false;
			check[to] = false;

		}else if(H[from] < H[to]){

			check[from] = false;

		}else{

			check[to] = false;
		}
	}

	int ans = 0;
	for(int i = 1; i <= N; i++){

		if(check[i])ans++;
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int xw,yw;
	xw = tx - sx;
	yw = ty - sy;

	string ret = "";

	// 1st step
	ret += string(xw,'R');
	ret += string(yw,'U');

	// 2nd step
	ret += string(xw,'L');
	ret += string(yw,'D');

	//3rd step
	ret += 'D';
	ret += string(xw+1,'R');
	ret += string(yw+1,'U');
	ret += 'L';

	//4th step
	ret += 'U';
	ret += string(xw+1,'L');
	ret += string(yw+1,'D');
	ret += 'R';

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int min = 0;
        for(int i = 0;i < n;i++){
            if(s.charAt(i) == '.'){
                min++;
            }
        }
        int num = min;
        for(int i = 0;i < n;i++){
            if(s.charAt(i) == '#'){
                num++;
            } else {
                num--;
            }
            min = Math.min(num,min);
        }
        System.out.println(min);
    }
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  int i = b;
    while(i<c+1){
      if(i%a==0){
        cout << "OK" << endl;
        break;
      }
      else
        i++;
    }
  if (i==c+1)
    cout << "NG" << endl;
}


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


int main() {
  int N;
  cin >> N;
  vector<vector<int>>vec(N);
  for(int i=0;i<N-1;i++){
    int a;
    cin >> a;
    vec.at(a-1).push_back(1);
  }
  for(int i=0;i<N;i++){
    cout << vec.at(i).size() << endl;
  }
}

Measured memory_bytes: 13996
import math
List = [int(i) for i in input().split()]
zei8min = List[0] * 25 / 2
zei8max = (List[0] + 1) * 25 / 2
for i in range(math.ceil(zei8min),math.floor(zei8max)):
    if math.floor(i * 0.1) == List[1]:
        print(i)
        exit()
print(-1)

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	priority_queue<ll> pq1;
	rep(i, n) {
		ll a;
		cin >> a;
		pq1.push(a);
	}
	
	vector<pair<ll, ll>> p;
	rep(i, m) {
		ll b_in, c_in;
		cin >> b_in >> c_in;
		p.push_back(make_pair(c_in, b_in));
	}
	
	sort(ALL(p));
	reverse(ALL(p));
	
	priority_queue<ll> pq2;
	ll cnt = 0;
	for (auto &t: p) {
		ll v = t.first;
		ll num = t.second;
		rep(i, num) {
			pq2.push(v);
			cnt++;
		}
		if (cnt > n) {
			break;
		}
	}
//	rep(i, m) {
//		ll b, c;
//		cin >> b >> c;
//		rep(j, b) {
//			pq2.push(c);
//		}
//
//		if (cnt > n)
//			break;
//		cnt++;
//	}
	
	ll sum = 0;
	rep(i, n) {
		if (pq1.empty()) {
			sum += pq2.top();
			pq2.pop();
		} else if (pq2.empty()) {
			sum += pq1.top();
			pq1.pop();
		} else {
			if (pq1.top() >= pq2.top()) {
				sum += pq1.top();
				pq1.pop();
			} else {
				sum += pq2.top();
				pq2.pop();
			}
		}
//		cout << sum << endl;
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 5744
import sys
table = [[0 for j in range(10)] for i in range(10)]


def flag(x, y):
    if x > 9 or y > 9 or x < 0 or y < 0:
        return False
    else:
        return True


def small(x, y):
    table[x][y] += 1
    if flag(x+1, y):
        table[x+1][y] += 1
    if flag(x-1, y):
        table[x-1][y] += 1
    if flag(x, y+1):
        table[x][y+1] += 1
    if flag(x, y-1):
        table[x][y-1] += 1


def medium(x, y):
    small(x, y)
    if flag(x+1, y+1):
        table[x+1][y+1] += 1
    if flag(x+1, y-1):
        table[x+1][y-1] += 1
    if flag(x-1, y+1):
        table[x-1][y+1] += 1
    if flag(x-1, y-1):
        table[x-1][y-1] += 1


def large(x, y):
    medium(x, y)
    if flag(x+2, y):
        table[x+2][y] += 1
    if flag(x-2, y):
        table[x-2][y] += 1
    if flag(x, y+2):
        table[x][y+2] += 1
    if flag(x, y-2):
        table[x][y-2] += 1


def ink(x, y, s):
    if s == 1:
        small(x, y)
    if s == 2:
        medium(x, y)
    if s == 3:
        large(x, y)


def Search():
    counter = 0
    thickest = 0
    for i in range(10):
        for j in range(10):
            if table[i][j] == 0:
                counter += 1
            elif thickest < table[i][j]:
                thickest = table[i][j]
    print(counter)
    print(thickest)


for l in sys.stdin:
    data = list(map(int, l.split(",")))
    x, y, s = data
    ink(x, y, s)

Search()

Measured memory_bytes: 7868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	rep(i, (max(a, b))) {
		cout << min(a, b);
	}
	cout << endl;
	//cin >> a;
}

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

int main() {
  string S;
  long long K;
  cin>>S>>K;
  bool a=1;
  for(int i=0; i<min((long long) S.size(), K); i++){
    if(S.at(i)>='2'){
      cout<<S.at(i)<<endl;
      a=0;
      break;
    }
  }
  if(a) cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<P> ID[N]; rep (i, N) ID[i].clear();

	vector<int> p(M, 0), y(M, 0);
	rep (i, M){
		cin >> p[i] >> y[i];
		--p[i];
		ID[p[i]].push_back(P(y[i],i));
	} // end rep

	map<int,int> mp[N];
	rep (i, N) mp[i].clear();
	rep (i, N){
		if ((int)ID[i].size() > 0){
			sort(ALL(ID[i]));
		} // end if
		rep (j, (int)ID[i].size()){
			int year = ID[i][j].first;
			int ind  = ID[i][j].second;
			mp[i][ind] = j;
		} // end rep
	} // end rep

	rep (i, M){
		int state = p[i];
		int city  = mp[p[i]][i];
		cout << setw(6) << setfill('0') << state+1 << setw(6) << setfill('0') << city+1 << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<string> words(n);
 
    string input;
    rep(i, n) {
        cin >> input;
        words.at(i) = input;
        sort(words.at(i).begin(), words.at(i).end());
    }
    sort(words.begin(), words.end());
 
    ll count = 0, sum = 0;
    bool reset = false;
    rep(i, n-1) {
        if (words.at(i) == words.at(i+1))
        {
            /* code */
            count++;
            sum += count;
        } 
        else
        {
            /* code */
            count = 0;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 5760
a,b,c,x,y=map(int,input().split())
ans=712378627461242
for i in range(0,2*max(x,y)+1,2):
    mai=max(0,x-i//2)
    mbi=max(0,y-i//2)
    ans=min(ans,a*mai+b*mbi+c*i)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<int mod=1000000007>
class ModInt {
public:
  int x;
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  friend ModInt operator + (ModInt l, const ModInt &r){ return l += r; }
  friend ModInt operator - (ModInt l, const ModInt &r){ return l -= r; }
  friend ModInt operator * (ModInt l, const ModInt &r){ return l *= r; }
  friend ModInt operator / (ModInt l, const ModInt &r){ return l /= r; }
  ModInt operator ^ (const int64_t y) const { return pow(y); }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt &a) { int64_t x; is>>x; a = ModInt(x); return is; }
};
using Int = ModInt<>;

int main(){
  long n,k;
  cin>>n>>k;
  vector<long> a(n);
  rep(i,n) cin>>a[i];

  sort(all(a));

  vector<Int> fact(n+5, 0), finv(n+5, 0);
  fact[0] = 1;
  rep(i,n) fact[i+1] = (i+1) * fact[i];
  rep(i,n+1) finv[i] = fact[i].inverse();

  auto comb = [&](int p, int r) {
    return fact[p] * finv[r] * finv[p-r];
  };

  Int ans = 0;
  rep(_,2){
    rep(i,k-1,n){ ans += a[i] * comb(i, k-1); dbg(ans);}
    dbg(ans);
    rep(i,n) a[i] *= -1;
    reverse(all(a));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0120

"""
import sys
from sys import stdin
input = stdin.readline


def calc_width(cakes):
    # ??±????????????????????????(?????????)????????????????????????????????????????¨??????????
    if len(cakes) == 1:
        return cakes[0]*2

    prev_r = cakes[0]
    width = prev_r

    for r in cakes[1:]:
        h_diff = abs(prev_r - r)
        w = ((prev_r + r)**2 - h_diff**2)**0.5
        width += w
        prev_r = r
    width += cakes[-1]

    return width


def main(args):
    for line in sys.stdin:
        data = [int(x) for x in line.strip().split()]
        box_size = data[0]
        temp = data[1:]
        temp.sort()

        # ??±??????????????????????????????????????????????????????????????????????????????
        min_width = float('inf')

        cakes = [temp[0]]
        temp = temp[1:]
        pick_large = True
        while temp:
            if pick_large:
                pick = temp[-1]
                temp = temp[:-1]
                pick_large = False
                diff_front = abs(pick - cakes[0])
                diff_rear = abs(pick - cakes[-1])
                if diff_front > diff_rear:
                    cakes.insert(0, pick)
                else:
                    cakes.append(pick)
            else:
                pick = temp[0]
                temp = temp[1:]
                pick_large = True
                diff_front = abs(pick - cakes[0])
                diff_rear = abs(pick - cakes[-1])
                if diff_front > diff_rear:
                    cakes.insert(0, pick)
                else:
                    cakes.append(pick)

        result = calc_width(cakes)
        min_width = min(result, min_width)

        if min_width <= box_size:
            print('OK')
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7944
N=int(input())
*A,=sorted(map(int,input().split()))

def f(x):
 for i in range(x,N,2):
  if A[i-1]!=i or A[i]!=i:
    return 0
 return 1   
    
a=1
if N%2==0:a=f(1)
else:
 if A[0]!=0:a=0
 else:a=f(2)
print(2**(N//2)%(10**9+7)*a)

Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

map<ll, ll> prime_factorization(ll n, set<int> &ps){
  map<ll, ll> ans;
  if(ps.find(n) != ps.end()){
    ans[n]++;
    return ans;
  }
  auto itr = ps.begin();
  while(n >= (*itr)*(*itr)){
    if(n % (*itr) == 0){
      ans[(*itr)]++;
      n /= (*itr);
      if(ps.find(n) != ps.end()){
        ans[n]++;
        return ans;
      }
    }else{
      itr++;
    }
  }
  ans[n]++;
  return ans;
}

set<int> make_prime_set(int lim){
  set<int> ps;
  vector<bool> chk(lim+1, true);
  chk.at(0) = chk.at(1) = false;
  rep2(i, 2, chk.size()){
    if(chk.at(i) == false) continue;
    ps.insert(i);
    for(int j = i+i; j < chk.size(); j +=i) chk.at(j) = false;
  }
  return ps;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  auto ps = make_prime_set(1e6+5);
  set<int> ups;
  bool f = false;
  for(auto now : a){
    auto rs = prime_factorization(now, ps);
    for(auto p : rs){
      if(p.first != 1 && ups.find(p.first) != ups.end()){
        f = true;
        break;
      }else{
        ups.insert(p.first);
      }
    }
    if(f == true) break;
  }
  if(f == false){
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = a.front();
  rep2(i, 1, a.size()){
    g = __gcd(g, a.at(i));
  }
  if(g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 10988
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

struct Node {
	int v, c;

	Node() {}
	Node(int v, int c):v(v), c(c) {}
};

int n;
int top;
int a[200010];
Node sta[200010];

inline void insert(int v, int x) {
	while(sta[top].v > v) --top;
	if(sta[top].v == v) sta[top].c++;
	else sta[++top] = Node(v, 1);
	if(top > 1 && sta[top].c == x) --top, insert(v - 1, x);
}

inline int chk(int x) {
	sta[top = 1] = Node(0, 0);
	for(int i = 2; i <= n; i++)
		if(a[i] <= a[i - 1]) insert(a[i], x);
	return sta[1].c == 0;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	n = ri;
	for(int i = 1; i <= n; i++) a[i] = ri;

	int ct = 0;
	for(int i = 2; i <= n; i++) ct += a[i] > a[i - 1];
	if(ct == n - 1) return puts("1"), 0;
	int l = 2, r = n, res = 1;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(chk(mid)) res = mid, r = mid - 1;
		else l = mid + 1;
	} printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int ch[100005][2],n,k,m,t,f[100005];
long long M,ans; char S[100005];
void dfs(int x,long long m){
	if (!ch[x][0]&&!ch[x][1]) return;
	if (!ch[x][0]||!ch[x][1])
	ans^=m&-m,dfs(ch[x][0]+ch[x][1],m-1);
	else dfs(ch[x][0],m-1),dfs(ch[x][1],m-1);
}
int main(){
	scanf("%d%lld",&n,&M);
	for (int i=1;i<=n;++i){
		scanf("%s",S); k=0; m=strlen(S);
		for (int j=0;j<m;++j){
			if (!ch[k][S[j]-'0']) ch[k][S[j]-'0']=++t;
			k=ch[k][S[j]-'0'];
		}
	}
	dfs(0,M);
	if (ans) puts("Alice"); else puts("Bob");
	return 0;
}

Measured memory_bytes: 1152
n,k = gets.chomp.split(' ').map(&:to_i)
arr = []
n.times do
  arr.push(gets.to_i)
end
arr.sort!
i = 0
min = 10 ** 10
while i <= n - k
  if arr[i+k-1] - arr[i] < min
    min = arr[i+k-1] - arr[i]
  end
  i += 1
end
puts min

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

using namespace std;

int main() 
{
    int n, x, z, i;
    string y;
    cin >> n;
    
    map<string, int> m;
    
    for(i = 0; i < n; i++)
    {
        cin >> x >> y;
        
        if(x == 0)
        {
            cin >> z;
            m[y] = z;
        }
        else if(x == 1)
        {
            printf("%d\n", m[y]);
        }
    }
    
    return 0;
}


Measured memory_bytes: 27968
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int , int> P;

int main(){
    int V, E;
    cin >> V >> E;

    vector<P> G[V];
    for(int i=0; i<E; i++){
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back(make_pair(t, w));
        G[t].push_back(make_pair(s, w));
    }

    int ans = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    bool used[V];
    fill(used, used+V, false);
    q.push(make_pair(0, 0));
    int cnt = 0;
    while(true){
        if(cnt==V) break;
        int now = q.top().second;
        int d = q.top().first;
        q.pop();
        if(used[now]) continue;

        used[now] = true;
        ans += d;
        cnt++;

        for(int i=0; i<G[now].size(); i++){
            int next = G[now][i].first;
            int c = G[now][i].second;
            q.push(make_pair(c, next));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7876
import numpy as np
N,M,Q = map(int,input().split())
lis = np.zeros((N,N))
for i in range(M):
    L,R = map(int,input().split())
    lis[N-L,R-1] += 1
#二次元累積和
np.cumsum(lis,axis=0,out=lis)
np.cumsum(lis,axis=1,out=lis)
for _ in range(Q):
    p,q = map(int,input().split())
    print(int(lis[N-p,q-1]))


Measured memory_bytes: 17044
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    string a;
    cin>>a;
    if(a[2]==a[3] && a[4]==a[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    

    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }

};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;










int main(){
    int n;
    cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    mint ans=0;
    rep(i,60){
        ll cnt=0;
        rep(j,n){
            if(p[j]>>i&1) cnt++;
        }
        mint a(cnt*(n-cnt));
        a*=mint(2).pow(i);
        ans+=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
int main() {
	while (true) {
		string x;
		cin >> x;
		if (x == "0")break;
		int sum = 0;
		for (int i = 0; i < x.size(); i++) {
			sum += x[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3180
import math

nums = [int(e) for e in input().split()]
a = nums[0]
b = nums[1]
h = nums[2]
m = nums[3]

rad = abs((h*60+m)/(60*12) - m/60) * 2 * math.pi

l = math.sqrt((a*math.sin(rad))**2 + (a*math.cos(rad)-b)**2)

print(l)


Measured memory_bytes: 9512
N = int(input())
S = input()

# 最初の黒以降の白全部置き換える
ans1 = 0
found = False
for c in S:
    if c == '.' and found:
        ans1 += 1
    if c == '#':
        found = True

# 最後の白より前の黒を全部置き換える
ans2 = 0
found = False
for c in reversed(S):
    if c == '#' and found:
        ans2 += 1
    if c == '.':
        found = True

bcounts = [0 for _ in range(len(S))]
wcounts = [0 for _ in range(len(S))]
cs = 0
for i in range(len(S)):
    if S[i] == '#':
        cs += 1
    bcounts[i] = cs
cs = 0
for i in reversed(range(len(S))):
    if S[i] == '.':
        cs += 1
    wcounts[i] = cs

INF = float('inf')
ans = INF
for i in range(len(S) - 1):
    if S[i] == '#' and S[i + 1] == '.':
        # 次の黒を超えたところの wcounts
        ni = i + 1
        while ni < len(S) and S[ni] == '.':
            ni += 1
        while ni < len(S) and S[ni] == '#':
            ni += 1
        if ni < len(S):
            wc = wcounts[ni]
        else:
            if wcounts[-1] == '.':
                wc = 1
            else:
                wc = 0
        ans = min(ans, bcounts[i] + wc)

print(min(ans1, ans2, (0 if ans == INF else ans)))


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

int main() {
  int d;
  cin >> d;
  
  if (d == 25) cout << "Christmas" << endl;
  else if (d == 24) cout << "Christmas Eve" << endl;
  else if (d == 23) cout << "Christmas Eve Eve" << endl;
  else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
}


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

const int INF=1001001001;

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> dp(h+1,INF);
    vector<int> a(1001);
    vector<int> b(1001);
    vector<int> c(1001);
    int ma=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        c[i]=b[i]/a[i];
        if(ma<a[i])ma=a[i];
    }
    dp[0]=0;
    rep(i,n){
        rep(j,h){
            int nj=min(j+a[i],h);
            dp[nj]=min(dp[nj],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[2*n];
for(int i=0; i<2*n; i++){
    cin>>arr[i];

}
int cnt = 0;
for(int i=0; i<2*n; i++){
if(arr[i] == arr[i+1] && arr[i+2] == arr[i+3] && arr[i+4] == arr[i+5]){
    cnt = cnt + 1;
}
}
if(cnt >= 1){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
    return 0;
}

Measured memory_bytes: 3644
import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict
import numpy as np

def main():
    finput=lambda :sys.stdin.readline().strip()
    n,a,b=map(int,finput().split())
    h=[int(finput()) for _ in range(n)]
    gs=lambda a,b:a//b+(a%b>0)
    def enough(t):
        s=np.sum([gs(max(x-t*b,0),a-b) for x in h])
        if s<=t:
            return True
        else:
            return False
    #def biser(t,l):
    #    if l==0:
    #        return t
    #    t=t+l//2
    #    if enough(t):
    #        return biser(t-l//2,l//2)
    #    else:
    #        return biser(t+1,l-l//2)
    l=max(h)//b+1
    t=0
    while l>0:
        t=t+l//2
        if enough(t):
            t=t-l//2
            l=l//2
        else:
            t+=1
            l=l-l//2
    print(t)

if __name__=='__main__':
    main()



Measured memory_bytes: 35540
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

ll pw(ll a, ll n)
{
    ll ans = 1;
    while (n > 0)
    {
        if (n % 2 != 0)
            ans = ans * a;
        a = a * a;
        n = n / 2;
    }
    return ans;
}

int main()
{
    ll x;
    cin >> x;
    bool y = false;
    for (ll i = -1000; i < 1000; i++)
    {
        for (ll j = -1000; j < 1000; j++)
        {
            if (pw(i,5) - pw(j,5) == x)
            {
                cout << i << " " << j << endl;
                y = true;
                break;
            }
        }
        if (y == true)
            break;
    }
    return 0;
}

Measured memory_bytes: 3632
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n,k,x,y,b[2000][2000],w[2000][2000],mx;
char c;

int bsum(int x1, int y1, int x2, int y2){
    if(x2==-1||y2==-1)return 0;
	return b[x2][y2]+(x1==-1||y1==-1?0:b[x1][y1])-(y1==-1?0:b[x2][y1])-(x1==-1?0:b[x1][y2]);
}
int wsum(int x1, int y1, int x2, int y2){
    if(x2==-1||y2==-1)return 0;
	return w[x2][y2]+(x1==-1||y1==-1?0:w[x1][y1])-(y1==-1?0:w[x2][y1])-(x1==-1?0:w[x1][y2]);
}

int main(){
	cin>>n>>k;
	lp(2*k)
		LP(2*k,j)
			b[i][j]=w[i][j]=0;
	lp(n){
		cin>>x>>y>>c;
		if(c=='B')b[x%(2*k)][y%(2*k)]++;
		else w[x%(2*k)][y%(2*k)]++;
	}
	lp(2*k)
		LP(2*k-1,j){
			b[i][j+1]+=b[i][j];
			w[i][j+1]+=w[i][j];
		}
		
	lp(2*k)
		LP(2*k-1,j){
			b[j+1][i]+=b[j][i];
			w[j+1][i]+=w[j][i];
		}
	mx=0;
	lp(k)
		LP(k,j){
			mx=max(mx,bsum(-1,-1,i-1,j-1)+bsum(i+k-1,-1,2*k-1,j-1)+bsum(-1,j+k-1,i-1,2*k-1)+bsum(i+k-1,j+k-1,2*k-1,2*k-1)+bsum(i-1,j-1,i+k-1,j+k-1)+wsum(i-1,-1,i+k-1,j-1)+wsum(-1,j-1,i-1,j+k-1)+wsum(i+k-1,j-1,2*k-1,j+k-1)+wsum(i-1,j+k-1,i+k-1,2*k-1));
		}
	lp(k)
		LP(k,j){
			mx=max(mx,wsum(-1,-1,i-1,j-1)+wsum(i+k-1,-1,2*k-1,j-1)+wsum(-1,j+k-1,i-1,2*k-1)+wsum(i+k-1,j+k-1,2*k-1,2*k-1)+wsum(i-1,j-1,i+k-1,j+k-1)+bsum(i-1,-1,i+k-1,j-1)+bsum(-1,j-1,i-1,j+k-1)+bsum(i+k-1,j-1,2*k-1,j+k-1)+bsum(i-1,j+k-1,i+k-1,2*k-1));
		}
	cout<<mx<<endl;
	return 0;
}


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

int n,m,k;
//union find
int par[100005];  
int rankk[100005];   
int sizz[100005];
int ans[100005];
int a[100005];
int b[100005];
int c[100005];
int d[100005];
void init(int n)      
{
    for(int i=0;i<n;i++)
    {
        par[i]=i;
        rankk[i]=0;
    }
} 

int find(int x)
{
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);     
} 

void unite(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y) return ;                
    
    if(rankk[x]<rankk[y]) par[x]=y,sizz[y]+=sizz[x];    
    else
    {
        par[y]=x;
        sizz[x]+=sizz[y];
        if(rankk[x]==rankk[y]) rankk[x]++;    
     } 
} 

bool  same(int x,int y)
{
    return find(x)==find(y);
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	//freopen("input.txt","r",stdin);
	cin>>n>>m>>k;
	init(n);
	fill(sizz,sizz+n,1);
	int t1,t2;
	for(int i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<k;i++)
	{
		cin>>c[i]>>d[i];
	}
	for(int i=0;i<m;i++)
	{
		unite(a[i],b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		ans[i]=sizz[find(i)];
	}
	for(int i=0;i<m;i++)
	{
		if(same(a[i],b[i]))
		{
			ans[a[i]]--;
			ans[b[i]]--;
		}
	}
	for(int i=0;i<k;i++)
	{
		if(same(c[i],d[i]))
		{
			ans[c[i]]--;
			ans[d[i]]--;
		}
	}
	cout<<ans[1]-1;
	for(int i=2;i<=n;i++)
	{
		cout<<" "<<ans[i]-1;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int gcd(int x,int y){
	int r;
   if(x<y)swap(x,y);
  
  while(y>0){
  r = x%y;
  x = y;
  y = r;
  }
  return x;
}

int main(){
 int a,b,c;
 int K;
 int sum=0;
 cin>>K;
 for(int i=1;i<=K;i++){
	for(int j=1;j<=K;j++){
		for(int k=1;k<=K;k++){
         a=i;
         b=j;
         c=k;
         sum+=gcd(gcd(a,b),c); 
		}
	}
}
  
 cout<<sum;
 return 0;
}


Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
    }
    println!("ABC{}", n);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    int cnt[100010] = {0};
    int sum = 0;
    while(q--) {
        int now;
        cin >> now;
        ++cnt[now];
        ++sum;
    }
    for(int i = 1; i <= n; ++i) {
        cout << (k - (sum - cnt[i]) > 0 ? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int count[] = new int[26];
		while (scanner.hasNext()) {
			String sen = scanner.nextLine();
			String sen2 = sen.toLowerCase();
			for (int i = 0; i < sen2.length(); i++) {
				char key = sen2.charAt(i);
				int num = key - 'a';
				if (num >= 0) {
					count[num]++;
				}
			}
			if(!scanner.hasNext()) {
				break;}

		}
		for (int i = 0; i < 26; i++) {
			System.out.println((char) (i + 'a') + " : " + count[i]);
		}

	}
}



Measured memory_bytes: 26140
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int m,n;
  int low,high,medi;
  int column,breadth;
  int i;
  bool f;
  while(cin>>m>>n,m,n){
    vector<int>v(n);
    for(i=low=0;i<n;i++){cin>>v[i];low+=v[i];}
    low/=m;
    high=1500000;
    int j=0;
    while(j++<100){
      medi=(low+high)/2;
      breadth=column=f=0;
      for(i=0;i<n;i++){
	if(medi<v[i]){f=1;break;}
	if(breadth+v[i]<=medi){
	  breadth+=v[i];
	}else{
	  breadth=v[i];
	  column++;
	  if(column==m){f=1;break;}
	}
      }
      if(f)low=medi;
      else high=medi;
    }
    cout<<high<<endl;
  }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N + 1), C(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<vector<int>> dp(N + 5, vector<int>(3));
  for (int i = 1; i <= N; i++) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
  }
  int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 6912
#include <stdio.h>
#define MAX 10000


int main(){
	int i,j,n,q,count;
	int S[MAX],T[MAX];


	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}

	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&T[i]);
	}

	for (j=0;j<q;j++){
		for (i=0;i<n;i++){
			if(S[i] == T[j]){
				count++;
				break;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int a,z,x,c,v;
int main()
{
    scanf("%d",&a);
    z=a/1000;
    x=(a/100)%10;
    c=(a/10)%10;
    v=a%10;
    if((z==x&&x==c)||(x==c&&c==v))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char a,b,c,d;
	scanf("%c%c%c%c", &a, &b, &c, &d);
	if (a == b && b == c) {
    printf("Yes\n");
  } else if (b == c && c == d) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
from collections import Counter
def solve():
  N = int(input())
  S = list(input())
  c = Counter(S)
  ans = c['R']*c['G']*c['B']
  for i in range(N):
    for j in range(i+1,N):
      k = j*2-i
      if k>N-1:
        break
      if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]:
        ans -= 1
  return ans
print(solve())

Measured memory_bytes: 74176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=3000000000;
const int MOD=1000000007;

int main()
{
 int n;
 cin >> n;
 ll sum[n],k,ans=INF;
 sum[0]=1;
 for(int i=0;i<n;i++){
   ll a;
   cin >> a;
   if(i==0) sum[0]=a; 
   else sum[i]=sum[i-1]+a;
 }
 for(int i=0;i<n;i++){
  k=2*sum[i]-sum[n-1];
  if(k<0) k=-1*k;
  if(k<ans) ans=k;
 }
 cout<< ans;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll Inf = 1e18;

ll k;
vector <ll> a;
vector <ll> b;
vector <ll> c;

ll S(ll x)
{
    return x * (x - 1) / 2;
}

bool Check(ll x)
{
    ll Cnt = 0;

    if(x >= 0)  Cnt += S(c.size()) + (ll) c.size() * ((ll) a.size() + b.size());

    for(int i = (int) a.size() - 1, j = 0; i >= 0; --i)
    {
        j = min(j, i);
        while(j < i && a[i] * a[j] <= x)    j++;
        Cnt += (ll) j;
    }

    reverse(b.begin(), b.end());
    for(int i = (int) b.size() - 1, j = 0; i >= 0; --i)
    {
        j = min(j, i);
        while(j < i && b[i] * b[j] <= x)    j++;
        Cnt += (ll) j;
    }
    reverse(b.begin(), b.end());

    reverse(a.begin(), a.end());
    for(int i = (int) a.size() - 1, j = 0; i >= 0; --i)
    {
        while(j < b.size() && a[i] * b[j] <= x) j++;
        Cnt += (ll) j;
    }
    reverse(a.begin(), a.end());

    return Cnt >= k;
}

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

    while(n--)
    {
        ll x;   scanf("%lld", &x);

        if(x > 0)   a.push_back(x);
        if(x < 0)   b.push_back(x);
        if(x == 0)  c.push_back(x);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll Ans = 0;
    ll Low = -Inf, High = +Inf;

    while(Low <= High)
    {
        ll Mid = Low + (High - Low) / 2;

        if(Check(Mid))  Ans = Mid, High = Mid - 1;
        else            Low = Mid + 1;
    }

    cout << Ans << endl;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

bool compare(ll x, ll y) {
    return abs(x) < abs(y);
}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int odd = 0;
    REP(i, N-1) {
        if (A[i] < 0) odd++;
    }
    
    ll total = 0;
    REP(i, N) {
        total += abs(A[i]);
    }

    if (A[N-1] < 0 && odd % 2 != 0) {
        print(total);
    } else if (A[N-1] >= 0 && odd % 2 == 0) {
        print(total);
    } else {
        sort(A.begin(), A.end(), compare);
        print(total - 2ll*abs(A[0]));
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && a != c) ans = "Yes";
  if (a == c && b != c) ans = "Yes";
  if (b == c && a != c) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1000000
#define L 12
#define NIL -1

char A[M][L];

int getChar(char c){
  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'T') return 4;
}

int getKey(char str[]){
  int sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key%(M-1));}

int find(char str[]){
  int i,h,key;
  key = getKey(str);

  for(i=0;;i++){
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(A[h],str) == 0) return 1;
    else if(strlen(A[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0 ; ; i++){
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(A[h],str) == 0) return 1;
    else if(strlen(A[h]) == 0){
      strcpy(A[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L], ch[9];

  scanf("%d", &n);
  for (i=0 ; i<n ; i++){A[i][0]='\0';}
  for (i=0 ; i<n ; i++){
    scanf("%s %s",ch,str);
    if (ch[0] == 'i'){insert(str);}
    else {
      if(find(str)){printf("yes\n");}
      else {printf("no\n");}
    }
  }
  return 0;
}


Measured memory_bytes: 13436