akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

#define MAX_V 100010
struct edge {
	int to;
	int cost;
};
using P = pair<int, int>;
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	cin >> V;
	rep(i, 0, V) {
		G[i].push_back({ (i + 1) % V,1 });
		G[i].push_back({ (i * 10) % V,0 });
	}
	dijkstra(1);
	printf("%lld", d[0] + 1);
	return 0;
}

Measured memory_bytes: 7164
import sys
input =sys.stdin.readline
import heapq

def dijkstra(edge, start):
    n = len(edge)
    dist = [float("inf")]*n
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, v = heapq.heappop(que)
        if dist[v] < d:
            continue
        for nv, nd in edge[v]:
            if dist[nv] > d + nd:
                dist[nv] = d + nd
                heapq.heappush(que, (dist[nv], nv))
    return dist

n, m, s = map(int, input().split())
G = [[] for _ in range(n)]
if s >= 2500:
  for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, b))
    G[v].append((u, b))
  L = dijkstra(G, 0)
else:
  for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, a, b))
    G[v].append((u, a, b))
  CD = [list(map(int, input().split())) for _ in range(n)]
  edge = [[] for _ in range(n*2500)]
  for i in range(n):
    c, d = CD[i]
    for k in range(2500):
      for v, a, b in G[i]:
        if k >= a:
          edge[2500*i+k].append((2500*v+(k-a), b))
      if k+c < 2500:
        edge[2500*i+k].append((2500*i+(k+c), d))
  dist = dijkstra(edge, s)
  L = [0]*n
  for i in range(n):
    L[i] = min(dist[2500*i:2500*(i+1)])
print(*L[1:], sep="\n")

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

int main() {
  int N,bob=0,alice=0;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i=0;i<N;i++){
    if(i%2 == 0)
      alice += a.at(i);
    else
      bob += a.at(i);
  }
  cout << alice-bob << endl;
}


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

int main(void){

  int a, b;

  cin >> a;
  cin >> b;

  if(a < b)
    cout << "a < b" << endl;

  else if(a > b)
    cout << "a > b" << endl;

  else
    cout << "a == b" << endl;

  return 0;
}

Measured memory_bytes: 1156
$h, $w = gets.split.map &:to_i

$ss = Array.new($h, nil)

$h.times{ |i|
	$ss[i] = gets.chomp.split("")
}

max_route_size = 0

def max_route(temp, map, count)
	is_ex = false
	temp_next = []

	temp.each{ |temp_i|
		h = temp_i[0]
		w = temp_i[1]

		if h > 0 && $ss[h - 1][w] == "." && map[h - 1][w] == false then
			map[h - 1][w] = true
			is_ex = true
			temp_next << [h - 1, w]
		end

		if w > 0 && $ss[h][w - 1] == "." && map[h][w - 1] == false then
			map[h][w - 1] = true
			is_ex = true
			temp_next << [h, w - 1]
		end

		if h < $h - 1 && $ss[h + 1][w] == "." && map[h + 1][w] == false then
			map[h + 1][w] = true
			is_ex = true
			temp_next << [h + 1, w]
		end

		if w < $w - 1 && $ss[h][w + 1] == "." && map[h][w + 1] == false then
			map[h][w + 1] = true
			is_ex = true
			temp_next << [h, w + 1]
		end
	}
	
	if is_ex then
		max_route(temp_next, map, count + 1)
	else
		count
	end
end


(0...$h).each{ |h_i|
	(0...$w).each{ |w_i|
		if $ss[h_i][w_i] == "." then
			map = Array.new($h).map{Array.new($w, false)}
			map[h_i][w_i] = true
			res = max_route([[h_i, w_i]], map, 0)
			
			if max_route_size < res then
				max_route_size = res
			end
		end
	}
}

puts max_route_size

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> order(n);
    rep(i,n){
        order[a[i]-1]=i+1;
    }
    rep(i,n){
        if(i==n-1){
            cout<<order[i]<<endl;
        }else{
            cout<<order[i]<<" ";
        }
    }
}

Measured memory_bytes: 1664
import Data.Char ( digitToInt )

main :: IO ()
main = do
  [n,a,b] <- map read . words <$> getLine 
  print $ f n a b

f :: Int -> Int -> Int -> Int
f n a b = sum [ m | m <- [1..n]
                  , a   <= g m
                  , g m <= b ]
  where
    g = sumDigits

sumDigits
  :: Int -> Int
sumDigits = sum . map digitToInt . show 

Measured memory_bytes: 1020
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]

#import numpy as np

lastdi = [0 for i in range(26)]
ans_c = []

