akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int n;
	bool ans = 0;
	cin >> n;
	for(int i = 1; i < 10; i++){
		if( n % i == 0 && n / i < 10){
			ans = 1;
		}
	}
	switch(ans)
	{
		case 1 :
		cout << "Yes";
		break;
		case 0 :
		cout << "No";
		break;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	char a,b;
	while(~scanf(" %c %c",&a,&b))
	{
		if(a>b) printf(">\n");
		else if(a<b) printf("<\n");
		else if(a==b) printf("=\n");
	}
	return 0;
}

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

using namespace std;

const int MAX_V = 10000;

int par[MAX_V];
int p_rank[MAX_V];

void init(int n) {
    for (int i = 0; i < n; ++i) {
        par[i] = i;
        p_rank[i] = 0;
    }
}

int find_root(int x) {
    if (par[x] == x) {
        return x;
    } else {
        // update parent
        return par[x] = find_root(par[x]);
    }
}

void unite(int x, int y) {
    int x_root = find_root(x);
    int y_root = find_root(y);
    if (x_root == y_root) return;

    if (p_rank[x_root] < p_rank[y_root]) {
        par[x_root] = y_root;
    } else {
        par[y_root] = x_root;
        if (p_rank[x_root] == p_rank[y_root]) p_rank[x_root]++;
    }
}

