akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int sum1 = 0, sum2 = 0;
  rep(i, n){
    if (i % 2 == 0 && s[i] == '1') sum1++;
    else if (i % 2 == 1 && s[i] == '0') sum1++;
    if (i % 2 == 0 && s[i] == '0') sum2++;
    else if (i % 2 == 1 && s[i] == '1') sum2++;
  }
  cout << min(sum1, sum2) << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    cin >> a >> b;

    if(a <= b){
        cout << a << endl;
    }else{
        cout << a-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = sum(a)
for i in range(len(b)):
  if a[i] >= b[i]:
    a[i] -= b[i]
  else:
    b[i] -= a[i]
    if a[i+1] < b[i]:
      a[i+1] = 0
    else:
      a[i+1] -= b[i]
    a[i] = 0

print(r - sum(a))

Measured memory_bytes: 18624
#include <stdio.h>

typedef struct 
{
  int number;
  char name[10];
} queue;
queue Q[100000];

int head,tail=0;
void enqueue(queue);
queue dequeue(void);

int main()
{
    int n,q,t=0,i,number;
    queue in;

    scanf("%d%d",&n,&q);
    tail= n;
    for(i=0;i<n;i++)
    {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].number);
    }
 
  while(tail!=head){
      if(Q[head].number>q){
        in=dequeue();
        in.number=in.number-q;
        enqueue(in);
        t=t+q;
      }
      else
      {
          in=dequeue();
          t=t+in.number;
          in.number=t;
          printf("%s %d\n",in.name,in.number);
      }
    }

    return 0;
}

void enqueue(queue in)
{
 Q[tail]=in;
 tail = (tail +1)%100000;
} 

queue dequeue(void)
{
    queue a;
    a=Q[head];
    head=(head+1)%100000;
 return a;
}


Measured memory_bytes: 3260
# -*- coding: utf-8 -*-
"""
B - Greedy Takahashi
https://atcoder.jp/contests/abc149/tasks/abc149_b

"""
import sys


def solve(A, B, K):
    if A >= K:
        return A-K, B
    return 0, max(B - K + A, 0)


def main(args):
    A, B, K = map(int, input().split())
    ans = solve(A, B, K)
    print(*ans)


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


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 100100100;

int main(){
  int n;
  cin >> n;
  cout << n*n*n << endl;  
}


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

int main() {
	string s;
	cin >> s;

	string ans = "";
	for (int i = 0; i < s.size(); i += 2) {
		ans.push_back(s[i]);
	}

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

Measured memory_bytes: 3712
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from collections import deque
def main(H, W, A):
    dist = [[-1] * W for _ in range(H)]
    q = deque()
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                dist[i][j] = 0
                q.append((i, j, 0))

    ans = 0
    while q:
        i, j, d = q.popleft()
        ans = max(ans, d)
        for ni, nj in [(i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)]:
            if not (0 <= ni < H and 0 <= nj < W): continue
            if dist[ni][nj] >= 0: continue
            dist[ni][nj] = d + 1
            q.append((ni, nj, d + 1))
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [input().rstrip() for _ in range(H)]
    main(H, W, A)


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

using namespace std;

int a[100010];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == i) {
      if (i + 1 < n) {
        swap(a[i], a[i + 1]);
      } else {
        swap(a[i], a[i - 1]);
      }
      ++ans;
    }
  }
  for (int i = 0; i < n; ++i) {
    assert(a[i] != i);
  }
  printf("%d\n", ans);
}

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

int main() {
 int l,r,d;
 cin >> l >> r >> d;
 
 if(l%d != 0 && r%d !=0){
 cout << (r - l) / d;}
 else {
  cout << (r - l) / d +1;
  }

}

Measured memory_bytes: 3632
while True:
    n = int(input())
    if n == 0:
        break;
    x = {}
    for i in range(n):
        k,v = input().split()
        x[k] = v
    y = []
    for i in range(int(input())):
        a = input()[0]
        if a in x:
            y.append(x[a])
        else:
            y.append(a)
    print(''.join(y))

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
bool eq(double a, double b) { return fabs(a - b) < EPS; }

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};
	
	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