d = 0
while True:
  if d == D:
    break
  if d > D - 2:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] - sum([c[k]*( 2*d-lastdi[k]+1) for k in range(26) if k not in [i,i2]] ) -c[i] -c[i2]*(d-lastdi[i2]) for i in range(26) for i2 in range(26) ]
    idx = a.index(max(a))
    best_i2 = idx % 26 + 1
    best_i1 = (idx // 26) % 26 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    
    d += 2

for i in range(D):
  print(ans_c[i])

Measured memory_bytes: 9300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray;
		Node[] nodes = new Node[n];
		for(int i = 0; i < n; i++){
			tmpArray = br.readLine().split(" ");
			
			int id = Integer.parseInt(tmpArray[0]);
			int left = Integer.parseInt(tmpArray[1]);
			int right = Integer.parseInt(tmpArray[2]);
			nodes[id] = new Node(id, left, right);
			nodes[id].nodes = nodes;
		}
		
		//?????¨???????????¨???????¨????
		for(int i = 0 ; i < nodes.length ; i++){
			if(nodes[i].left != -1){
				nodes[nodes[i].left].parent = i;
				nodes[i].degree++;
				if(nodes[i].right != -1){
					nodes[nodes[i].left].sibling = nodes[i].right; 
				}
			}
			if(nodes[i].right != -1){
				nodes[nodes[i].right].parent = i;
				nodes[i].degree++;
				if(nodes[i].left != -1){
					nodes[nodes[i].right].sibling = nodes[i].left;
				}
			}
		}
		
		//??????
		for(int i = 0; i < n; i++){
			System.out.println("node " + nodes[i].id + ": parent = " + nodes[i].parent 
					+ ", sibling = " + nodes[i].sibling + ", degree = " + nodes[i].degree 
					+ ", depth = " + nodes[i].getDepth() + ", height = " + nodes[i].getHeight()
					+", " + nodes[i].getType());
		}
	}

}

class Node {
	int id;
	int left = -1;
	int right = -1;
	int parent = -1;
	int sibling = -1;
	int degree = 0;
	Node[] nodes;
	
	public Node (int id, int left, int right){
		this.id =id;
		this.left = left;
		this.right = right;
	}
	
	int getDepth (){
		if(parent == -1){
			return 0;
		}
		return 1 + nodes[parent].getDepth();
	}
	
	int getHeight (){
		if(left == -1 && right == -1){
			return 0;
		}
		
		int heightL = 0;
		if(left != -1){
			heightL = nodes[left].getHeight();
		}
		
		int heightR = 0;
		if(right != -1){
			heightR = nodes[right].getHeight();
		}
		
		return Math.max(heightL, heightR) + 1;
	}
	
	String getType (){
		if(parent == -1){
			return "root";
		}
		else if(left == -1 && right == -1){
			return "leaf";
		}
		else {
			return "internal node";
		}
	}
}

Measured memory_bytes: 24412
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(n):
    mini = i
    for j in range(i, n):
        if a[j] < a[mini]:
            mini = j
    if i != mini:
        a[i], a[mini] = a[mini], a[i]
        count += 1

print(*a)
print(count)

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

using namespace std;
vector<bool> visit(200010, false);
vector<int> G[200010];
vector<int> d(200010, 0), res(200010, 0);

void dfs(int n) {
	visit[n] = true;
	for(int i = 0; i < G[n].size(); ++i) {
		if(visit[G[n][i]]) continue;
		res[G[n][i]] = res[n] + d[G[n][i]];
		dfs(G[n][i]);
	}
}

int main() {
	int N, Q; cin >> N >> Q;
	for(int i = 0; i < N-1; ++i) {
		int from, to; cin >> from >> to; from--; to--;
		G[from].push_back(to);
		G[to].push_back(from);
	}
	for(int i = 0; i < Q; ++i) {
		int node, cnt; cin >> node >> cnt; node--;
		d[node] += cnt;
	}

	/*
	queue<int> q;
	q.push(0); // 0スタート
	res[0] = d[0];

	while(!q.empty()) {
		int n = q.front(); q.pop();
		int cost = res[n];
		for(int i = 0; i < G[n].size(); ++i) {
			res[G[n][i]] = cost + d[G[n][i]];
			q.push(G[n][i]);
		}
	}
	*/

	res[0] = d[0];
	dfs(0);

	cout << res[0];
	for(int i = 1; i < N; ++i) {
		cout << " " << res[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 24320
#include<stdio.h>

int main(void)
{
    int input=-1;
    
    while( input<0 || 86400 < input)
    {
        char buffer[256];
        fgets(buffer, 256, stdin);
        input = atoi(buffer);
    }
    int sec = input % 60;
    int minuit = input / 60;
    int min = minuit % 60;
    int hour = minuit / 60;
    
    printf("%d:%d:%d\n", hour, min, sec);
    
    return(0);
}


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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      long long A = 1LL * i * i * i * i * i;
      long long B = 1LL * j * j * j * j * j;
      if (A - B == x) {
        cout << i << ' ' << j << '\n';
        return 0;
      }
    }
  }
  return 0;
}


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