int same(int x, int y) {
    return find_root(x) == find_root(y);
}


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

    int n, q;
    cin >> n >> q;

    init(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x>> y;
        if (com == 0) {
            unite(x, y);
        } else {
            cout << same(x, y) << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 3296
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
    long long n;
    long long p[200005];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    long long a, sum = 1;
    if (n == 1)
        cout << "1" << endl;
    else
    {
        a = min(p[0], p[1]);
        for (int i = 1; i < n; i++)
        {
            if (p[i] <= a)
            {
                a = p[i];
                sum++;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Queue<String> nameQueue = new ArrayDeque<>();
		Queue<Integer> timeQueue = new ArrayDeque<>();
		int time = 0;

		// プロセス数とクオンタムを読み込む
		int num = scan.nextInt();
		int quantum = scan.nextInt();

		// 各プロセスの情報を読み込む
		for(int i = 0; i < num; i++) {
			nameQueue.add(scan.next());
			timeQueue.add(scan.nextInt());
		}

		// ラウンドロビンスケジューリング
		while(!timeQueue.isEmpty()) {
			if(timeQueue.peek() > quantum) {
				timeQueue.add(timeQueue.poll() - quantum);
				nameQueue.add(nameQueue.poll());
				time += quantum;
			} else {
				time += timeQueue.poll();
				System.out.print(nameQueue.poll() + " ");
				System.out.println(time);
			}

		}

	}
}



Measured memory_bytes: 72760
#include <iostream>

using namespace std;

#define w first
#define v second

pair<int, int> obj[105];
long long dp[100005];

int main()
{
    int n, g;
    cin >> n >> g;
    for(int i = 1; i <= n; ++i)
        cin >> obj[i].w >> obj[i].v;
    int maxv = 100000;
    for(int i = 1; i <= maxv; ++i)
        dp[i] = 1e18;
    for(int i = 1; i <= n; ++i){
        for(int j = maxv; j >= obj[i].v; --j)
            dp[j] = min(dp[j], dp[j - obj[i].v] + 1LL * obj[i].w);
    }
    int ans = 0;
    for(int i = 1; i <= maxv; ++i){
        if(dp[i] <= g)
            ans = max(ans, i);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
now = A[0]
for i in range(1,N):
  if A[i] > 2*now:
    ans = 1
    now += A[i]
  else:
    ans += 1
    now += A[i]
print(ans)


Measured memory_bytes: 20480
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
            if 10000*i + 5000*j + 1000*(n-i-j)==y:
                print(str(i)+" "+str(j)+" "+str(n-i-j))
                exit()
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;

  cout << min((2 * N + M) / 4, M / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = max(base+score(tmp), 0LL);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = max(base + score_2(T, max_score, d, old, q), 0LL);
    if(max_score<tmp){
      max_score = tmp;
      FOR(i,d,D){
        if(T[i]==old) break;
        last[i+1][old] = last[d][old];
      }
      FOR(i,d,D){
        if(i!=d && T[i]==q) break;
        last[i+1][q] = (d+1);
      }
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3796
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static BigDecimal MAX = new BigDecimal(1_000_000_000_000_000_000L);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        boolean hasZero = false;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if(a[i] == 0) hasZero = true;
        }
        if(hasZero){
            System.out.println(0);
        }else{
            BigDecimal d = new BigDecimal(a[0]);
            boolean over = false;
            for (int i = 1; i < n; i++) {
                d = d.multiply(new BigDecimal(a[i]));
                if(d.compareTo(MAX) == 1){
                    over = true;break;
                }
            }
            if(over) System.out.println(-1);
            else System.out.println(d.longValue());
        }
        sc.close();

    }

}


Measured memory_bytes: 61768
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    int ans = -10000;
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    for(int bit=0; bit<(1<<N); ++bit){
        int X=0, Y=0;
        for(int i=0; i<N; ++i){
            if((bit>>i)&1){
                X+=V[i];
                Y+=C[i];
            }
        }
        ans = max(ans, X-Y);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdint>

using namespace std;

template <class T>
class FenwickTree {
    size_t n;
    vector<T> tree0, tree1;
    void update(vector<T> &tree, size_t i, T x) {
        while (i <= n) {
            tree[i] += x;
            i += i & -i;
        }
    }
    T query(vector<T> &tree, size_t i) {
        T res=0;
        while (i > 0) {
            res += tree[i];
            i -= i & -i;
        }
        return res;
    }
public:
    FenwickTree(size_t n, T e=0): n(n), tree0(n, e), tree1(n, e) {
        tree0 = vector<T>(n+1, e);
        tree1 = vector<T>(n+1, e);
    }
    void update(size_t l, size_t r, T x) {
        update(tree0, l+1, -x*l);
        update(tree1, l+1, x);
        update(tree0, r+1, x*r);
        update(tree1, r+1, -x);
    }
    T query(size_t l, size_t r) {
        T res=0;
        res += query(tree0, r) + query(tree1, r)*r;
        res -= query(tree0, l) + query(tree1, l)*l;
        return res;
    }
    T query(size_t l) {
        return query(l, l+1);
    }
};

int main() {
    size_t n;
    int q;
    scanf("%zu %d", &n, &q);

    FenwickTree<int64_t> tree(n);
    for (int i=0; i<q; ++i) {
        int op;
        scanf("%d", &op);

        if (op == 0) {
            size_t s, t;
            int64_t x;
            scanf("%zu %zu %lld", &s, &t, &x);
            tree.update(s-1, t, x);
        } else if (op == 1) {
            size_t i;
            scanf("%zu", &i);
            printf("%lld\n", tree.query(i-1));
        }
    }

    return 0;
}

Measured memory_bytes: 4720
#include <stdio.h>

int main()
{
    char n[4];
    scanf("%s",n);
    for(int i=0;;i++)
    {
        if(n[i]=='\0')
        {
            printf("\n");
            return 0;
        }
        printf("%c",n[i]=='1'?'9':'1');
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int H, W;
    cin >> H >> W;
    char a[H][W];
    rep(i, H){
        rep(j, W) cin >> a[i][j];
    }
    set<int> iw;
    set<int> jw;
    rep(i, H){
        bool is_w = true;
        rep(j, W) if(a[i][j] == '#') is_w = false;
        if(is_w) iw.insert(i);
    }
    rep(j, W){
        bool is_w = true;
        rep(i, H) if(a[i][j] == '#') is_w = false;
        if(is_w) jw.insert(j);
    }
    rep(i, H){
        if(iw.count(i) == 0){
            rep(j, W){
                if(jw.count(j) == 0) cout << a[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

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

signed main()
{
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int t = S - (i + j);
      if (t >= 0 and t <= K) ans++;
    }
  }

  cout << ans << endl;

  return (0);
}

Measured memory_bytes: 256
#include <iostream>
using int32 = int_fast32_t;
using int64 = int_fast64_t;

int main() {
  int32 n, m, k;
  std::cin >> n >> m >> k;
  int64 a[n];
  int64 b[m];
  for (auto&& x : a) std::cin >> x;
  for (auto&& x : b) std::cin >> x;
  int64 sumA[n+1];
  int64 sumB[m+1];
  sumA[0] = 0;
  sumB[0] = 0;
  for (int i = 1; i <= n; i++) {
    sumA[i] = sumA[i-1] + a[i-1];
  }
  for (int i = 1; i <= m; i++) {
    sumB[i] = sumB[i-1] + b[i-1];
  }
  int32 accA = n, accB = 0;
  int32 book = 0;
  while (accB <= m) {
    while (accA > 0 && sumA[accA] + sumB[accB] > k) {
      accA--;
    }
    if (sumA[accA] + sumB[accB] <= k) {
      book = std::max(book, accA + accB);
    }
    accB++;
  }
  std::cout << book << std::endl;
}


Measured memory_bytes: 9872
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t1 = c/b + (c%b ? 1:0);
    int t2 = a/d + (a%d ? 1:0);
    if (t1 <= t2) puts("Yes");
    else puts("No");
    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const ll INF = 1LL << 60;
    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    REP(i,a) cin >> p[i];
    REP(i,b) cin >> q[i];
    REP(i,c) cin >> r[i];
    sort(RALL(p));
    sort(RALL(q));
    sort(RALL(r));
    ll ans = 0;
    priority_queue<ll,vector<ll>,greater<ll>> pqp;
    priority_queue<ll,vector<ll>,greater<ll>> pqq;
    priority_queue<ll,vector<ll>> pqr;
    REP(i,x) {
        ans += p[i];
        pqp.push(p[i]);
    }
    REP(i,y) {
        ans += q[i];
        pqq.push(q[i]);
    }
    REP(i,c) pqr.push(r[i]);

    while(true) {
        if (pqr.empty()) break;
        ll red = pqp.empty() ? INF: pqp.top();
        ll green = pqq.empty() ? INF: pqq.top();
        ll no = pqr.top();
        if (min(red,green) >= no) break;
        if (red < green) {
            ans -= red;
            pqp.pop();
            ans += no;
            pqr.pop();
        } else {
            ans -= green;
            pqq.pop();
            ans += no;
            pqr.pop();
        }
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m], dist[m];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> c[i] >> d[i];
    }
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < m; k++) dist[k] = 0;
        for (int j = 0; j < m; j++) {
            dist[j] = abs(c[j]-a[i]) + abs(d[j]-b[i]);
        }
        int min = INT_MAX;
        int ans = m - 1;
        for (int j = m - 1; j >= 0; j--) {
            if (min >= dist[j]) {
                min = dist[j];
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <stack>

using namespace std;

int S[10];
int digit = 0;
long long sum = 0;

void calc(stack<long long> q, int i) {
  if (i == digit) {
    long long s = 0;
    long long a = 0;
    while (!q.empty()) {
      int n = q.top();
      q.pop();
      if (n == -1) {
        s += a;
        //cout << a << " ";
        a = 0;
      } else {
        a *= 10;
        a += n;
      }
    }
    s += a;
    //cout << a << " " << endl;
    sum += s;
    return;
  }

  stack<long long> q1(q);
  q1.push(S[i]);
  calc(q1, i + 1);
  
  if (q.top() != -1) {
    stack<long long> q2(q);
    q2.push(-1);
    calc(q2, i);
  }
}
  

int main() {
  long long s;

  cin >> s;

  while (s != 0) {
    int n = s % 10;
    s /= 10;
    S[digit] = n;
    digit++;
  }
  
  stack<long long> q;
  q.push(S[0]);
  calc(q, 1);

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..(N - 1) {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let G = {
        let mut G = vec![std::collections::HashSet::new(); N + 1];
        for i in 0..(N - 1) {
            G[a[i]].insert(b[i]);
            G[b[i]].insert(a[i]);
        }
        G
    };
    let mut parent = vec![N + 1; N + 1];
    let mut children = vec![std::collections::HashSet::new(); N + 1];
    parent[1] = 1;
    fn construct_tree(
        i: usize,
        parent: &mut Vec<usize>,
        children: &mut Vec<std::collections::HashSet<usize>>,
        G: &Vec<std::collections::HashSet<usize>>,
    ) {
        for &j in &G[i] {
            if parent[j] == G.len() {
                parent[j] = i;
                children[i].insert(j);
                construct_tree(j, parent, children, &G);
            }
        }
    }
    construct_tree(1, &mut parent, &mut children, &G);
    fn f(i: usize, children: &Vec<std::collections::HashSet<usize>>) -> (usize, usize) {
        children[i].iter().map(|&j| {
            let (d, k) = f(j, children);
            (d + 1, k)
        })
        .max()
        .unwrap_or((0, i))
    }
    let (_, x) = f(1, &children);
    let mut parent2 = vec![N + 1; N + 1];
    let mut children2 = vec![std::collections::HashSet::new(); N + 1];
    parent2[x] = x;
    construct_tree(x, &mut parent2, &mut children2, &G);
    let (d, _) = f(x, &children2);
    let ans = if d % 3 != 1 { "First" } else { "Second" };

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

Measured memory_bytes: 361024
import java.util.*;
class Main {
  public static void main(String[] args)  {
      Scanner scan_ = new Scanner(System.in);
      int a_ = scan_.nextInt();
      int b_ = scan_.nextInt();
      int c_ = scan_.nextInt();
      int count_ = 0;
      for( ; a_ <= b_ ; a_++ ) {
          if( c_ % a_  == 0 ) {
              count_++;
          }
        
      }
      System.out.println(count_);
  }
}


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

int	main(void)
{
  int N, K;
  int num = 1;
  cin >> N >> K;
  
  while (N > 0)
  {
    if ((num * 2) >= (num + K))
        num += K;
    else
        num *= 2;
    N--;
  }

  cout << num << endl;
}

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

int main(){
    char b;
    cin >> b;

    if(b =='A')cout << 'T' << endl;
    else if(b =='T')cout << 'A' << endl;
    else if(b =='G')cout << 'C' << endl;
    else cout << 'G' << endl;

    return 0;
}

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

using namespace std;

int N, K;
string S[16];
map< string, string > dp[1 << 16][16];

string check(int bit, int last, string used)
{
  if(bit == (1 << N) - 1) return ("");
  if(dp[bit][last].count(used)) return (dp[bit][last][used]);
  string beet = S[last];
  reverse(begin(beet), end(beet));
  beet += used;

  string ret = "~";
  for(int i = 0; i < N; i++) {
    if((bit >> i) & 1) continue;
    int tail = 0;
    string odd;
    for(int j = 0; j < beet.size(); j++) {
      if(tail < K && beet[j] == S[i][tail]) ++tail;
      else odd += beet[j];
    }
    if(tail == K) {
      auto get = check(bit | (1 << i), i, odd);
      if(get != "~") ret = min(ret, string(1, 'A' + i) + get);
    }
  }

  return (dp[bit][last][used] = ret);
}


int main()
{
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> S[i];
  }


  string ret = "~";
  for(int j = 0; j < N; j++) {

    bool used[26] = {};
    for(int i = 0; i < K; i++) {
      used[S[j][i] - 'A'] = true;
    }
    string rest;
    for(int i = 0; i < N; i++) {
      if(used[i]) continue;
      rest += (char) (i + 'A');
    }

    for(int i = 0; i < (1 << N); i++) {
      if(__builtin_popcount(i) != K) continue;
      do {
        string beet;
        int latte = 0, malta = 0;
        for(int k = 0; k < N; k++) {
          if((i >> k) & 1) beet += S[j][latte++];
          else beet += rest[malta++];
        }
        auto get = check(1 << j, j, rest);

        if(get != "~") {
          ret = min(ret, string(1, 'A' + j) + get);
        }
      } while(next_permutation(begin(rest), end(rest)));
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 150860
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    int a=0;
    for(int i=0;i<50;i++){
      if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
       a++;
    }
    printf("%d",a);

}

Measured memory_bytes: 1732
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  int cnt = 0;
  for(int i = 1;i<=n;i++)
  {
    char buf[111111];
    sprintf(buf, "%d", i);
    string str = std::string(buf);
    if(str.length() % 2 == 1)
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int i, j, k, length, key, print_count, A[N];
  
  scanf("%d",&length);
  print_count = length;
  for(i = 0; i < length; i++) scanf("%d",&A[i]);

  for(k = 0; k < length; k++){
      printf("%d",A[k]);
      if( k == length-1 ) printf("\n");
      else printf(" ");
    }
  print_count--;

  for(j = 1; j < length; j++){
    key = A[j];
    i = j-1;
    while( i >= 0 && A[i] > key ){
      A[i+1] = A[i];
      i--;
    }
    A[i+1] = key;
    for(k = 0; k < length; k++){
      printf("%d",A[k]);
      if( k == length-1 ) printf("\n");
      else printf(" ");
    }
    print_count--;
  }

  for(i = 1; i <= print_count; i++){
    for(k = 0; k < length; k++){
      printf("%d",A[k]);
      if( k == length-1 ) printf("\n");
      else printf(" ");
    }
  }
  
  return 0;
}



Measured memory_bytes: 2072
open System
open System.Collections.Generic


let ReadOne T = stdin.ReadLine()|> T
let ReadSplit T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let p =stdin.ReadLine().Split()
    let a,b =int p.[0],int p.[2]
    if p.[1]="+" then (a+b) else (a-b)
    |>stdout.WriteLine
    0


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#define ll long long
using namespace std;

ll n;
vector<ll> c;

int main()
{
  cin >> n;
  c.resize(n);
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
  }

  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());

  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans += c[i] * (i + 2);
    ans %= 1000000007;
  }

  for (int i = 0; i < 2 * n - 2; i++)
  {
    ans *= 2;
    ans %= 1000000007;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
int pow_mod(int a,int n,int mod){
    if(n==0)return 1;
    int ans=pow_mod(a,n/2,mod);
    ans=ans*ans%mod;
    if(n%2==1)ans=ans*a%mod;
    return ans;
}
//扩展GCD
int ex_gcd(int a,int b,int &x,int &y){
   if(b==0){x = 1;y = 0;return a;}
   int g = ex_gcd(b,a%b,x,y);
   int temp = x;
   x = y;
   y = temp - a/b*y;
   return g;
}
//扩展欧几里得的另一种写法
void ex_gcd(int a,int b,int &d,int &x,int &y){
    //求解ax+by=gcd(a,b)的一组解
    if(!b){
        d=a,x=1,y=0;
    }
    else{
        ex_gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
//逆元
int inv(int a,int mod){
   int X,Y;
   int g = ex_gcd(a,mod,X,Y);
   if(g!=1)return -1;
   return (X%mod + mod)%mod;
}
vector<int>G[maxn];
int sz[maxn];
int fa[maxn];
void dfs(int u,int f){
    sz[u]=1;
    fa[u]=f;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(v==f)continue;
        dfs(v,u);
        sz[u]+=sz[v];
    }
}
int p[maxn];
signed main(){
    int n;
    scanf("%lld",&n);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%lld%lld",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,-1);
    int ans=0;
    int inv2=inv(2,mod);
    for(int i=1;i<=n;i++){
        int tot=G[i].size();
        if(G[i].size()==1)continue;
        int now=1;
        for(int j=0;j<tot;j++){
            int v=G[i][j];
            int siz=0;
            if(v==fa[i])siz=n-sz[i];
            else siz=sz[v];
            p[j]=(1-inv(pow_mod(2,siz,mod),mod)+mod)%mod;//点黑的概率
            now*=((1-p[j]+mod)%mod);
            now%=mod;
        }
        int cur=now;
        for(int j=0;j<tot;j++){
            cur+=now*inv((1-p[j]+mod)%mod,mod)%mod*p[j]%mod;
            cur%=mod;
        }
        ans+=inv2*(1-cur+mod)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 23552
line = gets.split(' ').map(&:to_i)

H = line[0]
W = line[1]

if H == 1 or W == 1 then
  print 1
elsif H % 2 == 0 or W % 2 == 0 then
  print H * W / 2
else
  print (H * W + 1) / 2
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

ll judge(int N,ll *A, ll b){
  ll ans=0;
  for(int i=0; i<N; i++){
    ans += abs(A[i] - b);
  }
  return ans;
}



int main() {
  int N;
  cin >> N;
  ll A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i] -= (i+1);
  }
  sort(A, A+N);

  ll lb = A[0];
  ll rb = A[N-1];
  if(N >1){
    ll ans = min(judge(N,A,A[N/2]),min(judge(N,A,A[N/2+1]), judge(N,A,A[N/2-1])));
    cout << ans << endl;
  }
  else
    cout << 0 << endl;
  return 0;
	
  if(N==1){
    cout << 0 << endl;
  }
  else{
  while ((rb - lb) >1){
    ll m = (rb + lb)/2;
    if(judge(N,A,lb) > judge(N,A,m)){
      lb = m;
    }
    else{
      rb = m;
    }
  }
  if(judge(N,A,lb) > judge(N,A,rb)) cout << judge(N,A,rb) << endl;
  else cout << judge(N,A,lb) << endl;
  }

}


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

int main() {
  int n,x;
  cin >> n >>x;
  vector<int>L(n);
  rep(i,n) cin >> L.at(i);
  int sum=0;
  int count=0;
  rep(i,n){
    sum+=L.at(i);
    if(x/sum !=0)count++;
  }
  cout << count + 1 <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 100005 ;
using namespace std ;

int n, A, B, a[N] ;

bool check(int ave) {
	ll ret = 0 ;
	rep(i, 1, n) {
		ll x = (ll) a[i] - (ll) ave * B ;
		if (x <= 0) continue ;
		ret += (x + A - 1) / A ;
	}
	return (ret <= (ll) ave) ;
}

int main() {
	scanf("%d%d%d", &n, &A, &B) ;
	A -= B ;
	rep(i, 1, n) scanf("%d", &a[i]) ;
	sort(a + 1, a + n + 1) ;
	int l = 1, r = (a[n] + B - 1) / B, ret = r ;
	for ( ; l <= r; ) {
		int mid = (l + r) / 2 ;
		if (check(mid)) ret = mid, r = mid - 1 ;
			else l = mid + 1 ;
	}
	printf("%d\n", ret) ; 
	return 0 ;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n{},c{};
    cin>>n;
    int A[n]{};
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(i+1 != A[i]){
            c++;
        }
        if(c>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = INF;
    for(int i = 0; i <= X; i++){
        ll price = i * A;
        price += (X - i) * C * 2;
        if(Y - X + i >= 0){
            ll price2 = price + B * (Y - X + i);
            ll price3 = price + C * 2 * (Y - X + i);
            // cout << i << " " << price2 << " " << price3 << endl; 
            ans = min(ans, price2);
            ans = min(ans, price3);
        }else ans = min(ans, price);
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
    int main(void) {
     int a, b, c, min ;
     scanf("%d", &a);
     scanf("%d", &b);
     scanf("%d", &c);
     if (a < b) {
       if (b < c) { min = a + b; }
         else {min = a+ c;}
     } else if (a <c ) {min = a+ b;} 
       else {min = b +c;}
     
     printf ("%d", min); 
     
     return 0;
     
    }

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = -1;
    rep(i,1010) {
        if (floor(i*0.08) == a && floor(i*0.1) == b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()
ans = 'Yes'

if '#' in [S[A-1], S[B-1], S[C-1], S[D-1]]:
    ans = 'No'
elif '##' in S[A-1:C] or '##' in S[B-1:D]:
    ans = 'No'
elif A < B and C > D:
    if '...' not in S[B-2:min(C, D)+1]:
        ans = 'No'

print(ans)

Measured memory_bytes: 3572
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s = sc.chars();
    let mut ans: i64 = 0;
    for i in 1..n{
        if s[i-1] != s[i] {
            ans += 1;
        }
    }
    println!("{}", ans+1);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 4476
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 300 + 47;

int a, b, c, d;



int main()
{
    int q;
    scanf("%d", &q);
    FOR(_, 0, q)
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        --c, --d;
        int res = (a + b) / (min(a, b) + 1);
        int l = 0, r = a + 1;
        while(r - l > 1)
        {
            int m = (l + r) / 2;
            int x = (m - 1) / res;
            if ((a - m + 1) * 1LL * res >= b - (m-1) / res)
                l = m;
            else r = m;
        }
        string ans = "";
        FOR(i, c, d+1)
            if (i < l + (l-1)/res)
            {
                if (i % (res + 1) == res)
                    ans += 'B';
                else
                    ans += 'A';
            }
            else
            {
                if ((a + b - i - 1) % (res + 1) == res)
                    ans += 'A';
                else
                    ans += 'B';
            }
        printf("%s\n", ans.c_str());
    }
}


Measured memory_bytes: 384
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + 'sakoda'  +str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int a,b,h; cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 3556
#include<stdio.h>

int main()
{
   int N,a,b,i,j;

   scanf("%d",&N);
   for(i=1;i<=9;i++)
      for(j=1;j<=9;j++)
         if(i*j==N)
         {   
            printf("Yes\n");
            return 0;
         }   
   printf("No\n");
   return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	var t []Tenbou
	for i := 0; i < n; i++ {
		var h int
		fmt.Scanf("%d", &h)
		temp := Tenbou{Height: h, Road: []int{}}
		t = append(t, temp)
	}

	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		a = a - 1
		b = b - 1
		t[a].Road = append(t[a].Road, b)
		t[b].Road = append(t[b].Road, a)
	}

	count := 0
	for _, i := range t {
		flag := true
		for _, j := range i.Road {
			if i.Height <= t[j].Height {
				flag = false
				break
			}
		}
		if flag {
			count++
		}
	}

	fmt.Println(count)
}

type Tenbou struct {
	Height int
	Road   []int
}


Measured memory_bytes: 13812
#include <stdio.h>
int main(void) {
   int i,j,N,p[1000][3],a,b,c,temp;
   scanf("%d",&N);
   for(i=0;i<N;i++){
	   scanf("%d %d %d",&a,&b,&c);
	   if(a>b){temp=a;a=b;b=temp;}
	   if(a>c){temp=a;a=c;c=temp;}
	   if(c<b){temp=c;c=b;b=temp;}
	   if(c<a){temp=c;c=a;a=temp;}
	   p[i][0]=a;
	   p[i][1]=b;
	   p[i][2]=c;
   }
   for(i=0;i<N-1;i++){
	   if(p[i][0]!=0){
		   for(j=i+1;j<N;j++){
			   if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
				   p[j][0]=0;p[j][1]=0;p[j][0]=0;
			   }
		   }
	   }
   }
   temp=0;
   for(i=0;i<N;i++){
	   if(p[i][0]==0){temp++;}
   }
   printf("%d\n",temp);
	return 0;
}



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

typedef struct{
  int parent;//parent
  int left;//left child
  int right;//right sibling
}Tree;

int main(){
  Tree *t;
  int n,i,j,id,k,prov,depth,tn; //k=degree,prov=karinohensu,tn=type_number
  char type[3][15]={"root","internal node","leaf"};
  scanf("%d",&n);
  t=(Tree*)malloc(sizeof(Tree)*n);//akekata

  for(i=0;i<n;i++){
    t[i].parent=-1;
    t[i].left=-1;
    t[i].right=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      if(j==0){
	scanf("%d",&t[id].left);
	prov=t[id].left;
      }
      else{
	scanf("%d",&t[prov].right);
	  prov=t[prov].right;
      }
	  t[prov].parent=id;
    }  
  }
  
  for(i=0;i<n;i++){
    //depth
    depth=0;
    prov=t[i].parent;
    while(prov!=-1){
      prov=t[prov].parent;
      depth++;
    }    //end of deptp
    //type
    if(depth==0)
      tn=0;
    else if(t[i].left==-1)
      tn=2;
    else
      tn=1;
    //ende of type
    printf("node %d: parent = %d, depth = %d, ",i,t[i].parent,depth);
    printf("%s, [",type[tn]);
    if(t[i].left!=-1)
      {
	printf("%d",t[i].left);
	prov=t[i].left;
	while(t[prov].right!=-1){
	  printf(", %d",t[prov].right);
	  prov=t[prov].right;
	}
      }
    printf("]\n");
  }
  free(t);
  return 0;
}

Measured memory_bytes: 1680
<?php
class main {
    var $map = array();
    var $h;
    var $w;
 
    function run() {
        fscanf(STDIN, "%d %d", $h, $w);
        $this->h = $h;
        $this->w = $w;
        $this->map = array();
        $sum = 0;
        for ($i = 0; $i < $h; $i++) {
            $line = trim(fgets(STDIN));
            $this->map[] = str_split($line);
            $tmp = array_count_values($this->map[$i]);
            $sum += isset($tmp['#'])?$tmp['#']:0;
        }
 
        if ($sum != ($h + $w -1)) {
            echo "Impossible";
            exit;
        }
        $flag = 0;
 
        if ($this->map[0][0] == "#") {
            $flag = $this->check(0 ,0);
        } else {
            $flag = 1;
        }
 
        if ($flag) {
            echo "Impossible";
        } else {
            echo "Possible";
        }
    }
    function check($y, $x) {
        $left = 0;
        $right = 0;
        $up = 0;
        $down = 0;
        if ($y == $this->h - 1 && $x == $this->w - 1) {
            if ($this->map[$y][$x] == "#") {
                return 0;
            } else {
                return 1;
            }
        }
        if ($y != 0 && $this->map[$y - 1][$x] == "#") {
            $up = 1;
        };
        if ($y != $h - 1 && $this->map[$y + 1][$x] == "#") {
            $down = 1;
        };
        if ($x != 0 && $this->map[$y][$x - 1] == "#") {
            $left = 1;
        };
        if ($x != $w - 1 && $this->map[$y][$x + 1] == "#") {
            $right = 1;
        };
 
        if ($y != 0 || $x != 0) {
            if (($up + $left) != 1) {
                return 1;
            }
        }
 
        if ($y != ($this->h - 1) || $x != ($this->w - 1)) {
            if (($down + $right) != 1) {
                return 1;
            }
        }
 
        return $this->check($y + $down, $x + $right);
    }
}
$object = new main();
$object->run();

Measured memory_bytes: 3580
import java.io.IOException;
import java.util.Scanner;

public class Main {
    static int a, n;

    static int bfs(int p, int q, int pre, int k, int pi) {
        if (p < 0) return 0;
        if (p == 0) return 1;
        if (n <= k) return 0;

        int res = 0;
        for (int i = pre; pi*i <= a; i++) {
            int np = p*i - q;
            int nq = q*i;
            res += bfs(np, nq, i, k + 1, pi * i);
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            a = sc.nextInt();
            n = sc.nextInt();
            if (p == 0)
                break;
            System.out.println(bfs(p, q, 1, 0, 1));
        }
    }
}

Measured memory_bytes: 31940
// A - ABCxxx

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	cout << "ABC" << N << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 500005
#define ll long long
using namespace std;
bool f(ll a,ll b,ll c,ll d){
	if(b<c||a>d)return false;
	return true;
}
int main(){
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	if(a>b)swap(a,b);
	for(ll i=1;i<n;i++){
		ll x1=a+c*i,x2=a+d*i,x3=a-c*i,x4=a-d*i;
		ll y1=b+c*(n-1-i),y2=b+d*(n-1-i),y3=b-c*(n-1-i),y4=b-d*(n-1-i);
		bool flag=0;
		flag=f(x1,x2,y1,y2)|f(x1,x2,y4,y3)|f(x4,x3,y1,y2)|f(x4,x3,y4,y3);
		if(flag){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

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

using namespace std;

void DrawChessBoard(int h, int w) {
	for( int i=0; i<h; i++ ) {
		char c1, c2;
		if( i % 2 == 1 ) {
			c1 = '#';
			c2 = '.';
		} else {
			c1 = '.';
			c2 = '#';
		}
		for( int j=0; j<w; j++ ) {
			if( j % 2 == 1 ) { cout << c1; }
			else { cout << c2; }
		}
		cout << endl;
	}
}

int main() {
	int h,w;
	while( true ) {
		cin >> h >> w;
		if( h == 0 && w == 0 ) break;
		DrawChessBoard( h, w );
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int res[N + 5];
int val[N + 5];

vector<int> lst[N + 5];

vector<int> lis;


void dfs(int cur, int pre) {
	int stats = -1, tmp = -1;
	if(lis.size() == 0 || lis.back() < val[cur]) {
		lis.pb(val[cur]);
	} else {
		int lo = 0;
		int hi = lis.size() - 1;
		while(lo <= hi) {
			int mid = (lo + hi) / 2;
			if(lis[mid] >= val[cur]) {
				stats = mid;
				hi = mid - 1;
			} else lo = mid + 1;
		}
		tmp = lis[stats];
		lis[stats] = val[cur];
	}
	res[cur] = lis.size();
	for(int i = 0;i < lst[cur].size();i++) {
		int to = lst[cur][i];
		if(to == pre) continue;
		dfs(to, cur);
	}
	if(stats == -1) lis.pop_back();
	else lis[stats] = tmp;
}

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) cin>>val[i];
	for(int i = 1;i < n;i++) {
		int u, v;
		cin>>u>>v;
		lst[u].pb(v);
		lst[v].pb(u);
	}
	dfs(1, 1);
	for(int i = 1;i <= n;i++) cout<<res[i]<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 27536
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    string s;
    ll n;
    cin>>n;
    pr(n/3);
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

string str;
int ans = 0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> str){
		bool flag = true;
		rep(i,str.size()/2){
			if(str[i] != str[str.size()-i-1]){
				flag = false;
				break;
			}
		}
		if(flag == true) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <unordered_map>
#include <set>
using namespace std;

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

    unordered_map<long long, long long> M;

    for (long long i = 1; i <= N; ++i) {
        long long p;
        cin >> p;
        M[p] = i;
    }

    long long ans = 0;
    multiset<long long> S;
    S.insert(0);
    S.insert(0);
    S.insert(N + 1);
    S.insert(N + 1);

    for (long long p = N; p >= 1; --p) {
        long long i = M[p];
        S.insert(i);
        
        auto itr1 = S.find(i);
        auto itr2 = S.find(i);
        long long x1 = *(--itr1);
        long long x2 = *(--itr1);
        long long y1 = *(++itr2);
        long long y2 = *(++itr2);

        ans += p * ((x1 - x2) * (y1 - i) + (i - x1) * (y2 - y1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8996
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    H, W = read_ints()
    modulo = 10**9+7
    board = []
    for _ in range(H):
        board.append(input().strip())
    count = [[0]*W for _ in range(H)]
    count[0][0] = 1
    for i in range(H):
        for j in range(W):
            if board[i][j] == '.':
                if j > 0 and board[i][j-1] == '.':
                    count[i][j] = (count[i][j]+count[i][j-1])%modulo
                if i > 0 and board[i-1][j] == '.':
                    count[i][j] = (count[i][j]+count[i-1][j])%modulo
    return count[-1][-1]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 52464
import collections
import sys

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

cnt = collections.Counter(d)

if d[0]!=0:
    print(0)
    sys.exit(0)

if cnt[0]!=1:
    print(0)
    sys.exit(0)    
    
p = 1

for i in range(1,max(d)+1):
    if cnt[i] == 0:
        print(0)
        sys.exit(0)  
    else:
        p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353

print(p)

Measured memory_bytes: 19936