double cross(point a, point b)
{
	return a.x*b.y - a.y*b.x;
}



int main()
{
	int q;
	cin >> q;
	while (q--)
	{
		double a[8];
		REP(i, 8) cin >> a[i];
		point s(a[2] - a[0], a[3] - a[1]);
		point t(a[6] - a[4], a[7] - a[5]);
		if (eq(cross(s, t), 0)) puts("2");
		else if (eq(dot(s, t), 0)) puts("1");
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 1184
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()

no = 2

while no < n:
    no *= 2
if no > n:
    no = int(no/2)

print(no)



Measured memory_bytes: 61928
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int border[] = {599, 799, 999, 1199, 1399, 1599, 1799, 1999};

void solve(int cn) {
    int a[3],K;
    cin>>a[0]>>a[1]>>a[2]>>K;
    int cnt=0;
    while(a[0]>=a[1]&&cnt<=K){
        a[1]*=2;
        cnt++;
    }

    while(a[1]>=a[2]&&cnt<=K){
        a[2]*=2;
        cnt++;
    }
    cout<<((cnt<=K)?"Yes":"No")<<endl;

}


#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}


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

using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int res = 0;
  for (int i = 1; i <= N; ++i) {
    int sum_digit = 0;
    int x = i;
    while (x > 0) {
      sum_digit += x % 10;
      x /= 10;
    }
    if (sum_digit >= A && sum_digit <= B) res += i;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;



int main(){
  string s;cin>>s;
  int n = s.length();
  vec<int> v(n),w2019(n);
  w2019[0]=1;
  for (int i = 1; i < n; i++) {
    w2019[i]=(w2019[i-1]*10)%2019;
  }
  v[0]=s[n-1]-'0';
  for (int i = 1; i < n; i++) {
    v[i]=(v[i-1]+w2019[i]*(s[n-i-1]-'0'))%2019;
//   cout<<n-i-1<<"nyan"<<v[i]<<endl;
  }
  SORT(v);
  int cnt=0;
  int co=0;
  if(v[0]==0)cnt++;
  for (int i = 1; i < n; i++) {
//    cout<<v[i]<<endl;
    if(v[i]==v[i-1]){
      co++;
    }else if(co!=0){
      cnt+=co*(co+1)/2;
      co=0;
    }
    if(v[i]==0)cnt++;
  }
  if(co!=0){
    cnt+=co*(co+1)/2;
  }
  cout<<cnt;
}



/* きょむ〜 */


Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int a,b,n;
	cin>>a>>b>>n;
	cout<<(a*min(b-1,n))/b;
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
set <ll> gin[MAXN];
vl gout[MAXN];
ll pnt = 0;
vl top;
vl giin[MAXN];
ll dp[MAXN];
bool mark[MAXN];
void topo(ll v){
	queue<ll> q;
	q.push(v);
	while (q.size()){
		//cout << q.front() << ' ';
		ll fro = q.front();
		q.pop();
		for (auto u:gout[fro]){
			gin[u].ers(fro);
			if (gin[u].size() == 0) q.push(u);
		}
		top.pb(fro);
		mark[fro] = 1;	
	}
	
	
}



int main(){
	IOS;
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		ll v, u;
		cin >> v >> u;
		gin[u].ins(v);
		giin[u].pb(v);
		gout[v].pb(u);
	}
	for (int i = 1; i <= n; i++){
		if (gin[i].size() == 0 && mark[i] == 0){
			topo(i);
		}
	}
	/*for (auto u:top){
		cout << u << ' ';
	}*/
	for (int i = 0; i < n; i++){
		for (auto u:giin[top[i]]){
			dp[top[i]] = max(dp[top[i]], dp[u] + 1);
		}
	}
	ll Max = 0;
	for (int i = 1; i <= n; i++) Max = max(Max, dp[i]);
	cout << Max;
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 31732
#include<iostream>
using namespace std;
int n,q,A[20],m;
bool check(int a,int s){
  if(s==m)return 1;
  if(a==n)return 0;
 return check(a+1,s+A[a])||check(a+1,s);
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m;
    if(check(0,0))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

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

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

const int INF = INT_MAX/2;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using P = pair<int,int>;

vector<int> dx = {1,0,-1,0,1,1,-1,-1};
vector<int> dy = {0,1,0,-1,1,-1,1,-1};

int main() {

  int H,W,K; cin >> H >> W >> K;
  P s,g; cin >> s.first >> s.second >> g.first >> g.second;
  s.first--;s.second--;g.first--;g.second--;

  vector<string> C(H);
  REP(i,H) cin >> C.at(i);

  vector<vector<int>> len(H,vector<int>(W,INF));

  REP(i,H)REP(j,W){
    if(C.at(i).at(j)=='@')len.at(i).at(j)=-1;
  }

  len.at(s.first).at(s.second) = 0;

  queue<P> qu;

  qu.emplace(s.first,s.second);

  while(!qu.empty()){
    P now = qu.front();qu.pop();
    int a = now.first, b = now.second;
    int lengh = len.at(a).at(b);
    REP(i,4){
      for(int t = 1;t<=K;t++){
        int x = a + dx.at(i)*t, y = b + dy.at(i)*t;
        if(x<0||H<=x||y<0||W<=y)break;
        
        if(len.at(x).at(y)>lengh){
          if(chmin(len.at(x).at(y),lengh+1)) qu.emplace(x,y);
        }else{
          break;
        }
        
      }
    }
  }
  int ans = len.at(g.first).at(g.second);
  if(ans==INF) ans=-1;
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12140
def solve(s1,s2):
    if s1 == s2:
        return 0

    l1,l2 = s1.split('"'),s2.split('"')
    if len(l1) != len(l2):
        return 1

    ct = 0
    for i in range(len(l1)):
        if i%2 == 0:
            if l1[i] != l2[i]:
                return 1
        else:
            if l1[i] != l2[i]:
                ct += 1
            if ct > 1:
                return 1
    return 2

def main():
    ans = ['IDENTICAL', 'DIFFERENT', 'CLOSE']
    while True:
        s1 = input()
        if s1 == '.':
            return
        s2 = input()
        print(ans[solve(s1,s2)])

if __name__ == '__main__':
    main()



Measured memory_bytes: 5584
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		for( int i=1; x!= 0; i++ ){
			System.out.println("Case " + i + ": " + x );
			x = sc.nextInt();
		}
	}
}

Measured memory_bytes: 33028
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;
 
int main() {
   char temp[100000]; scanf("%s", temp); string s = temp;
   vector<vector<ll>> dp(s.length(), vector<ll>(13));
   if (s[0] == '?') {
      for (int i = 0; i < 10; ++i)
         ++dp[0][i];
   } else {
      ++dp[0][s[0] - '0'];
   }
   for (int i = 1; i < s.length(); ++i) {
      if (s[i] == '?') {
         for (int j = 0; j < 13; ++j) {
            for (int k = 0; k < 10; ++k) {
               dp[i][(10 * j + k) % 13] += dp[i - 1][j];
               dp[i][(10 * j + k) % 13] %= MOD;
            }
         }
      } else {
         for (int j = 0; j < 13; ++j) {
            dp[i][(10 * j + s[i] - '0') % 13] = dp[i - 1][j];
            dp[i][(10 * j + s[i] - '0') % 13] %= MOD;
         }
      }
   }
   printf("%lld", dp[s.length() - 1][5]);
   return 0;
}

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

namespace Contest
{
    class ABC042
    {
        static void Main()
        {
            SolveB();
        }

        private static void SolveB()
        {
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = INPUT[0];
            int L = INPUT[1];

            List<string> S = new List<string>();
            for(int i = 0; i < N; i++)
            {
                S.Add(Console.ReadLine());
            }
            string result = string.Join("" , S.OrderBy(a => a).ToArray());

            Console.WriteLine(result);
            Console.ReadLine();
        }

        private static void SolveA()
        {
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int go = 0;
            int nana = 0;
            if (INPUT[0] == 5) go++;
            if (INPUT[0] == 7) nana++;
            if (INPUT[1] == 5) go++;
            if (INPUT[1] == 7) nana++;
            if (INPUT[2] == 5) go++;
            if (INPUT[2] == 7) nana++;
            Console.WriteLine((go == 2 && nana == 1) ? "YES" : "NO");
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13660
(function main(){
  let lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n");
  let [n, k] = lines.shift().split(' ').map(Number);
  let w = lines.map(Number);

  const canAllStack = (p) => {
    let cnt = 0, sum = 0;
    for (let i = 0; i < k; i++) {
      for (sum = 0; sum + w[cnt] <= p;sum += w[cnt++]) {
        if (cnt === n) return n;
      }
    }
    return cnt;
  };

  let mid, left = 0, right = 1e9;
  while (right - left > 1) {
    mid = (right + left) / 2;
    if (canAllStack(mid) >= n) right = mid;
    else left = mid;
  }
  console.log(Math.floor(right));
})();



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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

ll calc(ll X, ll C, ll D){
    ll lcm = C*D/__gcd(C, D);
    return max(0ll, X - (X/C + X/D - X/lcm));
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //f(B) - f(A-1)
    ll A, B; cin >> A >> B;
    ll C, D; cin >> C >> D;
    cout << calc(B, C, D) - calc(A-1, C, D) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MAX 200000
using namespace std;

int a[MAX],b[MAX];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int x = a[0];
	int kind = 0;
	int l = 0;
	while (l < n) {
		b[kind] = upper_bound(a, a + n, x) - lower_bound(a, a + n, x);
		l += b[kind];
		kind += 1;
		x = a[l];
	}
	sort(b, b + kind);
	int ans = 0;
	for (int i = 0; i < kind - k; i++) {
		ans += b[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String S = in.next();
			String ans = "AC";
			if(S.charAt(0) != 'A') {
				ans = "WA";
			}
			int count = 0;
			for(int i = 2; i < S.length() - 1; i++) {
				if(S.charAt(i) == 'C') {
					count++;
				}
			}
			if(count != 1) {
				ans = "WA";
			}
			for(int i = 1; i < S.length(); i++) {
				if(Character.isUpperCase(S.charAt(i)) && S.charAt(i) != 'C') {
					ans = "WA";
				}
			}
			out.println(ans);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


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

int main() {
  uint32_t N = 0;
  std::cin >> N;

  uint32_t base = 100000;
  uint32_t sum = 0;
  while (base != 0) {
    sum += N / base;
    N %= base;
    base /= 10;
  }

  std::cout << (sum == 1 ? 10 : sum) << std::endl;

  return 0;
}

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

int a[5];
int m=200;
bool t=false;
int sum=0;

void solve(){
  rep(i,5) cin >> a[i];
//cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  for(int i=0; i<5; i++){
    if(a[i]%10==0) {
    sum += a[i];
    }
    else {
    m=min(m, a[i]%10);
    sum += (a[i]/10+1)*10;
      t=true;
    }
  }
  if(t) sum = sum - 10 + m;
  cout << sum << endl;
}

int main(){
  solve();
  return 0;
}
  

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

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

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

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        cin >>N;
        cout <<N+N*N+N*N*N <<endl;
        return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


Measured memory_bytes: 2044
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

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

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli A,B;
    cin>>A>>B;

    if(A%3==0 or B%3==0)
{
    cout<<"Possible";
    exit(0);
}

    if((A+B)%3)
    {
        cout<<"Impossible";
    }
    else
    {
        cout<<"Possible";
    }









 return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j;
map<int,int> mp;
vector<int> seq;
int main()
{
	scanf("%d",&n);
	int t=1;
	fz1(i,n){
		int x;
		scanf("%d",&x);
		if(x)t=0;
		mp[x]++;
	}
	if(t){
		puts("Yes");
		return 0;
	}
	if(n%2==0){
		if(mp.size()==2){
			if(mp.count(0)){
				if(mp[0]*2==n){
					puts("Yes");
					return 0;
				}
			}
		}
	}
	if(n%3!=0){
		puts("No");
		return 0;
	}
	ff(mp,it){
		int t=it->second;
		while(t){
			if(t<0){
				puts("No");
				return 0;
			}
			seq.push_back(it->first);
			t-=n/3;
		}
	}
	if((seq[0]^seq[1])!=seq[2]){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3840
from functools import reduce
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def gcd_list(numbers):
    return reduce(gcd, numbers)
n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))

Measured memory_bytes: 14596
s=input()
n=len(s)
if n%2==0 or s!=s[-1::-1]:
    print("No")
else:
    if s[:(n-1)//2]==s[(n-1)//2-1::-1] and s[(n+3)//2-1:]==s[-1:(n+3)//2-2:-1]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int c5 = 0;
            int c7 = 0;
            for (int i = 0; i < 3; i++) {
                int cn = in.nextInt();
                if (cn == 5)
                    c5++;
                else if (cn == 7)
                    c7++;
            }
            out.println(c5 == 2 && c7 == 1 ? "YES" : "NO");

        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(m,0);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int s;
            cin>>s;
            s--;
            v[s]++;
        }
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        if(v[i]==n) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100+7;
const int INF = 1e6+7;
int m[MAXN][MAXN];
int d[MAXN];
bool visit[MAXN];
int n;
set<int> s;
void djas()
{
    d[0] = 0;
    for(int i = 1; i < n; i++)
    {
        d[i] = INF;
    }
    while(s.size() != n)
    {
        int min_d = INF;
        int s1;
        for(int j = 0; j < n; j++)
        {
            if(d[j]<min_d && visit[j]==false)
            {
                min_d = d[j];
                s1 = j;
            }
        }

        s.insert(s1);
        visit[s1] = true;
        for(int j = 1; j < n; j++)
        {
            if(m[s1][j]!=-1 && d[s1]+m[s1][j]<d[j] && j!=s1 && visit[j]==false){
                d[j] = d[s1]+m[s1][j];
            }
        }
    }
}
int main()
{
//    freopen("in.txt", "r", stdin);
    memset(visit, false, sizeof(visit));
    memset(m, -1, sizeof(m));
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int id;
        scanf("%d", &id);
        int degree;
        scanf("%d", &degree);
        for(int j = 0; j < degree; j++)
        {
            int v;
            scanf("%d", &v);
            int c;
            scanf("%d", &c);
            m[id][v] = c;
        }
    }
    djas();
    for(int i = 0; i < n; i++)
    {
        printf("%d %d\n", i, d[i]);
    }

    return 0;
}



Measured memory_bytes: 3272
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, K;
    ll diff;

    cin >> N >> K;

    N = N % K;
    diff = abs(N - K);
    if(diff < N){
        cout << diff << endl;
    }else{
        cout << N << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

vector<string> dp(10015);
bool isbig(string a, string b){
  if(a.size() > b.size()){
    return true;
  }else if(a.size()== b.size()){
    return bool(a>b);
  }else{
    return false;
  }

}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m; cin >> n >> m;
  vector<pair<char,ll>> v;
  REP(i,m){
      ll tmp ; cin >> tmp;
      if(tmp==1) v.push_back(mp('1',2));
      if(tmp==7) v.push_back(mp('7',3));
      if(tmp==4) v.push_back(mp('4',4));
      if(tmp==2) v.push_back(mp('2',5));
      if(tmp==3) v.push_back(mp('3',5));
      if(tmp==5) v.push_back(mp('5',5));
      if(tmp==6) v.push_back(mp('6',6));
      if(tmp==9) v.push_back(mp('9',6));
      if(tmp==8) v.push_back(mp('8',7));
  }
  sort(all(v));
  REP(i,n+1){
      dp[i] = "";
  }
  REP(i,n){
    if(i && dp[i]=="")continue;
    REP(j,m){
      auto vv = v[j];
      char dig = vv.first;
      ll cost = vv.second;
      string tmp = dp[i];
      tmp.push_back(dig);
      if(isbig( tmp, dp[i+cost])){
        dp[i+cost] = tmp;
      }
    }
  }
  
  cout << dp[n] << endl;

}


Measured memory_bytes: 43776
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    ll N;
    cin >> N;
    ll tmp = N;
    string s;
    while(tmp >0) {
        ll rem = tmp % 26;
        if(rem==0){
            s+='z';
            tmp = tmp/26 - 1;
        } else{
            s+= char((rem-1)+'a');
            tmp = tmp/26;
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}


Measured memory_bytes: 3624
import sys
t_1,t_2=map(int,input().split())
a_1,a_2=map(int,input().split())
b_1,b_2=map(int,input().split())
if a_1==b_1:
    print("infinity")
    sys.exit()
    
x=a_1*t_1
y=a_2*t_2
w=b_1*t_1
z=b_2*t_2
if x+y==w+z:
    print("infinity")
    sys.exit()

if x+y>w+z:
    if x>w:
        print(0)
    else:
        if (w-x)%(x+y-w-z)==0:
            print(2*((w-x)//(x+y-w-z)))
        else:
            print(2*((w-x)//(x+y-w-z))+1)
else:
    if w>x:
        print(0)
    else:
        if (x-w)%(w+z-x-y)==0:
            print(2*((x-w)//(w+z-x-y)))
        else:
            print(2*((x-w)//(w+z-x-y))+1)

Measured memory_bytes: 38384
A = input()
B = input()
C = input()

dic = {
  'A': A,
  'B': B,
  'C': C
}

def f(x):
  if x == '':
    return False
  else :
    return x[1:]
  
person = 'A'

while True :
  flag = f( dic[person])
  
  if flag == False :
    print(person)
    break
  else :
    next_p = dic[person][0].upper()
    dic[person] = flag
    person = next_p

Measured memory_bytes: 3064
// 解き直し.
// ABC 135解説
// https://img.atcoder.jp/abc135/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    LL A[N + 1], B[N];
    for(int i = 0; i < N + 1; i++) scanf("%lld", A + i);
    for(int i = 0; i < N; i++)     scanf("%lld", B + i);
    
    // 2. モンスターを倒せる数を計算.
    // 解説通り.
    // Σ(f(i, i) + f(i, i + 1))
    LL ans = 0;
    LL f1 = 0, f2 = 0;
    for(int i = 0; i < N; i++){
        // f(1, 1) = min(A1, B1)
        // f(i, i) = min(A[i] - f(i - 1, i), B[i])
        f1 = min(A[i] - f2, B[i]);
        ans += f1;
        
        // f(i, i + 1) = min(A[i + 1], B[i] - f(i, i))
        f2 = min(A[i + 1], B[i] - f1);
        ans += f2;
        
    }
    
    // 3. 出力 ～ 後処理.
    printf("%llu\n", ans);
    return 0;

}

Measured memory_bytes: 1792
def fact(n)
  f = 1
  1.upto(n) do |i|
    f *= i
    f %= MOD
  end
  f
end

n, m = gets.split.map(&:to_i)
MOD = 10**9 + 7
diff = (n-m).abs
if diff > 1
  puts 0
  exit
elsif diff == 1
  puts (fact([n, m].min) ** 2 * [n,m].max) % MOD
else
  puts ((fact(n) ** 2) * 2) % MOD
end


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

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

int main(){
  int n;
  cin>>n;
  cout << (n>=1000 ? "ABD" : "ABC") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n;
    int t[9] = {0};
    int a = 0;
    for(int i = 0; i < n; ++i){
        cin >> m;
        if(m < 400){
            if(t[0] == 0) {
                t[0] = 1;
                a++;
            }
        }
        else if(m < 800){
            if(t[1] == 0) {
                t[1] = 1;
                a++;
            }
        }
        else if(m < 1200){
            if(t[2] == 0) {
                t[2] = 1;
                a++;
            }
        }
        else if(m < 1600){
            if(t[3] == 0) {
                t[3] = 1;
                a++;
            }
        }
        else if(m < 2000){
            if(t[4] == 0) {
                t[4] = 1;
                a++;
            }
        }
        else if(m < 2400){
            if(t[5] == 0) {
                t[5] = 1;
                a++;
            }
        }
        else if(m < 2800){
            if(t[6] == 0) {
                t[6] = 1;
                a++;
            }
        }
        else if(m < 3200){
            if(t[7] == 0) {
                t[7] = 1;
                a++;
            }
        }
        else {
            t[8] += 1;
        }
    }

    if(t[8] == 0){
        cout << a << " " << a << endl;
    }
    else{
        if(a == 0){
            cout << 1 << " " << t[8] << endl;
        }
        else{
            cout << a << " " << a + t[8] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k, t = na()
a = na()

s = sum(a)
a.sort()
s -= a[-1]
if a[-1] - s <= 0:
    print(0)
else:
    print(a[-1] - s - 1)

Measured memory_bytes: 3064
n=int(input())
s=input()

ans=0
for i in range(n-1):
  cnt=0
  a=set(s[:i+1])
  b=set(s[i+1:])
  for j in a:
    if j in b:
      cnt+=1
  if ans<cnt:
    ans=cnt

print(ans)

Measured memory_bytes: 3060
import sys

while True:
	sur = []

	for _ in range(8):
		sur.append(list(map(int, input().strip())))
		if 1 not in sur[-1]:
			sur.pop()

	if len(sur) == 1:
		print("C")
	elif len(sur) == 2:
		if sur[0].index(1) == sur[1].index(1):
			print("A")
		elif sur[0].index(1) < sur[1].index(1):
			print("E")
		else:
			print("G")
	elif len(sur) == 3:
		if sur[0].index(1) > sur[2].index(1):
			print("D")
		else:
			print("F")
	elif len(sur) == 4:
		print("B")

	try:
		line = input()
	except:
		break

Measured memory_bytes: 6728
#include<bits/stdc++.h>
#include<stdio.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e6)+1
#define MOD 1000000007
 
using namespace std;
 
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;
 
lli dp[101][100001];
int n,maxW;
vector<lli> pesos;
vector<lli> valores;

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(4);
    
    
    
    cin>>n>>maxW;
    
    
    rep(i,n){
        lli v,w;
        cin>>w>>v;
        pesos.pb(w);
        valores.pb(v);
    }
    
    for(int i=0;i<=n;++i){
        for(int w = 0;w<=maxW;w++){
            if(i == 0 || w == 0)
                dp[i][w] = 0;
            else if(pesos[i-1]<=w){
                dp[i][w] = max(valores[i-1]+dp[i-1][w-pesos[i-1]],dp[i-1][w]);
            }else{
                dp[i][w] = dp[i-1][w];
            }
        }
    }   
    cout<<dp[n][maxW]<<endl;
    return 0;
 
}

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

int main() {
    int N, A[110], cnt = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    for (int i = 0; i < N; ++i) {
        int minj = i;
        for (int j = i; j < N; ++j) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        if (i != minj) ++cnt;
    }

    for (int i = 0; i < N; ++i) {
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << endl << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int d[8][8];
double ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int, int> > XY(N);
    for (auto & xy : XY) {
        cin >> xy.first >> xy.second;
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ans += sqrt(pow(XY[i].first-XY[j].first, 2)+pow(XY[i].second-XY[j].second, 2));
        }
    }
    ans /= N;
    printf("%.10lf\n", ans);
    return 0;
}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;


const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
   




int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';     //Avoid flushing with endl.
    cout.precision(16);


    int q;
    string S, T;
    cin >> S >> T;

    vector<int> As_in_S(len(S)+1, 0);
    vector<int> As_in_T(len(T)+1, 0);

    ii (len(S)) {
        int increment = 2;
        if (S[i] == 'A')
            increment = 1;
        As_in_S[i+1] = As_in_S[i] + increment;
    }
    ii (len(T)) {
        int increment = 2;
        if (T[i] == 'A')
            increment = 1;
        As_in_T[i+1] = As_in_T[i] + increment;
    }

    cin >> q;
    ii (q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int left = As_in_S[b] - As_in_S[a-1];
        int right = As_in_T[d] - As_in_T[c-1];
        cout << ((left % 3 == right % 3) ? "YES" : "NO") << '\n';
    }
    

    return 0;
}



Measured memory_bytes: 1744