int main(){
	ll N,K;
	int count=0;
	cin>>N>>K;
	vector<long double> vec(N+1);
	long double ans=0;

	for(int i=0;i<N;i++)
		vec.at(i)=i+1;


	for(int i=0;i<N;i++){
		double j = vec.at(i);
		count=0;
		while(j<K){
			j*=2;
			count++;
		}
		vec.at(i)=count;
	}

	for(int i=0;i<N;i++)
		ans+=pow(0.5,vec.at(i));
	cout<<setprecision(12)<<ans/N<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int i,n;
  scanf("%d",&n);
  int b[n+100],max=0;
  for(i=0;i<n-1;i++){
    scanf("%d",&b[i]);
    if(i==0)
      max += 2*b[i];
    else{
      if(b[i-1] > b[i])
        max += 2*b[i]-b[i-1];
      else
        max += b[i];
    }
  }
  printf("%d",max);
  return 0;

}

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

using namespace std;

const int maxN = 101;
const int maxW = 1e5 + 10;
int v[maxN], w[maxN];
long long dp[2][maxW];
int n, W;

int main()
{
	cin >> n >> W;
	for (int i = 1; i <= n; ++i)
	{
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i <= W; ++i)
	{
		dp[0][i] = 0;
	}

	for (int i = 1; i <= n; ++i)
	{
		int curr = i % 2, prev = (i + 1) % 2;

		for (int j = 1; j <= W; ++j)
		{
			long long opt1 = dp[prev][j];
			long long opt2 = (j - w[i] >= 0) ? dp[prev][j - w[i]] + v[i] : 0;
			dp[curr][j] = max(opt1, opt2);
		}
	}	

	int curr = n % 2;
	cout << dp[curr][W] << endl;
	return 0;
}

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

using ll = long long;

struct edge { int from, to, cost;};

edge es[5001];

int d[2501];
int V, E, INF = 1e9;

void shortest_path(int s) {
    rep(i, V) d[i] = INF;
    d[s] = 0;
    rep(j, V * 2) {
        bool update = false;
        rep(i, E) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (j >= V) d[e.to] = - INF;
                //cout << e.from << " " << e.to << " " << e.cost << " " << d[e.to] << endl;
                update = true;
            }
        }
        if (!update) break;
    }
}

bool find_negative_loop() {
    rep(i, V) {
        rep(j, E) {
            edge e = es[j];
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (e.to == V - 1) return true;
            }
        }
    }
    return false;
}

