akhauriyash/Code-Regression huggingface dataset:
N, A, B, C = map(int, input().split())
dt = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
Q = [dt[input()] for _ in range(N)]


class Game:
    def __init__(self, ABC):
        self.ABC = ABC
        self.ds = {0: 'A', 1: 'B', 2: 'C'}
        self.ans = []

    def add_q0(self, q0, q1):
        self.ans.append(self.ds[q0])
        self.ABC[q0] += 1
        self.ABC[q1] -= 1

    def add_q1(self, q0, q1):
        self.ans.append(self.ds[q1])
        self.ABC[q0] -= 1
        self.ABC[q1] += 1


def solve1(ABC):
    G = Game(ABC)
    for q0, q1 in Q:
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            exit()
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        else:
            G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


def solve2(ABC):
    G = Game(ABC)
    for i, (q0, q1) in enumerate(Q):
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            exit()
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        elif G.ABC[q1] == 0:
            G.add_q1(q0, q1)
        elif G.ABC[q0] == G.ABC[q1] == 1 and i < N - 1:
            if q0 in Q[i + 1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
        else:
            # 余裕の無い方に足しておく
            if G.ABC[q0] <= G.ABC[q1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


def solve3(ABC):
    G = Game(ABC)
    for q0, q1 in Q:
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            exit()
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        elif G.ABC[q1] == 0:
            G.add_q1(q0, q1)
        else:
            # 余裕の無い方に足しておく
            if G.ABC[q0] <= G.ABC[q1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


S = A + B + C
if S == 0:
    print('No')
elif S == 1:
    solve1([A, B, C])
elif S == 2:
    solve2([A, B, C])
else:
    solve3([A, B, C])


Measured memory_bytes: 12376
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
char buf[114514];
string S;
vector<int> es[114514];

int main() {
  scanf("%s", buf);
  N = strlen(buf);
  S = buf;
  S = "0" + S;
  rep(i, N+1) {
    if (S[i] != S[N-i]) {
      puts("-1");
      return 0;
    }
  }

  if (S[1] != '1') {
    puts("-1");
    return 0;
  }

  int p = 0;
  reps(i, 1, N) {
    int v = i;
    if (S[i] == '1') {
      es[v].eb(p);
      p = v;
    } else if (S[i] == '0') {
      es[p].eb(v);
    } else assert(0);
  }
  assert(p == N-1);
  rep(v, N) {
    for (int u : es[v]) {
      cout << v+1 << " " << u+1 << endl;
    }
  }
}


Measured memory_bytes: 7424
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int getSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += (n % 10);
        n /= 10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int res = 0;
    for (int i = 1; i <= n; ++i){
        int dsum = getSumOfDigits(i);
        if (a <= dsum && dsum <= b) {
            res += i;
        }
    }

    cout << res << endl;
}


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

int G[1001][1001]={};

int main() {
 UL N; scanf("%u",&N);
 rep(i,N){
  UL x1,y1,x2,y2; scanf("%u%u%u%u",&x1,&y1,&x2,&y2);
  G[x1][y1]++;
  G[x2][y1]--;
  G[x1][y2]--;
  G[x2][y2]++;
 }
 rep(x,1000)rep(y,1000) G[x][y+1]+=G[x][y];
 rep(x,1000)rep(y,1000) G[x+1][y]+=G[x][y];
 int ans=0;
 rep(x,1000)rep(y,1000) ans=max(ans,G[x][y]);
 printf("%d\n",ans);
 return 0;
}



Measured memory_bytes: 7120
error_flag = 0;                                                     
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if b-a>k:error_flag=1
if c-a>k:error_flag=1
if d-a>k:    error_flag=1
if e-a>k:error_flag=1
if c-b>k:error_flag=1
if d-b>k:error_flag=1
if e-b>k:error_flag=1
if d-c>k:error_flag=1
if e-c>k:error_flag=1
if e-d>k:error_flag=1

if error_flag == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long k,a,b;
int main(){
	cin>>k>>a>>b;
	if(a>=k){puts("1");return 0;}
	if(b>=a){puts("-1");return 0;}
	cout<<((k-a)/(a-b)+((k-a)%(a-b)>=1?1:0))*2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_V = 250;

int V, match[MAX_V], used[MAX_V];
vector<int> G[MAX_V];

bool dfs(int v){
  used[v] = true;
  REP(i, G[v].size()){
    int u = G[v][i], w = match[u];
    if(w < 0 || (!used[w] && dfs(w))){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match, -1, sizeof(match));
  REP(v, V)
    if(match[v] < 0){
      memset(used, 0, sizeof(used));
      if(dfs(v)) ++res;
    }
  return res;
}

int main() {
  int X, Y, E; cin >>X >>Y >>E;
  V = X + Y;
  REP(i, E){
    int u, v; cin >>u >>v;
    v += X;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  cout <<bipartite_matching() <<endl;
  return 0;
}

Measured memory_bytes: 1348
main :: IO ()
main = do
    n <- readLn :: IO Int
    b <- map read . words <$> getLine :: IO [Int]
    print . sum . solve $ head b : b
  where
    solve [] = []
    solve (i:j:xs) = (if i > j then j else i) : solve (j:xs)
    solve (i:xs) = [i]



Measured memory_bytes: 1020
def culc_mp(l,num):
  mp = (len(l)-1)*10
  mp += abs(sum(l)-num)
  return(mp)

n, a, b, c = map(int, input().split())
l = []
for i in range(n):
	l.append(int(input()))

min_mp = float('inf')
for i in range(4**n):
  a_l = []
  b_l = []
  c_l = []
  mp = 0
  for j in range(n):
    tmp  = (i >> j*2) & 3
    num = l[j]
    if tmp == 0:
      a_l.append(num)
    elif tmp == 1:
      b_l.append(num)
    elif tmp == 2:
      c_l.append(num)
    
  if len(a_l) * len(b_l) * len(c_l) == 0:
      continue
    
  mp += culc_mp(a_l,a)
  mp += culc_mp(b_l,b)
  mp += culc_mp(c_l,c)
  if mp < min_mp:
    min_mp = mp
    
print(min_mp)
    

  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, k, dp, ss[200005], mod = 998244353;
pi arr[11];

inline ll query(ll x, ll y) {
	x = max(x, 1ll);
	if (x > y) return 0;
	return (ss[y] - ss[x-1] + mod) % mod;
}

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, k) cin >> arr[i].f >> arr[i].s;
	ss[1] = 1;
	FOR(i, 2, n) {
		dp = 0;
		FOR(j, 1, k) dp = (dp + query(i-arr[j].s, i-arr[j].f)) % mod;
		ss[i] = (ss[i-1] + dp) % mod;
	}
	cout << dp;
}


Measured memory_bytes: 5208
K,N=map(int, input().split())
A=[int(i) for i in input().split()]
D=[0]*(N)
sum=0
for i in range(0, N-1):
  D[i]=A[i+1]-A[i]
  sum+=D[i]
D[N-1]=A[0]-A[N-1]+K
sum+=D[N-1]
dist=-1
for i in range(0, N):
  temp=sum-D[i]
  if(dist==-1):
    dist=temp
  else:
    dist=min(temp, dist)
print(dist)


Measured memory_bytes: 26444
# ABC132 B Ordinary-Number

n = int(input())
p = list(map(int, input().split()))

temp = 0

for i in range(1, len(p)-1):
    if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
        temp += 1
        
print(temp)

Measured memory_bytes: 3060
n = int(input())
b = list(map(int, input().split()))

ans = []
for _ in range(n):
    for i, bi in enumerate(b[::-1]):
        if len(b) == bi + i:
            ans.append(b.pop(len(b) - i - 1))
            break
print(*(ans[::-1] if len(ans) == n else [-1]), sep='\n')


Measured memory_bytes: 63184
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}

int main()
{
	io;
    int k,x;
    cin>>k>>x;
    if(500*k>=x)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define UF_RANK 1 // 1/0: rankによる経路圧縮をする/しない
#define UF_SIZE 1 // 1/0: 連結成分のサイズを記録する/しない

struct UnionFind{
  vector<int> root;
#if (UF_RANK==1)
  vector<int> rank;
#endif
#if (UF_SIZE==1)
  vector<int> size;
#endif

  UnionFind(int N): root(N)
#if (UF_RANK==1)
                  , rank(N)
#endif
#if (UF_SIZE==1)
                  , size(N,1)
#endif
  { iota(root.begin(), root.end(), 0); }

  int find(int a){
    if(root.at(a)==a){
      return a;
    }
    else{
      return root.at(a)= find(root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);
#if (UF_RANK==1)
    if(r_a != r_b){
      if(rank.at(r_a) < rank.at(r_b)){
        root.at(r_a)= r_b;
        #if (UF_SIZE==1)
        size.at(r_b)+= size.at(r_a);
        #endif
        return;
      }
      else{
        root.at(r_b)= r_a;
        #if (UF_SIZE==1)
        size.at(r_a)+= size.at(r_b);
        #endif
        if(rank.at(r_a)==rank.at(r_b)) rank.at(r_a)++;
        return;
      }
    }
#else
    if(r_a != r_b){
      root.at(r_b)= r_a;
      #if (UF_SIZE==1)
      size.at(r_a)+= size.at(r_b);
      #endif
      return;
    }
#endif
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

#if (UF_SIZE==1)
  int get_size(int a){
    return size.at(find(a));
  }
#endif
};

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

  UnionFind uf(N);
  vector<int> offset(N,1); // ans.at(i)= (iが属する連結成分のサイズ)- 1(自分自身)- (#iの友人)- (#iと同じ連結成分に属してブロック関係にある人)
                           //          = uf.get_size(i)        - offset.at(i)
  int buf1,buf2;
  for(int i_f=0; i_f<M; i_f++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    uf.unify(buf1, buf2);
    offset.at(buf1)++;
    offset.at(buf2)++;
  }
  for(int i_b=0; i_b<K; i_b++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    if(uf.are_comrade(buf1, buf2)){
      offset.at(buf1)++;
      offset.at(buf2)++;
    }
  }
  
  for(int i=0; i<N-1; i++){
    cout << uf.get_size(i)- offset.at(i) <<" ";
  }
  cout << uf.get_size(N-1)- offset.at(N-1) << endl;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int SIZE = 1 << 17;

long long n, k[200005], ans, sum;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		if (i&&k[i] - k[i - 1] > 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (k[0] > 0) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		if (!(k[i] + 1 == k[i + 1])) { sum += k[i]; }
	}
	cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<int,int>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














//int ct[100005][2];
const int N=100005;
int n;
int h[N];
int main()
{
     cin>>n;
     int k;
     cin>>k;
     for(int i=1;i<=n;i++)cin>>h[i];
     int dp[n+1];
     for(int i=0;i<=n;i++)dp[i]=INT_MAX;
     dp[0]=0;
     dp[1]=0;
     dp[2]=abs(h[2]-h[1]);
     for(int i=3;i<=n;i++)
     {
          for(int j=i-1;j>=1&&j>=i-k;j--)
          {
               dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
          }
     }
     cout<<dp[n];
}
























 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

bool isP(string s) {
   string t = s;
   reverse(t.begin(), t.end());
   return s == t;
}
int main() {
   string s;
   cin >> s;
   int n = s.size();
   bool ok = true;
   if (!isP(s)) ok = false;
   if(!isP(s.substr(0, n/2))) ok = false;
   
   if(ok) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    static int MOD = 1000000007;

    public static void main(String[] args) {

        //int ans=Integer.MAX_VALUE;
        Scanner sc = new Scanner(System.in);
        int ans =0;
        int h =sc.nextInt();
        int n=sc.nextInt();
        int[] a = new int[n],b=new int[n];
        int[][] dp = new int[n][h+1];


        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }

        for(int i=1;i<h+1;i++){
            if(i%a[0]==0)dp[0][i]=(i/a[0])*b[0];
            else dp[0][i]=(i/a[0]+1)*b[0];
        }

        for(int i=1;i<n;i++){
            for(int j=1;j<h+1;j++){
                if(j<=a[i]){
                    dp[i][j]=Math.min(b[i],dp[i-1][j]);
                }else{

                dp[i][j]=Math.min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
                }
            }
        }


        System.out.println(dp[n-1][h]);

    }


}




Measured memory_bytes: 80828
#include <iostream>

using namespace std;

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

	int res[3];
	res[0] = A+B;
	res[1] = A-B;
	res[2] = A*B;
	int ans = res[0] > res[1] ? res[0] : res[1];
	ans = res[2] > ans ? res[2] : ans;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# x**2 + x + 4 = n

n = gets.strip.to_i
m = Array.new(n,0)
nn = Integer.sqrt(n)
1.upto(nn) do |x|
  1.upto(nn) do |y|
    1.upto(nn) do |z|
      t = x * x + y * y + z * z + x * y + y * z + z * x
      break if t > n
      m[t-1] += 1
    end
  end
end
n.times do |i|
  p m[i]
end


Measured memory_bytes: 14488
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define sc second
#define INF 3000000000
#define SINF 2*(1e18)
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define D(x) cout << #x " = " << (x) << endl
#define mem(a,val) memset(a,val,sizeof a)
#define cc continue
#define bb break
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
//priority_queue<ll> pq;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
bool pal(string s){
  ll j=s.size()-1;
  ll sw=0;
  for(ll i=0;i<s.size()/2;i++){
    if(s[i]!=s[j]){sw=1;break;}j--;}
  if(sw)return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    string s;
    while(cin>>s){
      if(count(all(s),'7')>0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int a;
	int b;

	// read inputs
	cin >> a;
	cin >> b;
	
	int fee;

	if (a > 12) {
		fee = b;
	} else if (a <= 12 && a >= 6) {
		fee = b/2;
	} else {
		fee = 0;
	}

	cout << fee << endl;
	
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if(a < b && b < c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24332
open Printf open Scanf
open Array

let print_array f a = Array.iter (fun v -> printf "%s " @@ f v) a; print_newline ()

let () = scanf " %d %s" @@ fun n s ->
  let a = init n (fun i -> s.[i]) in
  let b = ref @@ 0 in
  let w = ref @@ fold_left (fun u -> function
  | '.' -> u+1 | _ -> u) 0 a in
  init (n+1) (fun i ->
    let res =
      if i=0 then (
        !w
      ) else if i=n then (
        !b
      ) else (
        let ww = !b + (n - i - !w) in
        let wb = !b + !w in
        let bb = (i - !b) + !w in
        fold_left min max_int [|ww;wb;bb|]
      )
    in
    if i<n then (
      if a.(i) = '#' then b := !b + 1
      else w := !w - 1;
    );
    (* printf "%d :: %d,%d :: %d\n"
      i !b !w res; *)
    res
  )
  |> fold_left min max_int
  |> print_int








Measured memory_bytes: 6400
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if 500 * i + 100 * j + 50 * k == x :
				count += 1

print count

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ins(a,b,c) a.insert(a.begin()+b,c)
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,c=1,d=0;
  cin>>a;
  vector<int> b(a);
  fo(i,a)
    cin>>b[i];
  fo(i,a){
    if(b[i]%10!=0)
      c=0;
  }
  if(c)
    cout<<0<<endl;
  else{
    fo(i,a)
      d+=b[i];
    Sort(b);
    if(d%10==0){
    fo(i,a){
      if(b[i]%10!=0){
        d-=b[i];
        break;
      }
    }
    }
    cout<<d<<endl;
  }
}


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

int main()
{

    int N;
    cin >> N;

    int n = N % 1000;
    if (n == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - N % 1000 << endl;
    }

    return 0;
}

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

int main(void){
	int a,b,c,d,e,f;
	double x,y;

	while(cin >> a >> b >> c >> d >> e >> f){
		x = (double)(b*f-c*e)/(b*d-a*e)+0;
		y = (double)(a*f-d*c)/(a*e-b*d)+0;
		printf("%.3f %.3f\n",x,y);
	}

	return 0;

}

Measured memory_bytes: 1192
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

bool isValid(int x, const vector<int>& a, int k)
{
    ll count = 0;
    if (x == 0)
    {
        return false;
    }
    for(auto av : a)
    {
        auto m = av % x;
        count += (m == 0 ? av / x - 1 : av / x);
        if(count > k)
        {
            return false;
        }
    }
    return true;
}

int main(int, const char**)
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int maxLen = 0;
    rep(i, n)
    {
        cin >> a[i];
        maxLen = max(maxLen, a[i]);
    }

    ll l = 0, h = maxLen;
    while(h != l)
    {
        auto t = (l + h) / 2;
        if(isValid(t, a, k))
        {
            h = t;
        }
        else
        {
            if(l == t)
            {
                l = h;
                break;
            }
            l = t;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
    using namespace std;
    #define int long long

    signed main() {
       int n;
       cin>>n;
       int a[n+1]={};
       for(int i=0;i<n;i++)cin>>a[i];
       int b[n+2]={};
       b[1]=abs(a[0]);
       for(int i=1;i<n;i++)b[i+1]=b[i]+abs(a[i]-a[i-1]);
       b[n+1]=b[n]+abs(a[n-1]);
       cout<<b[0]+abs(0-a[1])+b[n+1]-b[2]<<endl;
       for(int i=1;i<n;i++){
           cout<<b[i]+abs(a[i-1]-a[i+1])+b[n+1]-b[i+2]<<endl;
       }

    }


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<int> p3v, p3v2, p5v;
  int p3 = 3;
  while(true) {
    p3v.push_back(p3);
    p3 += 6;
    if (p3 % 5 == 0) p3 += 6;
    if (p3 > 30000) break;
  }
  p3 = 3;
  while(true) {
    p3v2.push_back(p3);
    p3 += 6;
    if (p3 > 30000) break;
  }
  int p5 = 5;
  while(true) {
    p5v.push_back(p5);
    p5 += 10;
    if (p5 % 3 == 0) p5 += 10;
    if (p5 > 30000) break;
  }
  vector<int> ps3(p3v.size()+1), ps5(p5v.size()+1);
  partial_sum(ALL(p3v), begin(ps3)+1);
  partial_sum(ALL(p5v), begin(ps5)+1);
  int k2 = min(15000, n-2);
  int s2 = k2 * (k2+1);
  int k3 = min((int)p3v.size(), n-2-k2);
  int s3 = ps3[k3-1];
  int k5 = n-2-k2-k3;
  int s5 = ps5[k5-1];
  FOR(i,k3,p3v.size()) FOR(j,k5,p5v.size()) {
    if ((s2+s3+p3v[i]) % 5 == 0 && (s2+s5+p5v[j]) % 3 == 0 && (s3+p3v[i]+s5+p5v[j]) % 2 == 0) {
      REP(k,k2) {
        cout << 2*(k+1) << ' ';
      }
      REP(k,k3) {
        cout << p3v[k] << ' ';
      }
      REP(k,k5) {
        cout << p5v[k] << ' ';
      }
      cout << p3v[i] << ' ' << p5v[j] << endl;
      return 0;
    }
  }
  FOR(i,1,15000) {
    k3 = 2*i;
    k2 = n-k3;
    if (k2 > 15000) continue;
    if (k2 <= 0) break;
    s2 = k2*(k2+1);
    if ((s2 % 3) == 0) {
      REP(k,k2) {
        cout << 2*(k+1) << ' ';
      }
      REP(k,k3) {
        if (k) cout << ' ';
        cout << p3v2[k];
      }
      cout << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,C;
  cin>>N>>C;
  VL X(N),V(N);
  rep(i,N) cin>>X[i]>>V[i];
  vector< pair<ll,ll> > P(N);
  rep(i,N) P[i]=mp(X[i],V[i]);
  P.pb(mp(0,0));
  P.pb(mp(C,0));
  sort(all(P));
  VL A(N+1),B(N+1);
  rep(i,N) A[i+1]=A[i]+P[i+1].second-P[i+1].first+P[i].first;
  rep(i,N) B[i+1]=B[i]+P[N-i].second+P[N-i].first-P[N+1-i].first;
  VI E(N+1),F(N+1);
  rep(i,N){
    if(A[i+1]<A[i]){
      A[i+1]=A[i];
      E[i+1]=E[i];
    }else E[i+1]=i+1;
  }
  rep(i,N){
    if(B[i+1]<B[i]){
      B[i+1]=B[i];
      F[i+1]=F[i];
    }else F[i+1]=i+1;
  }
  ll ans=max({0ll,A[N],B[N]});
  rep(i,N+1) ans=max(ans,A[i]+B[N-i]-min(P[E[i]].first,C-P[N+1-F[N-i]].first));
  cout<<ans<<endl;
}

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

int main() {
  int N,n,M=100000000,count=0;
  cin >> N;
  n = N;
  for (int i=8; i>=0; i--) {
    if ((N/(pow(10,i))<1))
      M /= 10;
    else {
      count += N/M;
      N -= (N/M) * M;
      M /= 10;
    }
  }
  if (n%count)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=1005,mod=1e9+7;
int c[N][N];
ll f[N],g[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),k=read();
	For(i,0,n)For(j,c[i][0]=1,i)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	f[0]=1;
	For(i,1,k){
		int a=read();
		mem(g);
		For(i,0,n){
			For(j,0,min(n-i,a)){
				g[i+j]=(g[i+j]+f[i]*c[n-j][a-j]%mod*c[n-i][j])%mod;
			}
		}
		swap(f,g);
	}
	cout<<f[n]<<endl;
}


Measured memory_bytes: 7552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int l,r,ans=inf; cin>>l>>r;
    set<int> s;
    for(int i=l;i<=r;i++){
        if(s.count(i%2019)) break;
        s.insert(i%2019);
    }
    for(auto i:s)for(auto j:s){
        if(i==j) continue;
        ans=min(ans,(2019+i*j)%2019);
    }
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	ll* x = new ll[n] ;
	ll* y = new ll[n];
	ll* p = new ll[n];
	ll* cost = new ll[n + 1];
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i] >> p[i];
		cost[i] = 1e18;
	}
	cost[n] = 1e18;
	long long** tate = new long long*[n];
	long long** yoko = new long long*[n];
	for (int i = 0;i < n;i++) {
		tate[i] = new long long[1 << n];
		yoko[i] = new long long[1 << n];
		for (int j = 0;j < 1 << n;j++) {
			tate[i][j] = abs(x[i]) * p[i];
			yoko[i][j] = abs(y[i]) * p[i];
		}
	}
	// calc tate and yoko
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 1 << n;j++) {
			for (int k = 0;k < n;k++) {
				if (j & 1 << k) {
					tate[i][j] = min(tate[i][j], abs(x[k] - x[i]) * p[i]);
					yoko[i][j] = min(yoko[i][j], abs(y[k] - y[i]) * p[i]);
				}
			}
		}
	}
	int* ind = new int[n];
	for (int i = 0;i < n;i++) {
		ind[i] = 0;
	}
	bool flag = true;;
	while (flag) {
		//syori
		int ind_tate, ind_yoko;
		ind_tate = ind_yoko = 0;
		int honsu = 0;
		for (int i = 0;i < n;i++) {
			if (ind[i] == 1) {
				ind_tate += 1<<i;
				honsu++;
			}
			if (ind[i] == 2) {
				ind_yoko += 1 << i;
				honsu++;
			}
		}
		ll c = 0;
		for (int i = 0;i < n;i++) {
			c += min(tate[i][ind_tate], yoko[i][ind_yoko]);
		}
		cost[honsu] = min(c, cost[honsu]);
		//ind update
		flag = false;
		for (int i = 0;i < n;i++) {
			if (ind[i] < 2) {
				ind[i]++;
				flag = true;
				break;
			}
			else {
				ind[i] = 0;
			}
		}

	}
	for (int i = 0;i <= n;i++) {
		cout << cost[i] << endl;
	}
}

Measured memory_bytes: 10968
import sys

n = int(input())
w = []
for _ in range(n):
  w.append(input())

sw = sorted(w)
for i in range(1, len(sw)):
  if sw[i - 1] == sw[i]:
    print("No")
    sys.exit()

for i in range(1, len(w)):
  if w[i - 1][-1] != w[i][0]:
    print("No")
    sys.exit()

print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct P{
	int a,b,c,d;
}a[100005];
struct edge{
	int k,next;
}e[200005];
int n,h,IN[405],home[405],cnt=-1;
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
int D;
bool vis[405],used[405];
void dfs(int k){
	vis[k]=1;
	if(IN[k]) D=1;
	for(int i=home[k];~i;i=e[i].next) if(!vis[e[i].k])
		dfs(e[i].k);
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&a[i].a,&a[i].b,&a[i].c,&a[i].d);
		int x=a[i].c?a[i].c:a[i].a+h,y=a[i].d?a[i].d+h:a[i].b;
		add(x,y);add(y,x);
		IN[x]--;IN[y]++;
	}
	int t=0;
	for(int i=1;i<=h;i++) if(IN[i]<0) t=1;
	for(int i=h+1;i<=h+h;i++) if(IN[i]>0) t=1;
	if(t) return puts("NO"),0;
	for(int i=1;i<=h+h;i++) if(!vis[i]&&home[i]!=-1){
		D=0;dfs(i);
		if(!D) return puts("NO"),0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3328
#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>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
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)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int a, b;

int main() {

	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
const ll mod=2019;
char s[200005];
ll n,mod1[200005]={0};
int main(){
	scanf("%s",s);
	n=strlen(s);
	ll sum=0,ten=1;
	for(ll i=0;i<n;i++) s[i]-='0';
	for(ll i=n-1;i>=0;i--){
		sum+=ten*s[i];
		ten=(ten*10)%2019;
		sum%=2019;
		mod1[sum]++;
	}
	sum=mod1[0]*(mod1[0]+1)/2;
	for(ll i=1;i<2019;i++) sum+=mod1[i]*(mod1[i]-1)/2;
	printf("%lld\n",sum);
	return 0; 
}



Measured memory_bytes: 3920
from collections import Counter
from functools import reduce
from operator import add

h, w = map(int, input().split())
a_counts = [Counter(input()) for _ in range(h)]
counts = reduce(add, a_counts)

if h%2==0 and w%2==0:
    if all([x%4==0 for x in counts.values()]):
        print('Yes')
        exit()
    else:
        print('No')
        exit()
elif h%2==0 and w%2==1:
    mod4 = [x%4 for x in counts.values()]
    mod2 = [x%2 for x in mod4 if x!=0]

    if all([x==0 for x in mod2]) and len(mod2) <= h//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
elif h%2==1 and w%2==0:
    mod4 = [x%4 for x in counts.values()]
    mod2 = [x%2 for x in mod4 if x!=0]

    if all([x==0 for x in mod2]) and len(mod2) <= w//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    mod4 = [x%4 for x in counts.values()]
    mod2 = [x%2 for x in mod4 if x!=0]
    mod2_0 = [x for x in mod2 if x==0]
    mod2_1 = [x for x in mod2 if x==1]

    if len(mod2_0) <= w//2 + h//2 and len(mod2_1) <= 1:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

Measured memory_bytes: 39792
#include <stdio.h>

#define GRAY 1
#define BROWN 2
#define GREEN 4
#define AQUA 8
#define BLUE 16
#define YELLOW 32
#define ORANGE 64
#define RED 128

int main()
{
    int i = 0;
    int n = 0;
    scanf("%d", &n);
    int dat[n];
    int colorbit = 0;
    int ultimat = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &dat[i]);
        int g = dat[i] / 400;
        switch (g)
        {
            case 0:
                colorbit = colorbit | GRAY;
                break;
            case 1:
                colorbit = colorbit | BROWN;
                break;
            case 2:
                colorbit = colorbit | GREEN;
                break;
            case 3:
                colorbit = colorbit | AQUA;
                break;
            case 4:
                colorbit = colorbit | BLUE;
                break;
            case 5:
                colorbit = colorbit | YELLOW;
                break;
            case 6:
                colorbit = colorbit | ORANGE;
                break;
            case 7:
                colorbit = colorbit | RED;
                break;
            default:
                ultimat++;
                break;
        }
    }

    int kind = 0;
    if (colorbit & GRAY)
    {
        kind++;
    }
    if (colorbit & BROWN)
    {
        kind++;
    }
    if (colorbit & GREEN)
    {
        kind++;
    }
    if (colorbit & AQUA)
    {
        kind++;
    }
    if (colorbit & BLUE)
    {
        kind++;
    }
    if (colorbit & YELLOW)
    {
        kind++;
    }
    if (colorbit & ORANGE)
    {
        kind++;
    }
    if (colorbit & RED)
    {
        kind++;
    }

    int min = 0;
    int max = 0;

    if (kind == 0)
    {
        if (ultimat == 0)
        {
            min = 0;
            max = 0;
        }
        else
        {
            min = 1;
            max = ultimat;
            if (max > 8)
            {
                max = 8;
            }
        }
    }
    else
    {
        if (ultimat == 0)
        {
            min = kind;
            max = kind;
        }
        else
        {
            min = kind;
            max = kind + ultimat;
        }
    }
    printf("%d %d\n", min, max);
    return 0;
}


Measured memory_bytes: 128
def is_div_8(x):
    if x % 2 == 0:
        return False
    count = 0
    for j in range(1, x + 1):
        if x % j == 0:
            count += 1
    if count == 8:
        return True
    else:
        return False


N = int(input())
count = 0
for i in range(1, N + 1):
    if is_div_8(i):
        count += 1

print(count)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

int main(){
    int N;
    cin >> N;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    bool up=false,down=false;
    LL ans=0;
    for(int i=0;i<N-1;i++){
        if(a[i+1]==a[i]) continue;
        if(up){
            if(a[i+1]>a[i]) continue;
            else{
                up=false;
                ans++;
                continue;
            }
        }
        if(down){
            if(a[i+1]<a[i]) continue;
            else{
                down=false;
                ans++;
                continue;
            }
        }
        if(a[i+1]>a[i]) up=true;
        else if(a[i+1]<a[i]) down=true;
    }
    cout << ans+1 << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();

		int length = d * 2 + 1;

		System.out.println(Math.round(Math.ceil((double)n / (double)length)));
	}
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=2000005;
int n,m,k,xa,xb,top;
char s[maxn],t[maxn];
int a[maxn],b[maxn],st[maxn],todo[maxn];

int main(){
	scanf("%d%d%d%s%s",&n,&m,&k,s,t);
	int len=max(n,m)+k;
	rep(i,n)a[i+len-n]=s[i]-'0';
	rep(i,m)b[i+len-m]=t[i]-'0';
	rep(i,len){
		int tmp=0;
		if(a[i]==1&&b[i]==1){
			a[i]=b[i]=0;
			int cnt=k,j=i;
			xa=xb=1;
			while(cnt>=0){
				int last=top?st[--top]:-1;
				if(xa==1&&xb==1){
					if(j-cnt>last){
						a[j-cnt]=b[j-cnt]=1;
						todo[tmp++]=last;
						break;
					}
					cnt-=j-last;
					assert(last>=0);
					xa=a[last];xb=b[last];
					todo[tmp++]=last;
					a[last]^=1;b[last]^=1;
				}
				else{
					if(last!=j){
						a[j]=xa;b[j]=xb;
						todo[tmp++]=j;
						todo[tmp++]=last;
						break;
					}
					if(a[last]==xa&&b[last]==xb)a[last]=b[last]=0;
					else{
						if(!cnt){
							a[last]=b[last]=1;
							break;
						}
						a[last]=b[last]=0;
						cnt--;
						xa=xb=1;
					}
				}
				j=last-1;
			}
			for(int j=tmp-1;j>=0;j--)st[top++]=todo[j];
		}
		else if(a[i]>0||b[i]>0)st[top++]=i;
	}
	rep(i,len)if(a[i]){
		for(int j=i;j<len;j++)putchar(a[j]+'0');
		puts("");
		break; 
	}
	rep(i,len)if(b[i]){
		for(int j=i;j<len;j++)putchar(b[j]+'0');
		puts("");
		break;
	}
	return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int n, m;

int main() {

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

    int l = 1, r = n;
    bool left = true;
    int cnt = 0;
    for (int i = (n - 1) / 2; i >= 1; i--) {
        if (left) {
            printf("%d %d\n", l, l + i);
            l++;
        } else {
            printf("%d %d\n", r - i, r);
            r--;
        }
        cnt++;
        if (cnt == m)
            return 0;
        left = !left;
    }

    return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>

#define N 100000

//node pointer
typedef struct DATA{
  char name[11];
  int time;
}DATA;

//prototype
void enqueue(DATA);
DATA *dequeue(void);

//Queue set
DATA Queue[N];

//head & tail & data number set
int head=0, tail=0, num;

int main(){
  int Q, i;
  DATA *data;

  //create *data
  data=(DATA *)malloc(sizeof(DATA));
  
  //input data number & Quantime
  scanf("%d %d",&num,&Q);

  //input data
  for(i=0;i<num;i++){
    scanf("%s %d",data->name,&data->time);
    enqueue(*data);
  }
  
  //count doing process time
  data=dequeue();
  i=0;
  while(data!=NULL){
    
    if(data->time<=Q){//finish process
      i+=data->time;
      
      printf("%s %d\n",data->name,i);
      data=dequeue();
    }

    else{//Quantime
      i+=Q;
      data->time-=Q;
      
      enqueue(*data);
      data=dequeue();
    }
    
  }

  
  return 0;
}


//input data to tail
void enqueue(DATA data){
  if(tail+1==head){//full
    printf("ERROR:full\n");
    exit(4);
  }

  Queue[tail]=data;
  tail++;
  if(tail==(num+1)) tail=0;
}


//output data from head
DATA *dequeue(void){
  DATA *dp;
  
  if(head==tail){//empty
    //printf("ERROR:empty\n");
    return NULL;
  }

  dp=&Queue[head];

  head++;
  if(head==(num+1)) head=0;
  return dp;
}



Measured memory_bytes: 2480
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF (long long)1 << 61
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	llong y;cin >> y;
    llong x = 100;llong i = 0;
    while(x<y){
        i++;
        x+=x/100;
    }
    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3632
use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        xys: [(i128, i128); n],
    }
    // |xi - xj| + |yi - yj|
    let xys_pp = xys
        .iter()
        .cloned()
        .sorted_by(|l, r| (l.0 + l.1).cmp(&(r.0 + r.1)))
        .collect_vec();
    let xys_pn = xys
        .iter()
        .cloned()
        .sorted_by(|l, r| (l.0 - l.1).cmp(&(r.0 - r.1)))
        .collect_vec();
    let xys_np = xys
        .iter()
        .cloned()
        .sorted_by(|l, r| (-l.0 + l.1).cmp(&(-r.0 + r.1)))
        .collect_vec();
    let xys_nn = xys
        .iter()
        .cloned()
        .sorted_by(|l, r| (-l.0 - l.1).cmp(&(-r.0 - r.1)))
        .collect_vec();
    fn f(a: &(i128, i128), b: &(i128, i128)) -> i128 {
        (a.0 - b.0).abs() + (a.1 - b.1).abs()
    }
    let ans = *[
        f(&xys_pp[0], &xys_pp[n - 1]),
        f(&xys_pn[0], &xys_pn[n - 1]),
        f(&xys_np[0], &xys_np[n - 1]),
        f(&xys_nn[0], &xys_nn[n - 1]),
    ]
    .iter()
    .max()
    .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 39732
#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;

int main () {
  int n;
  float m;
  cin >> n >> m;
  float a[n];
  float sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int cnt = 0;
  float check = sum / 4.0 / m;
  for (int i=0; i<n; i++) {
    if (check <= a[i]) cnt++;
  }
 if (cnt >= m) cout << "Yes";
 else cout << "No";
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define swap(type, a, b) do{type tmp = a; a = b; b = tmp;}while(0);

int main(void)
{
	int n;
	char word[201], ans[2][201];
	int i, j, r0, r1, h;


	while(scanf("%s", word)!=EOF && strcmp(word, "-")!=0){
		r0 = 1;
		r1 = 0;
		strcpy(ans[r0], word);
		scanf("%d", &n);

		for(i=0;i<n;i++){
			swap(int, r0, r1);
//printf("%d %d\n", r0, r1);
			scanf("%d", &h);

			for(j=h;j<strlen(word);j++)
				ans[r0][j-h] = ans[r1][j];
			ans[r0][j-h] = '\0';
			strncat(ans[r0], ans[r1], h);
//printf("%s %s %s\n", word, ans[r0], ans[r1]);

		}

		printf("%s\n", ans[r0]);
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace::std;
#define all(n) (n).begin(),(n).end()

auto meld(tuple<int,int,int> s,tuple<int,int,int> t){
    constexpr int64_t base=10007;
    constexpr int64_t mod[2]={1000000007LL,999999937LL};
    int64_t a[2]={};
    a[0]=(int64_t(get<0>(s))*base%mod[0]+get<0>(t))%mod[0];
    a[1]=(int64_t(get<1>(s))*base%mod[1]+get<1>(t))%mod[1];
    return make_tuple(a[0],a[1],get<2>(s)+get<2>(t));
}
auto make(char c){
    return make_tuple(int(c),int(c),1);
}
auto empty(){
	return make_tuple(0,0,0);
}

int main(){
	vector<tuple<int,int,int>>m;
	int n;
	cin>>n;
	vector<tuple<int,int,int>>v(n,empty());
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		reverse(all(s));
		vector<int>cnt(26,0);
		for(int j=0;j<(int)s.size();++j)cnt[s[j]-'a']++;
		bitset<26>b;
		for(int j=0;j<26;++j)if(cnt[j])b[j]=1;
		for(int j=0;j<(int)s.size();++j){
			for(int k=b._Find_first();k<26;k=b._Find_next(k)){
				auto e=meld(v[i],make(k+'a'));
				m.push_back(e);
			}
			v[i]=meld(v[i],make(s[j]));
			cnt[s[j]-'a']--;
			if(!cnt[s[j]-'a'])b[s[j]-'a']=0;
		}
	}
    sort(all(m));
	int64_t ans=0;
	for(int i=0;i<n;++i){
		ans+=upper_bound(all(m),v[i])-lower_bound(all(m),v[i])-1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 397988