akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())

h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]
dp[0] = 0

for i in range(N-1):
    for j in range(1, min(K+1, N - i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[N-1])

Measured memory_bytes: 56928
#include<stdio.h>

int h[100];
int w[100];
int i;
int j;
int k;

int main(void){
	
	for(i=0;i<100;i++){
		scanf("%d %d",&h[i],&w[i]);
		if(h[i] == 0 && w[i] == 0){
			break;
		}
	}
	for(i=0;i<100;i++){
		for(j=0;j<h[i];j++){
			for(k=0;k<w[i];k++){
				if(j == 0 || j == h[i]-1 || k == 0 || k == w[i]-1){
				printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
			
		}
			printf("\n");
				if(h[i+1] == 0 && w[i+1] == 0){
				break;
				}
			}
	return 0;
}

Measured memory_bytes: 572
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int R;
    cin>>R;

    if(R<1200){

        cout<<"ABC"<<endl;

    }
    else if(1200<=R&&R<2800){

        cout<<"ARC"<<endl;

    }
    else{

        cout<<"AGC"<<endl;

    }

}


Measured memory_bytes: 256
from collections import defaultdict

S = defaultdict(int)
T = defaultdict(int)

for _ in range(int(input())):
    S[input()] += 1

for _ in range(int(input())):
    T[input()] += 1

print(max(0, max([S[k] - T[k] for k, v in S.items()])))



Measured memory_bytes: 9392
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
c=a[0...k].inject(:+)
m=c
(n-k).times do |i|
  c+=a[k+i]
  c-=a[i]
  m=c if c>m
end
puts (m+k)/2.0


Measured memory_bytes: 14980
#include <iostream>
#include <string>
#include <vector>
#define ll long long
using namespace std;

int mod2(int n) {
  if (n >= 0)
    return n % 2;
  else
    return (-n) % 2;
}

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

  ll XY[N + 5][2];
  for (int i = 0; i < N; i++) {
    cin >> XY[i][0] >> XY[i][1];
  }

  int MOD = mod2(XY[0][0] + XY[0][1]);
  for (int i = 0; i < N; i++) {
    if (MOD != mod2(XY[i][0] + XY[i][1])) {
      cout << -1 << endl;
      return 0;
    }
  }

  int m = 33 - MOD;
  cout << m << endl;

  vector<ll> D(32);
  D[0] = 1;
  for (int i = 1; i < 32; i++) {
    D[i] = D[i - 1] * 2;
  }
  sort(D.begin(), D.end(), greater<ll>());
  if (MOD == 0)
    D.push_back(1);
  for (auto d : D)
    cout << d << " ";
  cout << endl;

  for (int i = 0; i < N; i++) {
    ll x = XY[i][0], y = XY[i][1];
    string w = "";
    for (auto d : D) {
      if (x + y >= 0 && x - y >= 0) {
        w += 'R';
        x -= d;
      } else if (x + y < 0 && x - y >= 0) {
        w += 'D';
        y += d;
      } else if (x + y >= 0 && x - y < 0) {
        w += 'U';
        y -= d;
      } else {
        w += 'L';
        x += d;
      }
    }
    cout << w << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<cmath>
#include<climits>
#include<cfloat>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<limits>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

	long A,B;
	long x,r,tmp;

	cin >> A >> B;

	x = A*B;

	if(A<B){

		tmp = A;
		A = B;
		B = tmp;

	}

	r = A%B;

	while(r != 0){

		A = B;
		B = r;
		r = A % B;

	}

	cout << long(x/B) << endl;

return 0;

}


Measured memory_bytes: 256
N,Y = map(int, input().strip().split(' '))

for a in range(N+1):
  for b in range(N-a+1):
    if Y == 10000*a + 5000*b + 1000*(N-a-b):
      print(a,b,N-a-b)
      exit()
print(-1,-1,-1)


Measured memory_bytes: 40684
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long ll;

ll mod_fact(ll n, ll mod) {
  if ( n <= 1 ) return 1;
  return (n * mod_fact(n-1, mod)) % mod;
}

int main( void ) {
  ll N, M;
  std::cin >> N >> M;

  const ll mod = 1000000007;

  const ll max = std::max(N, M);
  const ll min = std::min(N, M);

  if( max - min >= 2 ) {
    std::cout << 0 << std::endl;
    return 0;
  }

  const bool can_swap = ((max - min) == 0);
  const ll swap_coef = can_swap ? 2 : 1;

  const ll fact_max = mod_fact(max % mod, mod);
  const ll fact_min = mod_fact(min % mod, mod);

  const ll result = (swap_coef * fact_max * fact_min) % mod;
  std::cout << result << std::endl;

  return 0;
}

Measured memory_bytes: 3328
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define rALL(x) x.rbegin(),x.rend()
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vll A(N);
    REP(i,N) cin >> A[i];


    //本文
    sort(A.rbegin(), A.rend());
    ll ans =0;
    for(ll i = 1;i<N;i++){
        ans += A[i/2];
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 4856
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def solve():
    x = ni()
    print(360 // gcd(360, x))
    return

solve()


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ac=abs(a-c);
  int ab=abs(a-b);
  int bc=abs(b-c);
  if(ac<=d){
    cout<<"Yes"<<endl;
  }else if(ab<=d && bc<=d){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    int x[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        if (k - x[i] < x[i]) ans += 2 * (k - x[i]);
        else ans += 2 * x[i];
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
x, y = map(int, input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if (x in a and  y in a) or (x in b and y in b) or (x in c and y in c):
  print('Yes')
else:
  print('No')

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

int main(){
  long long A,B,r,x;
  cin>>A>>B;
  x=A*B;

  if(A<B){
    int tmp=A;
    A=B;
    B=tmp;
  }

  //ユークリッドの互除法
  r=A%B;
  while(r!=0){
    A=B;
    B=r;
    r=A%B;
  }

  cout<<x/B<<endl;

return 0;
}


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

#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

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

  ll ans = 0;
  while (n > 0) {
    n /= k;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a, b;
	int i,count=0;
	int answer[200];
	while (count<200)
	{
		if (scanf("%d", &a) != EOF)
		{
			scanf("%d", &b);
			i = 0;
			while (pow(10, i) <= a + b)
			{
				i++;
			}
			if (a + b == 0)
				i++;
			answer[count] = i;
		}
		else
		{
			answer[count] = -1;
			break;
		}
		count++;
	}
	for (i = 0; i < count || answer[i] != -1; i++)
		printf("%d\n", answer[i]);
	return 0;
}

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

int main(){
  int k;
  cin >> k;
  vector<ll> ak(k);
  for(int i=0; i<k; ++i) cin >> ak[i];
  ll ansl = 2, ansr = 2;
  for(int i=k-1; i>=0; --i){
    if(ansr < ak[i]){
      cout << -1 << endl;
      return 0;
    }
    ansl = ((ansl-1) /ak[i] +1)*ak[i];
    ansr = ansr /ak[i] *ak[i] +(ak[i]-1);
    if(ansr < ansl){
      cout << -1 << endl;
      return 0;
    }
    //cout << ansl << " " << ansr << endl;
  }
  cout << ansl << " " << ansr << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Binary_Indexed_Tree{
    vector<T> bit;
    
    Binary_Indexed_Tree(int N){
        bit.assign(N+1, 0);
    }
    
    void add(int i, const T &x){
        for(i++; i < sz(bit); i += (i & -i)) bit[i] += x;
    }
    
    T sum(int i){
        T ret = 0;
        for(; i > 0; i -= (i & -i)) ret += bit[i];
        return ret;
    }
    
    T query(int l, int r){
        return sum(r) - sum(l);
    }
    
    void clear(){
        fill(bit.begin(), bit.end(), 0);
    }
};

int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    vector<int> v(N);
    iota(all(v), 0);
    sort(all(v), [&](int i, int j){return a[i] < a[j];});
    Binary_Indexed_Tree<ll> bit(N);
    ll ans = 0;
    rep(i, N){
        ans += bit.query(v[i]+1, N);
        bit.add(v[i], 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6068
def gcd(li):
    a=max(li)
    b=min(li)
    while b>0:
        a,b=b,a%b
    return a

def lcm(li):
    return li[0]*li[1]/gcd(li)

while True:
    try:
        li=[int(i) for i in input().split(" ")]
        print("%i %i"%(gcd(li),lcm(li)))
    except:break

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb 	push_back
#define ll  long long
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define debug(x) cerr<<#x<<" =: "<<x<<endl;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Find find_by_order
#define Order order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 mrand(random_device{}());
ll rnd(ll x) { return mrand() % x;}
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0) {while(n%i==0) n/=i;ans=ans*(i-1)/i;}}if(n>1) ans=ans*(n-1)/n;return ans;}
//head

const int maxn=2e6+7;

ll solve(ll T){
	int n;cin>>n;
	cout<<(1000-n%1000)%1000<<endl;
	return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll T=1;
//    cin>>T;
    for(ll cas=1; cas<=T; cas++) {
        solve(T);
    }
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (b + c < a) {
        printf("0\n");
    } else {
        printf("%d\n", b - (a - c));
    }
    return 0;
}


Measured memory_bytes: 128
while true

 h,w = gets.split(' ').collect{|n|n.to_i}
 break if h==0 && w==0
 h.times do |hc|
  char = hc % 2 == 0 ? '#' : '.' 
  w.times do
   print char
   char = char=='#'?'.':'#'
  end
  puts
 end
 puts
end

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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    int P = 2019;
    vector<int> sum(N + 1, 0), ten(N + 1, 1);
    for (int i = N - 1; i >= 0; i--) {
        ten[i] = ten[i + 1] * 10 % P;
    }
    for (int i = N - 1; i >= 0; i--) {
        sum[i] = ((int)(S[i] - '0') * ten[i + 1] % P + sum[i + 1]) % P;
    }

    map<int, int> m;
    for (auto i : sum) {
        m[i]++;
    }

    int ans = 0;
    for (auto i : m) {
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5168
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<b+1;i++){
        if(abs(a-i)<k||abs(b-i)<k){
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char mozi[10];
 	int N,i;
 	int AC=0,WA=0,TLE=0,RE=0;
 	scanf("%d",&N);
 	for(i=0;i<N;i++){
 	scanf("%s",mozi);
	if(strcmp(mozi,"AC")==0)
		AC++;
	else if(strcmp(mozi,"WA")==0)
		WA++;
	else if(strcmp(mozi,"TLE")==0)
		TLE++;
	else if (strcmp(mozi,"RE")==0)
		RE++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",AC,WA,TLE,RE);
	return 0;
}


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

int main() {
    int N;

    cin >> N;

    vector<vector<int>> arr(N, vector<int>(3));
    vector<vector<int>> dp(N, vector<int>(3));

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

    
    for (int i = 0; i < 3; i++) {
        dp[0][i] = arr[0][i];
        //cout << "dp[0][" << i << "] = " << dp[0][i] << endl;
    }

    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) {
                    continue;
                }

                dp[i][j] = max(dp[i][j], dp[i - 1][k] + arr[i][j]);
            }
        }
    }

    int m = max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});

    cout << m << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(){
  int n;
  while (true){
    scanf("%d",&n);
    if (n==0) return 0;
    int cnt=0;
    for (int i=0;i<182;i++){
      if (i*i>n) break;
      for (int j=i;j<182;j++){
        if (i*i+j*j>n) break;
        for (int k=j;k<182;k++){
	  if (i*i+j*j+k*k>n) break;
          for (int l=k;l<182;l++){
            if (i*i+j*j+k*k+l*l>n) break;
            if (i*i+j*j+k*k+l*l==n) cnt++;

	  }
        } 
      }
    }
    printf("%d\n",cnt);
  }
}

Measured memory_bytes: 1028
import math
from decimal import *
A,B,H,M = list(map(int,input().split()))

#A H:時
#B M:分
theta = abs((H/12+M/60*1/12)-M/60) * 2* math.pi
thetar = math.degrees(theta)
# theta = abs((Decimal(H)/Decimal(12) - Decimal(M)/Decimal(60)))*Decimal(2)*Decimal(math.pi)
# print(thetar)
ans = math.sqrt(A**2 + B**2 - 2* A* B*math.cos(theta))
print(ans)


Measured memory_bytes: 10308
n , x = map(int,input().split())
a = sorted(list(map(int,input().split())))
cnt = 0
if x > sum(a):
	print(n - 1)
	exit()
    
for i in range(n):
	if (x - a[i]) >= 0:
		x -= a[i]
		cnt += 1
	else:
		break
        
print(cnt)
	


Measured memory_bytes: 2940
import sys
from collections import deque
#N,Q = list(map(int,input().split()))
N,Q = [int(i) for i in input().split()]
G=[]
for i in range(N):
    G.append([])

for i in range(N-1):
    #a,b = list(map(int,input().split()))
    a,b = [int(j) for j in input().split()]
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N

for i in range(Q):
    #p,x = list(map(int,input().split()))
    p,x = [int(j) for j in input().split()]
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.append(u)


ans = ' '.join([str(x) for x in c])

print(ans)

Measured memory_bytes: 122304
#include<stdio.h>

int main(){
char a[2][101];
int i=0,j=0,f=0;
scanf("%s %s",a[0],a[1]);
while(a[0][i]!=0)i++;
while(a[1][j]!=0)j++;
if(i>j)f=1;
else if(i<j)f=-1;
else{
 for(i=0;i<j;i++){
if(a[0][i]-'0'>a[1][i]-'0'){
f=1;
break;
}
if(a[0][i]-'0'<a[1][i]-'0'){
f=-1;
break;
}
}
}
if(f==1)puts("GREATER");
if(f==-1)puts("LESS");
if(f==0)puts("EQUAL");
return 0;
}

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

int main () {
    int a, b; cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9 ) cout << a * b << endl;
    else cout << "-1" << endl;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	sort(a.begin(), a.end());
	int lb = 0, ub = 13;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		vector<vector<bool> > dp(13, vector<bool>(13));
		dp[0][0] = true;
		rep(i, N) {
			vector<vector<bool> > _dp(13, vector<bool>(13));
			rep(x, 13) rep(y, 13) if (dp[x][y]) {
				if (a[i] - x >= mid) _dp[a[i]][y] = true;
				if (a[i] - y >= mid) _dp[x][a[i]] = true;
			}
			dp = _dp;
		}
		bool ok = false;
		rep(x, 13) rep(y, 13) if (dp[x][y] && 24 - x - y >= mid) ok = true;
		if (ok) lb = mid;
		else ub = mid;
	}
	cout << lb << endl;
}


Measured memory_bytes: 256
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = [0]
B = [0]
for i in range(n):
    A.append(A[-1] + a[i])
for j in range(m):
    B.append(B[-1] + b[j])
    
ans = 0
for i in range(n + 1):
    time = A[i]
    b_index = 0
    if time > k:
        break
    b_index = bisect_right(B, k - time)
    ans = max(ans, i + b_index - 1)
print(ans)

Measured memory_bytes: 47704
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::string S;
    std::cin >> S;



    //  ->E
    // W <-
    std::vector<int64_t> esum;
    std::vector<int64_t> wsum;

    int64_t e, w;
    e = w = 0;
    
    for (size_t i = 0; i < N; ++i) {
        if (S[i] == 'E') {
            e++;
        }
        else {
            w++;
        }
        esum.push_back(e);
        wsum.push_back(w);
    }

    int64_t m = INT64_MAX;
    for (int64_t i = 0; i < N; ++i) {
        // 0 -- i-1
        int64_t turntoE = 0;
        if (i > 1) {
            turntoE = wsum[i-1];
        }

        int64_t turntoW = 0;
        if (i < N) {
            turntoW = esum[N-1] - esum[i];
        }
        m = std::min(m, turntoE + turntoW);
    }

    std::cout << m << std::endl;

    return 0;
}


Measured memory_bytes: 10988
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,i,a[105],p[105],g[105][105],len[105];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",a+i);
	sort(a+1,a+1+n);
	if(a[1]*2<a[n])
	{
		printf("Impossible");
		return 0;
	}
	for(i=1;i<=n;++i)
		if(!p[a[i]])
			p[a[i]]=i;
		else if(!p[a[n]-a[i]])
			p[a[n]-a[i]]=i;
		else if(a[i]>(a[n]-1)/2+1)
			g[a[i]-1][++len[a[i]-1]]=i;
		else
		{
			printf("Impossible");
			return 0;
		}
	for(i=0;i<=a[n];++i)
		if(!p[i])
		{
			printf("Impossible");
			return 0;
		}
	printf("Possible");
	return 0;
}


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

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  if (x < 0) {
    x = -x;
  }
  ll ans = 0;
  if (x/d >= k) {
    ans = x - k*d;
  } else {
    if ((k - x/d) % 2 == 0) {
      ans = x % d;
    } else {
      ans = abs((x % d) - d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long x = long.Parse(input[1]);
    long answer = 0;
    long lookNum = n;

    long[] allCount = new long[51];
    long[] patyCount = new long[51];
    
    allCount[0] = 1;
    patyCount[0] = 1;
    for(int i = 1; i <= 50; i++)
    {
      allCount[i] = 2*allCount[i-1] + 3;
      patyCount[i] = 2*patyCount[i-1] + 1;
    }

    while(true)
    {  
      if(x <= 1 && lookNum > 0) break;
      if(lookNum == 0)
      {
        if(x == 1) answer++;
        break;
      }
      
      if(x < allCount[lookNum]/2+1)
      {
        x--;
        lookNum--;
        continue;
      }
      else if(x == allCount[lookNum]/2+1)
      {
        x -= 2;//左と中央を除く
        lookNum--;
        answer++;
        continue;
      }
      else if(x < allCount[lookNum])
      {
        //Console.WriteLine("a");
        x -= 2;
        x -= allCount[lookNum-1];
        answer++;
        answer += patyCount[lookNum-1];
        lookNum--;
        //Console.WriteLine(answer);
        continue;
      }else
      {
        answer += patyCount[lookNum];
        break;
      }
      
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    if(n == 1){
        cout << k << endl;
        return 0;
    }
    ll low = 0, high = k+1;
    while(high-low > 1){
        ll mid = (high+low)/2;
        ll res = k-mid, bef = mid;
        bool f = false;
        for(ll i = 1; i < n; i++){
            ll tmp = bef/2;
            if(tmp == 0)    break;
            if(res < tmp){
                f = true;
                break;
            }
            res -= tmp;
            bef = tmp;
        }
        if(f)   high = mid;
        else    low = mid;
    }
    cout << low << endl;
    return 0;
}


Measured memory_bytes: 3120
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t,ans;

    cin>>n;

    cin>>ans;

    For(i,2,n)
    {
        cin>>m;

        ans = ans^m;
    }

    if(ans==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
ios_base::sync_with_stdio(false); \
cin.tie(0);                       \
cout.tie(0);
#define test  \
int t;    \
cin >> t; \
while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
for (auto i : a)      \
    cerr << i << " "; \
cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
for (int u = 0; u < n; u++) \
{                           \
    cout << ar[u] << " ";   \
}                           \
cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
	rootdada;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
	string s;
	cin >> s;
	int c = 0, ans = 0;
	rep(i, 0, s.length())
	{
		if (s[i] == 'R')
			c++;
		else
			c = 0;
		ans = max(c, ans);
	}
	cout << ans << endl;

}


Measured memory_bytes: 3640
# coding: utf-8

def toAdd(a, b):
    return int(a) + int(b)
    
def toSubtract(a, b):
    return int(a) - int(b)

def toMultiply(a, b):
    return int(a) * int(b)

def toDivide(a, b):
    return int(int(a) / int(b))
    
operations = {
    "+": toAdd,
    "-": toSubtract,
    "*": toMultiply,
    "/": toDivide
    }

while True:
    valueA, operation, valueB = input().split(" ")
    if operation == "?":
        break
    function = operations[operation]
    print("{0}".format(int(function(valueA, valueB))))

Measured memory_bytes: 7640
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
	unsigned short *A,*B;
	
	int C[VMAX+1];
	int n,i,j;
	scanf("%d",&n);
	
	A=malloc(sizeof(short)*n+1);
	B=malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++)C[i]=0;
	
	for(i=0;i<n;i++){
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
	
	for(j=1;j<=n;j++){
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n;i++){
		if(i>1)printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 9552
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ull;
typedef long long ll;
//const int INF=0x3f3f3f3f;
const int INF=1e9;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e9+7;
const ll maxn=1e5+7;
const int MAXN=1005;
const int MAX=5e2+5;
const int MAX_N=MAX;
const ll MOD=1e9+7;
//const double eps=0.00000001;
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
int n;
int num[4];
int main()
{
    scanf("%d",&n);
    bool st=false;
    for(int i=1;i<=n;i++)
    {
        int tem;
        scanf("%d",&tem);
        if(tem%2)
            ++num[1];
        else
            ++num[tem%4];
    }
    if(num[2])
    {
        if(num[0]>=num[1])
            st=true;
    }
    else
    {
        if(num[0]>=num[1]-1)
            st=true;
    }
    if(st)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
//https://arc096.contest.atcoder.jp/tasks/arc096_c

#include<bits/stdc++.h>
#define int long long
const int N = 3005;
using namespace std;

int n, mod, f[N][N], c[N][N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod;
}

int po(int n, int k, int Mod = mod){
    int ans = 1;
    while(k){
        if (k&1) ans = 1LL * ans * n % Mod;
        n = 1LL * n * n % Mod;
        k >>= 1;
    }
    return ans;
}

int cal(int x, int Max){
    x = po(po(2, x), mod-2);
    x = mod-x+1; if (x >= mod) x -= mod;
    return po(x, Max);
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> mod;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++){
            f[i][j] = ((j == 0) ? 1 : (1LL * f[i-1][j] * (j+1) + f[i-1][j-1]) % mod);
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++){
            c[i][j] = ((j == 0) ? 1 : (c[i-1][j] + c[i-1][j-1]) % mod);
        }
    }
    for (int a = 0; a <= n; a++){
        int sum = 0;
        for (int i = 0; i <= a; i++) {
            add(sum, 1LL * f[a][i] * po(po(2, n-a), i) % mod);
        }
        sum = 1LL * sum * c[n][a] % mod;
        sum = 1LL * sum * po(2, po(2, n-a, mod-1)) % mod;
        if (a&1) {
            sum = -sum; if (sum < 0) sum += mod;
        }
        add(ans, sum);
    }
    cout << ans;
}


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

int  main()
{
	long n; cin >> n;
	long sum = 0;
	vector<long> v(n);
	long total = 0;
	rep(i, n)
	{
		cin >> v[i];
		total += v[i];
	}
	// sort(v.begin(), v.end());
	priority_queue<long, vector<long>, greater<long> > q;
	long ans = LONG_MAX;
	rep(i, n-1)
	{
		sum+=v[i];
		q.push(labs(sum - (total - sum)) );
	}
	cout << q.top() << endl;
	// cout << ans << endl;
	return (0);
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    ll co = 0;
    vector<P> a;
    rep(i, n)
    {
        ll k;
        cin >> k;
        a.push_back(P(k, i));
    }
    sort(a.begin(), a.end());
    rep(i, n)
    {
        if (abs(a[i].second - i) % 2 == 1)
        {
            co++;
        }
    }
    cout << (co + 1) / 2 << endl;
}

Measured memory_bytes: 5336
from math import gcd, sqrt, ceil
from functools import reduce

def sieve(n):
    A = list(range(n+1))
    for i in range(2, n+1 ,2):
        A[i] = 2
    for j in range(3, ceil(sqrt(n+1))+1, 2)[::-1]:
        for i in range(j, n+1, j):
            A[i] = j
    return A

def factorize(n, A):
    factors = set()
    while n != 1:
        f = A[n]
        factors.add(f)
        n //= f
    return factors

# def factorize(n):
#     factors = set()
#     if n % 2 == 0:
#         factors.add(2)
#         n //= 2
#     while n % 2 == 0:
#         n //= 2
#     for i in range(3, ceil(sqrt(n + 1)) + 1):
#         if n % i == 0:
#             factors.add(i)
#             n //= i
#         while n % i == 0:
#             n //= i
#     if n > 2:
#         factors.add(n)
#     return factors

_, *aa = map(int, open(0).read().split())

def main(aa):
    pair_co = True
    A = sieve(10**6)
    all_factors = set()
    for a in aa:
        factors = factorize(a, A)
        for factor in factors:
            if factor in all_factors:
                pair_co = False
                break
            else:
                all_factors.add(factor)
        if not pair_co:
            break
    if pair_co:
        return 'pairwise coprime'
    elif reduce(gcd, aa) == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'

print(main(aa))

Measured memory_bytes: 215220
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto X = RDA(-1);

	long ans = long.max;
	foreach (i; 0..100)
	{
		long cnt;
		foreach (e; X)
		{
			cnt += (e-i)^^2;
		}
		ans.chmin(cnt);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    vector<ll> k(Q);
    REP(i, Q) cin >> k[i];

    REP(q, Q){
    	ll res = 0;
    	ll a=0, b=0, m=0;
	    REP(i, N){

	    	if(i>=k[q]){
	    		if(S[i-k[q]] == 'D'){
	    			a--;
	    			b -= m;
	    		}
	    		if(S[i-k[q]] == 'M'){
	    			m--;
	    		}
	    	}

	    	if(S[i] == 'D'){
	    		a++;
	    	}
	    	if(S[i] == 'M'){
	    		b += a;
	    		m++;
	    	}
	    	if(S[i] == 'C'){
	    		res += b;
	    	}

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

Measured memory_bytes: 1948
#include <iostream>
 
int main()
{
int n=0;
  bool ok=true;
  std::cin>>n;
for(int i=0; i<n ;++i){
	 int x=0;
    std::cin>>x;
    if(x%2==0){
    	if((x%3==0)||(x%5==0))
          continue;
      	
      	ok=false;
    }
}
  if(ok)
  std::cout<<"APPROVED"<<std::endl;
  else
    std::cout<<"DENIED"<<std::endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (a % 3 == 0) cout << "Possible";
  else if (b % 3 == 0) cout << "Possible";
  else if (c % 3 == 0) cout << "Possible";
  else cout << "Impossible";
  cout << endl;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
color_val=0
bigList=[]
for i in range(1,400):
  if i in a:
    color_val+=1
    break
for s in range(400,800):
  if s in a:
    color_val+=1
    break
for t in range(800,1200):
  if t in a:
    color_val+=1
    break
for u in range(1200,1600):
  if u in a:
    color_val+=1
    break
for q in range(1600,2000):
  if q in a:
    color_val+=1
    break
for e in range(2000,2400):
  if e in a:
    color_val+=1
    break
for f in range(2400,2800):
  if f in a:
    color_val+=1
    break
for g in range(2800,3200):
  if g in a:
    color_val+=1
    break
for z in a:
  if z >=3200:
    bigList.append(z)
    
max=color_val+len(bigList)
if color_val!=0:
  print(color_val,max)
else:
  print(1,max)
    
    

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

int main(){
  int N;
  set<string> S;
  cin >> N;
  rep(i, N){
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 19252
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N, M, K;
    cin >> N >> M >> K;
    
    vector<int> A(N+1);
    vector<int> B(M+1);
    vector<long long> each_Time_A(N+1,0);
    vector<long long> each_Time_B(M+1,0);
    long long max_Time_A = 0, max_Time_B = 0;
    
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        each_Time_A[i] = max_Time_A + A[i];
        max_Time_A += A[i];
    }    
    for(int i = 1; i <= M; i++){
        cin >> B[i];
        each_Time_B[i] = max_Time_B + B[i];
        max_Time_B += B[i];
    }    
    
    int ans = 0;
    for(int i = 0; i <= N; i++){
        
        if(each_Time_A[i] + each_Time_B[M] <= K && M >= 0){
            ans = max(ans, i + M);
            continue;
        }
        
        else{
            while(M != 0){
                M--;
                if(each_Time_A[i] + each_Time_B[M] <= K && M >= 0){
                    ans = max(ans, i + M);
                    break;
                }
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 7624
#include <iostream>
#include <algorithm>
using namespace std;
#include <vector>
#include <map>
#include <set>
#include <cmath>    //floor ceil
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>
#include <cstdlib>

#define endl '\n'
#define lli long long int

int main () {
    lli ans=0;
    string n;
    cin >> n;
    for (int i=0;i<n.size();i++) {
        ans += (n[i]-48);
    }
    if(ans%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3744
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

# fact(int)
def fact(n):
  if(n == 1):
    return 1
  else:
    return (n * fact(n - 1))

# gcd(int,int)
def gcd(a,b):
  if a == 0:
    return b
  elif b == 0:
    return a
  else:
    return gcd(b,a % b)

# lcm(int,int)
def lcm(a,b):
  return (a * b / gcd(a,b))

# qsort(array[])
def qsort(seq):
  if len(seq) < 1:
      return seq
  pivot = seq[0]
  left = []
  right = []
  for x in range(1, len(seq)):
    if seq[x] <= pivot:
        left.append(seq[x])
    else:
        right.append(seq[x])
  left = qsort(left)
  right = qsort(right)
  foo = [pivot]
  return (left + foo + right)

a,b = map(int, input().split())
#  = int(input())
#  = raw_input().split()
#  = list(int(i) for i in input().split())  

k = (a + b) // 2;
if abs(k - a) == abs(k - b):
  print(k)
else:
  print("IMPOSSIBLE")


Measured memory_bytes: 5128
#include<stdio.h>

int main()
{
   int x, y, i, X, Y;

   scanf("%d %d", &x, &y);

   if(x > y){
      X = x%y;
      for(i=X; i>=1; i--){
         if(X%i == 0){
            if(y%i == 0){
               printf("%d\n", i);
               return 0;
            }
         }
      }
   }

   else if(x < y){
      Y = y%x;
      for(i=Y; i>=1; i--){
         if(Y%i == 0){
            if(x%i == 0){
               printf("%d\n", i);
               return 0;
            }
         }
      }
   }

   else
      printf("%d\n", x);
      return 0;

}

Measured memory_bytes: 1848
cards_size = gets.to_i
cards = gets.split(" ").map(&:to_i)
cards.sort!{ |a, b| b <=> a }
alice = 0
bob = 0
isAliceTurn = true
cards.each do |card|
  if isAliceTurn then
    alice += card
    isAliceTurn = false
  else
    bob += card
    isAliceTurn = true
  end
end
puts alice - bob

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[1001],f,g,h,j,i,k;
	scanf("%d %d",&a,&f);
	for(i=0;i<a;i++)
		scanf("%d",&d[i]);
	for(s=1;s<=f;s++){
		for(i=0;i<a-1;i++){
			if(d[i+1]%s<d[i]%s){
				g=d[i];
				d[i]=d[i+1];
				d[i+1]=g;
			}
		}
	}
	for(i=0;i<a;i++)
		printf("%d\n",d[i]);
	return 0;
}

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

int main() {
	int s, cnt1=0, cnt2=0;
	for (int i = 0; i < 3; ++i) {
		cin >> s;
		if (s == 5) cnt1++;
		if (s == 7) cnt2++;
	}
	if (cnt1 == 2 && cnt2 == 1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <sstream>
#include <vector>

using namespace std;
int calcReversePoland(string str);

int main()
{
	string str;
	getline(cin, str);
	
	cout << calcReversePoland(str) << endl;

	return 0;
}

int calcReversePoland(string str) {
	stringstream ss(str);
	vector<int> stack;
	string buff;
	int cnt = 0;
	
	// main.
	while (getline(ss, buff, ' ')) {
		stringstream ss(buff);
		int x, y, z;
		if (cnt > 1) {
			x = stack[cnt - 1];
			y = stack[cnt - 2];
		}
		int flg = 0;
		// オペランドの場合
		switch (buff[0]) {
			case '+':
				z = y + x;
				flg = 1;
				break;
			case '-':
				z = y - x;
				flg = 1;
				break;
			case '*':
				z = y * x;
				flg = 1;
				break;
		}

		if (flg == 1) {
			stack.pop_back();
			stack.pop_back();
			cnt -= 2;
		} else {
			ss >> z;
		}
		stack.push_back(z);
		cnt++;
	}
	
	return stack[0];
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
cout<<n+n*n+n*n*n;
return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    
int main(){
    int x,n;
    cin>>x>>n;
    vector<bool> p(101,0);
    
    if(n==0){
        cout<<x;
        return 0;
    }
    rep(i,n){
        int q;
        cin>>q;
        p[q]=1;
    }

    for(int i=0;;i++){
        if(p[x-i]==0){
            cout<<x-i;
            return 0;
        }
        else if(p[x+i]==0){
            cout<<x+i;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,ans;
  int a,pa,ha=0,sa=0,nd[8],da=10000000;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    for(int i=0;i<8;i++){
      pa = a;
      pa /= da;
      nd[i] = pa;
      pa *= da;
      a -= pa;
      da /= 10;
    }
    da = 10000000;
    sort(nd,nd+8);
    for(int i=0;i<8;i++){
      sa += nd[i] * da;
      da /= 10;
    }
    da = 10000000;
    sort(nd,nd+8,greater<int>());
    for(int i=0;i<8;i++){
      ha += nd[i] * da;
      da /= 10;
    }
    ans = ha - sa;  
    cout << ans << endl;
    da = 10000000;
    sa = 0;
    ha = 0;
  }
  return 0;
}

Measured memory_bytes: 1180
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, C, c, D[30][30] = {}, T[3][30] = {}, ans = 1000000000;
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c;
			c--;
			T[(i + j) % 3][c]++;
		}
	}
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			if (i != j) {
				for (int k = 0; k < C; k++) {
					if (i != k && j != k) {
						int count = 0;
						for (int l = 0; l < C; l++) {
							count += D[l][i] * T[0][l];
							count += D[l][j] * T[1][l];
							count += D[l][k] * T[2][l];
						}
						ans = min(ans, count);
					}
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256