int main() {
    ll P, A, B, C;
    cin >> V >> E >> P;
    rep(i, E) {
        cin >> A >> B >> C;
        es[i].from = A - 1;
        es[i].to = B - 1;
        es[i].cost = P - C;
    }
    shortest_path(0);
    //rep(i, V) cout << d[i] << endl;
    /*
    if (find_negative_loop()) {
        cout << -1 << endl;
    } else {
        cout << max(0, -d[V - 1]) << endl;
    }
    */
    //rep(i, V) cout << d[i] << endl;
    if (d[V - 1] <= - INF) cout << -1 << endl;
    else cout << max(0, - d[V - 1]) << endl;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    ll acc = 0LL, ans = 0LL;

    REP(i,n){
        ll a; cin >> a;
        if(a==0){
            ans += acc/2;
            acc=0;
        } else {
            acc+=a;
        }
    }

    cout << ans+acc/2 << endl;



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
int partition(int A[],int p,int r);
int main(void){
	int i,n,q;
	scanf("%d",&n);
	int A[n];
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	q=partition(A,0,n-1);
	
	for(i=0;i<n;i++){
		if(i>0){
			printf(" ");
		}
		
		if(i==q){
			printf("[");
		}
		printf("%d",A[i]);
		if(i==q){
			printf("]");
		}
	}
	
	printf("\n");
	return 0;
}

int partition(int A[],int p,int r){
	int i,j,tmp,parti;
	
	parti=A[r];// partition
	i=p-1;
	for(j=p;j<r;j++){
		if(A[j]<=parti){
			i++;
			tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
		}
	}
	
	tmp=A[i+1];
	A[i+1]=A[r];
	A[r]=tmp;
	
	return i+1;
	
}


Measured memory_bytes: 2136
#define _CRT_SECURE_NO_WARNINGS
#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 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 int MAX = 1000 * 1000 + 47;

int n, e, t;
int X[MAX];
LL dp[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, e, t;
	cin >> n >> e >> t;
	FOR(i, 0, n)
	{
		cin >> X[i];
	}

	FOR(i, 0, n + 1) dp[i] = INF;
	dp[0] = 0;
	int p = 0;
	LL minn = LINF;

	FOR(i, 1, n + 1)
	{
		while (2 * (X[i - 1] - X[p]) > t)
		{
			minn = min(dp[p] - 2 * X[p], minn);
			p++;
		}

		dp[i] = minn + 2 * X[i - 1];
		dp[i] = min(dp[i], dp[p] + t);
	}

	cout << dp[n] + e;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main{
    static int[] A,L,R;
    static int N,Q;
    static String str;
    static int ans;
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      N = sc.nextInt();
      Q = sc.nextInt();
      str = sc.next();
      A = new int[N];
      R = new int[Q];
      L = new int[Q];
      for(int i=0;i<Q;i++){
        L[i]=sc.nextInt();
        R[i]=sc.nextInt();
      }
      A[0]=0;
      if(str.charAt(0)=='A' && str.charAt(1)=='C'){
        A[1]=1;
      }
      else{
        A[1]=0;
      }
      for(int i=2;i<N;i++){
        if(str.charAt(i-1)=='A' && str.charAt(i)=='C'){
          A[i]=A[i-1]+1;
        }
        else{
          A[i]=A[i-1];
        }
      }
      for(int i=0;i<Q;i++){
        ans = A[R[i]-1]-A[L[i]-1];
        System.out.println(ans);
      }
    }

}

Measured memory_bytes: 91732
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include<stack>
using namespace std;
typedef long long LL;
const LL Maxn = 1e6 + 7;
const int Inf = 1e9 + 7;
LL n , x;
LL MID[Maxn] , Head[Maxn] , Tail[Maxn];

priority_queue < LL , vector<LL> , greater<LL> > T1;
priority_queue <LL> T2;

int main()
{
	while( cin >> n ){
		LL Sum1 = 0 , Sum2 = 0;
		for( int i = 1 ; i <= n ; i++ ){
			scanf(" %lld",&x);
			T1.push(x);
			Sum1 += x;
		}
		for( int i = 1 ; i <= n ; i++ ){
			scanf(" %lld",&MID[i]);
		}
		for( int i = 1 ; i <= n ; i++ ){
			scanf(" %lld",&x);
			T2.push(x);
			Sum2 += x;
		}
		Head[0] = Sum1 , Tail[n+1] = Sum2;
		for( int i = 1 ; i <= n ; i++ ){
			T1.push(MID[i]);
			Sum1 += ( MID[i] - T1.top() );
			T1.pop();
			Head[i] = Sum1;
		}
		for( int i = n ; i >= 1 ; i-- ){
			T2.push(MID[i]);
			Sum2 += ( MID[i] - T2.top() );
			T2.pop();
			Tail[i] = Sum2;
		}
		LL ans = -(1LL << 60);
		for( int i = 0 ; i <= n ; i++ ){
			ans = max( ans , Head[i] - Tail[i+1] );
		}
		cout << ans << endl;
		memset( MID , 0 , sizeof(MID) );
		memset( Head , 0 , sizeof(Head) );
		memset( Tail , 0 , sizeof(Tail) );
		while(!T1.empty())	T1.pop();
		while(!T2.empty())	T2.pop();
	}
}

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

signed main(){
    //cout << setprecision(16) ;
    ios::sync_with_stdio(false);
	cin.tie(0);

    ll n,k;
    cin>>n>>k;
    ll a[n];
    vector<vector<int>> mp(200010);
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]].push_back(i);
    }
    ll cnt=0;
    ll now = 0;

    while(true){
        auto itr = upper_bound(mp[a[now]].begin(),mp[a[now]].end(),now);
        int next;
        if(itr==mp[a[now]].end()){
            itr = mp[a[now]].begin();
            cnt++;
        }
        now = *itr;
        now++;
        now%=n;
        if(now == 0) break;
    }
    
    cnt++;
    k%=cnt;
    now=0;

    while(true){
        int t=a[now];
        auto itr = upper_bound(mp[t].begin(),mp[t].end(),now);
        if(itr == mp[t].end()){
            itr = mp[t].begin();
            k--;
        }
        if(k==0) break;
        
        now = *itr;
        now++;
        now%=n;
    }
    for(;now<n;now++){
        int t=a[now];
        auto itr = upper_bound(mp[t].begin(),mp[t].end(),now);
        if(itr == mp[t].end()){
            cout<<a[now]<<" ";
        }
        else {
            now = *itr;
        }
        
    }
    cout<<endl;
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 

int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 

int   main(){
   int n;
   cin>>n;
   int temp;
   vector<int> a;
   for(int i=0;i<n;++i){
       cin>>temp;
       a.push_back(temp);
   }
   sort( a.begin(), a.end() );
// a.erase( unique( a.begin(), a.end() ), a.end() );
//  n = a.size();
 int ans= 0 ;
  for(int i=0;i<n-2;++i){
      for(int j=i+1;j<n-1;++j){
          for(int k=j+1;k<n;++k){
              if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
                  ans++;
              }
          }
      }
  }
   
   cout<<ans;
  
    return 0;

}


Measured memory_bytes: 3628
import collections
N = int(input())
A = list(map(int,input().split()))
Cn_A = collections.Counter(A)
ans_list = [0]*len(Cn_A)
ans = 0
for i,j in enumerate(Cn_A.values()):
    ans+=j*(j-1)//2
for i in A:
    j = Cn_A[i]
    print(ans-(j*(j-1)//2)+((j-1)*(j-2)//2))
    


Measured memory_bytes: 34108
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

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

//code start from here 

int main() {
	fast;
	readstr(s)
	readstr(g)
	bool flag=false;
	loop(j,0,s.length()){
		if(s[j]!=g[j]){
			cout<<"No"<<endl;
			flag=true;
			break;
		}

	}
	if(!flag){
		if(s.length()-g.length()==-1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

//ends here 

Measured memory_bytes: 3656
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

print(sum(A[::2]) - sum(A[1::2]))

Measured memory_bytes: 3572
#include<cstdio>
inline int Min(int a,int b){return a<b?a:b;}
int cnt[2],n,m,a,b;
bool A[1005][1005];
inline bool work(int x,int y){
	if(x>n&&y>m)return 1;
	if(x==a+1&&y==b+1){
		for(int i=x,j;i<=n;++i)
			for(j=y;j<=m;++j)A[i][j]=1;
		return 1;
	}
	if(x>n||y>m)return 0;
	if(n-x+1>=a&&m-y+1>=b){
		for(int i=0,j;i<a;++i)
			for(j=0;j<b;++j)A[x+i][y+j]=1;
		return work(x+a,y+b);
	}
}
int main(){
	int i,j;
	scanf("%d%d%d%d",&n,&m,&b,&a);
	if(!work(1,1))puts("-1");
	else for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)printf("%d",A[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2176
import math


def dsum(b,n):
    if n<b:
        return n
    else:
        return n%b+dsum(b,n//b)

def main():
    n=int(input())
    s=int(input())
    if n == s:
        return n+1
    elif s > (n+1)//2:
        return -1
    else:
        rn = math.floor(math.sqrt(n))
        for i in range(2,rn+1):
            if dsum(i,n) == s:
                return i
        for i in range(rn,0,-1):
            if (n-s) % i == 0:
                b = (n-s)//i+1
                if dsum(b,n) == s:
                    return b
        return -1



print(main())

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#define lowbit(x) ((x) & -(x))
#define EB emplace_back
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define maxn 1005
using namespace std;

struct DSU {
    vector<int> s, p;
    DSU(int sz) : s(sz + 1, 1), p(sz + 1, -1) {}
    int find(int x) {
        return (p[x] == -1) ? x : (p[x] = find(p[x]));
    }
    bool join(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(s[x] < s[y]) swap(x, y);
        s[x] += s[y]; p[y] = x;
        return true;
    }
    int cnt() {
        int ret = 0;
        for(int i = 1; i < SZ(p); i++) {
            if(p[i] == -1) ret++;
        }
        return ret;
    }
};

int mx[4] = {0, 0, -1, 1};
int my[4] = {-1, 1, 0, 0};
char mp[maxn][maxn];
int id[maxn][maxn];
int n, m;

bool cool(int i, int j) {
    if(i < 0 || i >= n) return false;
    if(j < 0 || j >= m) return false;
    return mp[i][j] == '#';
}

int solve() {
    int R = 0, C = 0;
    for(int i = 0; i < n; i++) {
        int cnt = 0;
        if(mp[i][0] == '#') cnt++;
        if(mp[i][m - 1] == '#') cnt++;
        for(int j = 1; j < m; j++) {
            if(mp[i][j - 1] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) R++;
    }
    for(int j = 0; j < m; j++) {
        int cnt = 0;
        if(mp[0][j] == '#') cnt++;
        if(mp[n - 1][j] == '#') cnt++;
        for(int i = 1; i < n; i++) {
            if(mp[i - 1][j] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) C++;
    }
    if((R + C) > 0 && (R != n || C != m)) return -1;
    DSU loli(n * m);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(mp[i][j] == '.') cnt++;
            else {
                for(int k = 0; k < 4; k++) {
                    int ii = i + mx[k];
                    int jj = j + my[k];
                    if(cool(ii, jj)) {
                        loli.join(id[i][j], id[ii][jj]);
                    }
                }
            }
        }
    }
    return loli.cnt() - cnt;
}


int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    /*cin >> n >> m; int tot = 0;
    for(int i = 0; i < n; i++) {
        cin >> mp[i];
        for(int j = 0; j < m; j++)
            id[i][j] = ++tot;
    }
    cout << solve() << '\n';*/
    int arr[3];
    for(int i = 0; i < 3; i++)
        cin >> arr[i];
    sort(arr, arr + 3);
    cout << (arr[0] + arr[1] == arr[2] ? "Yes" : "No") << '\n';
    return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string a,b;
  cin >> a >> b;
  string Check = a + b;
  bool ans = false;
  int c = atoi(Check.c_str());
  for (int i = 1; i < 500; i++) {
    if(i * i == c) ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll ev[200000], od[200000];
    vector<pair<ll, ll> > even, odd;
    ll n;
    ll v;
    cin>>n;
    MEMSET(ev, 0); MEMSET(od, 0);
    rep(i, n){
        cin>>v;
        if(i%2==0) ev[v]++;
        else od[v]++;
    }
    rep(i, 200000) if(ev[i]!=0) even.push_back({ev[i], i});
    rep(i, 200000) if(od[i]!=0) odd.push_back({od[i], i});
    sort(all(even)); sort(all(odd));
    if(even[even.size()-1].second!=odd[odd.size()-1].second){
        cout<<n-even[even.size()-1].first-odd[odd.size()-1].first<<endl;
    }
    else{
        ll Maxim=0;
        if(even.size()>=2) Maxim=max(even[even.size()-2].first+odd[odd.size()-1].first, Maxim);
        if(odd.size()>=2) Maxim=max(even[even.size()-1].first+odd[odd.size()-2].first, Maxim);
        else if(even.size()==odd.size()) Maxim=n/2;
        cout<<n-Maxim<<endl;
    }
    return 0;
}


Measured memory_bytes: 5620
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, k, q = li()
a = [ni() for _ in range(q)]

point = [k-q]*n
for ai in a:
    point[ai-1] += 1

for pi in point:
    if pi > 0:
        print("Yes")
    else:
        print("No")

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

using namespace std;
using ll = long long;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);

    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int  t; cin >> t; t--;
            a[t]++;
        }
    }
    cout << count(a.begin(), a.end(), n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int h[100000];
int main(){
  int n, m;
  int a, b;
  int f[100000];
  int ans = 0;
  cin >> n >> m;
  for(int i = 0;i < n;i++){
    cin >> h[i];
    f[i] = 1;
  }
  for(int i = 0;i < m;i++){
    cin >> a >> b;
    if(h[a - 1] < h[b - 1]){
      f[a - 1] = 0;
    }else if(h[a - 1] > h[b - 1]){
      f[b - 1] = 0;
    }else{
      f[a - 1] = 0;
      f[b - 1] = 0;
    }
  }
  for(int i = 0;i < n;i++){
    if(f[i] == 1){
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  int ans=1001001;
  for(int i=0; i<n; ++i){
    int x, nans=0;
    cin >> x;
    while(x%2==0){
      x/=2;
      ++nans;
    }
    ans = min(ans, nans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class CFlipFlipAndFlip {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, M;
    cin >> N >> M;
    int temp1 = max(N, M);
    int temp2 = min(N, M);
    N         = temp1;
    M         = temp2;
    int ans   = 0;
    if (N == 1 and M == 1) {
      ans = 1;
    } else if (N == 2 and M == 1) {
      ans = 0;
    } else if (M == 1) {
      ans = N - 2;
    } else if (M == 2 and N == 2) {
      ans = 0;
    } else if (M == 2) {
      N *M - 4;
    } else {
      ans = (N - 2) * (M - 2);
    }
    cout << ans << endl;
  }
};


signed main() {
  CFlipFlipAndFlip solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ll long long int
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>vect;
using namespace std;
int main()
{
string s;
cin>>s;
ll flag=0,flag1=0;
for(ll i=0;i<s.length();i++)
{
	if(s[i]=='A')
	{
		flag=1;
	}
		if(s[i]=='B')
	{
		flag1=1;
	}

}
if(flag&&flag1)
cout<<"Yes";
else
cout<<"No";
return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for (int i = 0; i < N; i++){
    cin >> x.at(i);
    cin >> y.at(i);
  }
  int count = 1;
  for (int i = 1; i < N; i++){
    count *= i;
  }
  count *= 2;
  int A = 1;
  for (int i = 1; i <= N; i++){
    A *= i;
  }
  
  double ans = 0.0000000000;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      ans += sqrt((x.at(i) - x.at(j)) * (x.at(i) - x.at(j)) + (y.at(i) - y.at(j)) * (y.at(i) - y.at(j)));
    }
  }
  cout << fixed << setprecision(10);
  cout << count * ans / A << endl;
}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vector<LP> ab(n);
    cin>>ab;

    sort(rng(ab));
    ll ans = 0;
    rep(i, n) {
        if (m - ab[i].se < 0) {
            ans += ab[i].fi * m;
            break;
        }
        ans += ab[i].fi * ab[i].se;
        m -= ab[i].se;
    }
    cout<<ans<<endl;
}

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

template<class T> inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    int a, b;
    read(a), read(b);
    if (a > 9 || b > 9) {
        cout << -1 << endl;
    }
    else cout << a * b << endl;
    return 0;
}

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

int main(void){
    int N;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;

    scanf("%d", &N);
    std::string V[N];
    for (int i = 0; i < N; i++){
        std::cin >> V[i];
    }
    
    for (auto& v : V){
        if (v == "AC") AC++;
        else if (v == "WA") WA++;
        else if (v == "TLE") TLE++;
        else if (v == "RE") RE++;
    }

    std::cout << "AC x " << AC << std::endl;
    std::cout << "WA x " << WA << std::endl;
    std::cout << "TLE x " << TLE << std::endl;
    std::cout << "RE x " << RE << std::endl; 


}

Measured memory_bytes: 6748
// AOJ 2187: Card Game
// 2017.11.6 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define SUM 171		// =19*9
#define HALF 86		// =SUM/2+1
int g[10], j[10];
int f[10][SUM+1][1<<9], p[10];

int rec(int i, int sg, int combi)
{
	int k, r;

	if (i == 9) return sg >= HALF;
	if (f[i][sg][combi] >= 0) return f[i][sg][combi];
	if (sg >= HALF) return f[i][sg][combi] = p[9-i];
	
	r = 0;
	for (k = 0; k < 9; k++) {
		if (combi & (1<<k)) {
			if (g[i] > j[k]) r += rec(i+1, sg+g[i]+j[k], combi^(1<<k));
			else             r += rec(i+1, sg, combi^(1<<k));
		}
	}
	return f[i][sg][combi] = r;
}

int main()
{
	int t, i;
	double x;

#if TM
	clock_t start, end;
	start = clock();
#endif
	for (p[0] = 1, i = 1; i <= 9; i++) p[i] = i*p[i-1];

	scanf("%d", &t);
	while (t-- > 0) {
		for (i = 0; i < 9; i++) scanf("%d", g+i);
		for (i = 0; i < 9; i++) scanf("%d", j+i);
		memset(f, -1, sizeof(f));
		x = rec(0, 0, (1<<9)-1) * 1.0/p[9];
		printf("%.5lf %.5lf\n", x, 1-x);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 5156
import java.util.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        int K = sc.nextInt();
        long ans = 0;
        if(K==0){
            System.out.println(N * N);
            return;
        }

        for(int i=1; i<=N; i++){
            ans += N / i *Math.max(0, i - K);
            ans += Math.max(0, N % i - K + 1);
        }
        System.out.println(ans);
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int a_i = a[n-1];
  int res = a[0];
  for(int i = 0; i < n-1; i++){
    int tmp1 = min(a_i - res, res);
    int tmp2 = min(a_i - a[i], a[i]);
    if(tmp1 < tmp2){
      res = a[i];
    }
  }
  cout << a_i << " " << res << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  string  s; 
  cin>>s;
  if(s=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

bool solve(string S) {
  REP(i,S.length()) {
    if(i % 2 == 0) {
      if(! (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) return false;
    } else {
      if(! (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) return false;
    }
  }
  return true;
}

int main() {
  string S; cin>>S;
  YesNo(solve(S));
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val s1 = readLine
    val s2 = readLine
    if (s1(0) == s2(2) && s1(1) == s2(1) && s1(2) == s2(0)) {
      println("YES")
    }else{
      println("NO")
    }

  }


}


Measured memory_bytes: 25296
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  int a,b,k; cin >> a >> b >> k;
  set<int> se;
  // for(int i=a;i<a+k;i++) se.insert(i);
  for(int i=a;i<min(a+k,b+1);i++) se.insert(i);
  for(int i=max(a,b-k+1);i<=b;i++) se.insert(i);
  for(auto itr=se.begin();itr!=se.end();++itr){
    cout << *itr << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define y1 cgbngfgn
#define pb push_back
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fir first
#define m_p make_pair
#define sec second
#define files(name) freopen(name".in","r",stdin); freopen (name".out","w",stdout);
#define time pdojegoritg
#define left eorgjrptgj
#define right rtyjtokh
#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int arr=3e5+100;

bool use[4100000];

signed main()
{
    int n;
    cin>>n;
    vector<int> vec;
    vec.pb(0);
    for (int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        vector<int> vec2;
        for (auto j:vec)
        {
            if (!use[j+a])
            {
                use[j+a]=1;
                vec2.pb(j+a);
            }
        }
        for (auto i:vec2)
            vec.pb(i);
    }

    vec.clear();

    for (int i=0;i<4100000;i++)
        if (use[i])
        vec.pb(i);

    cout<<vec[(vec.size()-1)/2];
}
/*
*/


Measured memory_bytes: 22492
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,y,h,w,size,sum;
    sum=0;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>x>>y>>h;
                size=x+y+h;
                cin>>w;
                if (size<=60 && w<=2) {
                    sum=sum+600;
                } else if (size<=80 && w<=5) {
                    sum=sum+800;
                } else if (size<=100 && w<=10) {
                    sum=sum+1000;
                } else if (size<=120 && w<=15) {
                    sum=sum+1200;
                } else if (size<=140 && w<=20) {
                    sum=sum+1400;
                } else if (size<=160 && w<=25) {
                    sum=sum+1600;
                }
            }
            cout<<sum<<endl;
            sum=0;
        }
    }
}



Measured memory_bytes: 3084
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n - 1); i >= 0; --i)
#define D(n, retu)                                                             \
  REP(i, n) { cin >> retu[i]; }
#define mod 1000000007
#define INF 93193111451418101
#define MIN -933111451418101
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
#define yo 100001
//------------------変数-----------------------//
ll n, maxmove = 0, movesize;
string str;
//-------------------関数----------------------//
typedef pair<char, ll> strp;
int main() {
  cin >> str;
  strp outx[100001];
  ll hoge = 0;
  REP(i, str.size()) {
    if (str[i] != 'x') {
      outx[hoge] = strp(str[i], i);
      hoge++;
    }
  }
  REP(i, hoge) {
    if (outx[i].first != outx[hoge - i - 1].first) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll fir = outx[(hoge + 1) / 2].second, sec = outx[(hoge) / 2].second;
  vector<ll> iz;
  str += 'a';
  ll ryt = 0;
  REP(i, str.size()) {
    if (str[i] != 'x') {
      iz.push_back(ryt);
      ryt = 0;
    } else {
      ryt++;
    }
  }
  // cout << iz.size() << endl;
  ll cnt = 0;
  REP(i, iz.size() / 2) { cnt += abs(iz[i] - iz[iz.size() - 1 - i]); }
  cout << cnt << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

char white='.';
char black='#';

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  
  if(a==0 || b==0){
    cout<<1<<' '<<1<<endl;
    if(a==0) cout<<black<<endl;
    else cout<<white<<endl;
    return 0;
  }
  
  cout<<100<<' '<<100<<endl;
  char G[100][100];
  memset(G,white,sizeof(G));
  irep(i,50,100){
    rep(j,100){
      G[i][j]=black;
    }
  }
  
  ll row=51, col=0;
  rep(i,a-1){
    G[row][col]=white;
    col+=2;
    if(col>=100){
      col=0;
      row+=2;
    }
  }
  
  row=0, col=0;
  rep(i,b-1){
    G[row][col]=black;
    col+=2;
    if(col>=100){
      col=0;
      row+=2;
    }
  }
  
  rep(i,100){
    rep(j,100){
      cout<<G[i][j];
    }
    cout<<endl;
  }
  
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >>Y;

    int ans = 5000 * 2 * 1E+5;
    for (int c=0; c<=max(X, Y) * 2; c+=2) {
        int a = max(X - c / 2, 0);
        int b = max(Y - c / 2, 0);
        int cost = a * A + b * B + c * C;
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256