akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public class Plane
	{
		public long Time;
		public long X;
		public long Y;
	}

	public static class Question
	{
		public static void Exec()
		{
			long n = int.Parse(Console.ReadLine());
			List<Plane> list = new List<Plane>();
			var p = new Plane();
			p.Time = 0;
			p.X = 0;
			p.Y = 0;
			list.Add(p);

			for (var j = 0; j < n; ++j) {
				var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
				var plane = new Plane();
				plane.Time = array[0];
				plane.X = array[1];
				plane.Y = array[2];
				list.Add(plane);
			}

			string answer = "Yes";
			for (var j = 1; j <= n; ++j) {
				long time = list[j].Time - list[j - 1].Time;
				long x = Math.Abs(list[j].X - list[j - 1].X);
				long y = Math.Abs(list[j].Y - list[j - 1].Y);
				if (x + y > time) {
					answer = "No";
					break;
				}

				if ((x + y) % 2 != time % 2) {
					answer = "No";
					break;
				}
			}

			Console.WriteLine($"{answer}");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 22956
from collections import defaultdict

S = input()
T = input()

s_dic = defaultdict(lambda: -1)
t_dic = defaultdict(lambda: -1)

can_replace = True
for i in range(len(S)):
    s_char = S[i]
    t_char = T[i]

    if s_dic[s_char] != -1 or t_dic[t_char] != -1:
        if s_dic[s_char] != t_char and t_dic[t_char] != s_char:
            can_replace = False
            break
    else:
        s_dic[s_char] = t_char
        t_dic[t_char] = s_char

if can_replace:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4144
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n;
	cin >> n;
	vector<char>s(n);
	rep(i, n) {
		cin >> s[i];
	}
	int res = s.size();
	rep(i, n-1) {
		if (s[i] == s[i + 1])res--;
	}
	c(res);
	ed;
	return 0;
}



Measured memory_bytes: 384
import bisect

N=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N):
    a=L[i]
    for j in range(i+1, N):
        b=L[j]
        ans+=bisect.bisect_left(L, a+b)-(j+1)
print(ans)


Measured memory_bytes: 43628
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    cin >> a >> b;
    // スペース区切りの整数の入力
    int c,d;
    cin >> c >> d;
    // 文字列の入力
    //string s;
    //cin >> s;

    // 出力
    cout << (a-c) * (b-d) << endl;
    return 0;
}

Measured memory_bytes: 256
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=105;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int n,m,K,Mod;
int C[N][N],P[N][N],f[2][N][N];
int mod(int x){return x>=Mod?x-Mod:x;}
void Prepare(){
	for(int i=0;i<N;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=mod(C[i-1][j-1]+C[i-1][j]);}
	for(int i=0;i<N;i++){P[i][0]=1;for(int j=1;j<N;j++)P[i][j]=1ll*P[i][j-1]*i%Mod;}
}
void Clear(int t){for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)f[t][i][j]=0;}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();m=read();K=read();Mod=read();Prepare();
	int t=0;f[t][0][0]=1;
	for(int T=1;T<=K;T++){
		Clear(t^=1);
		for(int i=0;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(!f[t^1][i][j])continue;
				int tmp=f[t^1][i][j],mul=1ll*P[T][m-j]*P[K-T+1][j]%Mod;
				for(int a=0;i+a<=n;a++,tmp=1ll*tmp*mul%Mod){
					f[t][i+a][j]=mod(f[t][i+a][j]+1ll*C[n-i][a]*tmp%Mod);
				}
			}
		}
		Clear(t^=1);
		for(int i=0;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(!f[t^1][i][j])continue;
				int tmp=f[t^1][i][j],mul=1ll*P[T][n-i]*P[K-T+1][i]%Mod;
				for(int b=0;j+b<=m;b++,tmp=1ll*tmp*mul%Mod){
					f[t][i][j+b]=mod(f[t][i][j+b]+1ll*C[m-j][b]*tmp%Mod);
				}
			}
		}
		Clear(t^=1);
		for(int i=0;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(!f[t^1][i][j])continue;
				int tmp=f[t^1][i][j],mul=1ll*P[T][m-j]*(Mod-P[K-T][j])%Mod;
				for(int c=0;i+c<=n;c++,tmp=1ll*tmp*mul%Mod){
					f[t][i+c][j]=mod(f[t][i+c][j]+1ll*C[n-i][c]*tmp%Mod);
				}
			}
		}
		Clear(t^=1);
		for(int i=0;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(!f[t^1][i][j])continue;
				int tmp=f[t^1][i][j],mul=1ll*P[T][n-i]*(Mod-P[K-T][i])%Mod;
				for(int d=0;j+d<=m;d++,tmp=1ll*tmp*mul%Mod){
					f[t][i][j+d]=mod(f[t][i][j+d]+1ll*C[m-j][d]*tmp%Mod);
				}
			}
		}
	}
	printf("%d",f[t][n][m]);
	return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {

    char s1[12], s2[12], s3[12];

    scanf("%[^ ]%*c", s1);
    scanf("%[^ ]%*c", s2);
    scanf("%s", s3);

    printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));


    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
s = str(input())
k -= 1

if s[k] == 'A':
    print(str(s[0:k]) + 'a' + str(s[k+1:]))

elif s[k] == 'B':
    print(str(s[0:k]) + 'b' + str(s[k+1:]))

else:
    print(str(s[0:k]) + 'c' + str(s[k+1:]))

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

int main(){
	string st;
	int s1=0,s2=0,i;
	cin>>st;
	for(i=0;i<st.size();i++){
		if(st[i]=='C')s1=1;
		if(s1&&st[i]=='F')s2=1;
	}
	if(s1&&s2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#define MAX 10000
using namespace std;

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node* y = NIL; //xの親
    Node* x = root;
    Node* z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL){
        y = x; //親の設定
        if(z->key < x->key) x = x->left;//左の子へ移動
        else x = x->right;
    }
    z->parent = y;

    if( y == NIL) root = z;
    else if(z->key < y->key ) y->left = z; //z を y の左の子にする
    else y->right = z; //z を y の右の子にする
}

void preorder(Node* z){//先行順巡回
    printf(" %d", z->key);
    if(z->left != NIL) preorder(z->left);
    if(z->right != NIL) preorder(z->right);
}

void inorder(Node* z){
    if(z->left != NIL) inorder(z->left);
    printf(" %d", z->key);
    if(z->right != NIL) inorder(z->right);
}

void print(){
    Node* z = root;
    inorder(z);
    printf("\n");
    preorder(z);
    printf("\n");
}

Node* find(int k, Node *z){
    while( z != NIL && z->key != k){
        if( k < z->key) z = z->left;
        else z = z->right;
    }
    return z;
}

Node* getSuccessor(Node *z){
    if(z->right != NIL){
        z = z->right;
        while(z->left != NIL){
            z = z->left;
        }
    }
    return z;
}

void deleteNode(int k){
    Node* z = find(k, root);
    Node* p = z->parent;
    if(z->left == NIL && z->right == NIL){
        if(p->left == z)p->left = NIL;
        else p->right = NIL;
        free(z);
    }else if(z->left != NIL && z->right == NIL){
        if(p->left == z)p->left = z->left;
        else p->right = z->left;
        z->left->parent = p;
        free(z);
    }else if(z->left == NIL && z->right != NIL){
        if(p->right == z)p->right = z->right;
        else p->left = z->right;
        z->right->parent = p;
        free(z);
    }
    else{
        p = getSuccessor(z);
        z->key = p->key;
        if(p->right == NIL){
            if(z->right == p)p->parent->right = NIL;
            else p->parent->left = NIL;
            free(p);
        }else if(p->right != NIL){
            if(z->right == p)p->parent->right = p->right;
            else p->parent->left = p->right;
            p->right->parent = p->parent;
            free(p);
        }
    }
}

int main(){
    int n, k;
    string com;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &k);
            insert(k);
        }else if( com == "print"){
            print();
        }else if( com == "find"){
            scanf("%d", &k);
            if(find(k, root) != NIL) printf("yes\n");
            else printf("no\n");
        }else if( com == "delete"){
            scanf("%d", &k);
            deleteNode(k);
        }
    }

    return 0;
}


Measured memory_bytes: 21940
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
long long  mod = 1000000007;
vector<string> s;

long long C(int n, int r) {
	long long c = 1;
	int j = 1;
	for (int i = 0; i < r; i++) {
		c *= n - i;
		c /= j;
		j++;
	}
	return c;
}

int main()
{
	int N;
	cin >> N;
	string S;
	long long an = 0;
	for (int i = 0; i < N; i++) {
		cin >> S;
		sort(S.begin(), S.end());
		s.push_back(S);
	}
	sort(s.begin(), s.end());
	s.push_back(" ");
	int count = 1;
	for (int i = 0; i < N ; i++) {
		if (s[i] != s[i + 1]) {
			an += C(count, 2);
			count = 1;
		}
		else {
			count++;
		}
	}
	cout << an;
}

Measured memory_bytes: 5748
import sys

sys.setrecursionlimit(10 ** 9)

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))

d = [[-1 for _ in range(len(arr))] for _ in range(len(arr))]


def dp(l, r, idx):
    if idx == len(arr):
        return 0

    if d[l][r] != -1:
        return d[l][r]

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    d[l][r] = max(left, right)
    return max(left, right)


print(dp(0, len(arr) - 1, 0))


Measured memory_bytes: 174916
# https://atcoder.jp/contests/abc172/tasks/abc172_b


def compare(S, T):
    s = t = 0
    changes = 0

    while s < len(S):
        if S[s] != T[t]:
            changes += 1
        s += 1
        t += 1

    return changes


S = input()
T = input()
print(compare(S, T))



Measured memory_bytes: 9324
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a>0) cout << "Positive";
  else if(a<=0 && b>=0) cout << "Zero";
  else{
    -a;-b;
    if((a-b)%2==0) cout <<"Negative";
    else cout << "Positive";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B,maximum = INT32_MAX;
    cin >> N >> A >> B;
    maximum = N * A;
    maximum = min(maximum,B);
    cout <<maximum<< "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  int n,m,ans=0;
   scanf("%d%d",&n,&m);
   if(n<=0&&m>=0){puts("Zero");return 0;}
   for(int i=n;i<=m;i++)
       if(i<0)ans++;
   if(ans%2==1)puts("Negative");
   else puts("Positive");
   return 0;
}

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

int main() {

	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	int x3 = x2 - dy;
	int y3 = y2 + dx;
	int x4 = x3 - dx;
	int y4 = y3 - dy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 3588
if __name__ == "__main__":
	lis = []
	while True:
		a, b = map( int, input().split() )
		if a == b == 0:
			break
		lis.append([a,b])
	for i in lis:
		print('#'*i[1])
		for j in range(i[0]-2):
			print('#'+'.'*(i[1]-2)+'#')
		print('#'*i[1])
		print()

Measured memory_bytes: 7604
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in));       
        String line = r.readLine();       
        
        int cnt=0;

        String st[] = line.split(" ",0);
        int a = Integer.parseInt(st[0]);
        int b = Integer.parseInt(st[1]);
        int c = Integer.parseInt(st[2]);

        for(int i = a ; i <=b ; i++){
            if (c % i == 0) cnt++;
        }
        System.out.println(cnt);         
    }
}

Measured memory_bytes: 24396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {

    static int h, w;

    public static void main(String[] args) throws NumberFormatException, IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            while (true) {

                int[] arr = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

                h = arr[0];
                w = arr[1];

                if (h == 0 && w == 0) {
                    break;
                }

                System.out.println(getTopString(w, new StringBuilder()));//1行目
                IntStream.range(1, h - 1).forEach(i -> System.out.println(getLineString(w, new StringBuilder())));
                System.out.println(getTopString(w, new StringBuilder()));//最終行
                System.out.println();
            }
        }
    }

    public static String getLineString(int n, StringBuilder sb) {
        if(n == 1) {
            sb.append("#");
            return sb.toString();
        }else {
            if(sb.length() == 0) {
                sb.append("#");
            }else {
                sb.append(".");
            }
            return getLineString(n - 1, sb);
        }
    }

    public static String getTopString(int n, StringBuilder sb) {
        if(n == 0) {
            return sb.toString();
        }else {
            sb.append("#");
            return getTopString(n - 1, sb);
        }
    }
}



Measured memory_bytes: 31552
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,A; cin >> N >> A;
    if(N%500<=A) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
int main()
{
	long long n;
	int cnt=0;
	bool lag = true;
	scanf("%lld",&n);
	while(n && n>9)
	{
		if(n%10 != 9)
			lag = false;
		n /= 10;
		cnt++;
	}
	printf("%d",lag ? cnt*9+n : cnt*9+n-1);
	return 0;
 } 

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

int main()
{
int ans = 0;
char S[3], T[3];
cin >> S;
cin >> T;

for(int i=0; i<3; i++){
    if(S[i] == T[i]){
        ans++;
    }
}
cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll H, W, D; cin >> H >> W >> D;
  ll mx[H*W+1], my[H*W+1];
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      ll a; cin >> a; mx[a] = i; my[a] = j;
    }
  }
  ll mp[H*W+1];
  for (ll i = H*W; i >= 1; i--) {
    if (i+D > H*W) {mp[i] = 0;}
    else {
      mp[i] = mp[i+D] + abs(mx[i]-mx[i+D]) + abs(my[i]-my[i+D]);
    }
  }
  ll Q; cin >> Q;
  for (ll i = 0; i < Q; i++) {
    ll l, r; cin >> l >> r;
    cout << mp[l] - mp[r] << endl;
  }
}   

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

long long f(long long h){
  if(h==1){
    return 1;
  }else{
    return 2*f(h/2)+1;
  }
}

int main(){
  long long h;
  cin>>h;
  
  cout<<f(h)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >>s;
  for(int i=0;i<3;i++) cout <<s[i];
  cout <<'\n';
    return (0);
}


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

int main() {
	int m, f, r;
	while(1){
		cin >> m >> f >> r;
		if(m==-1 && f==-1 && r==-1) break;
		if(m==-1 || f==-1) cout << "F" << endl;
		else if(m+f>=80) cout << "A" << endl;
		else if(m+f>=65 && m+f<80) cout << "B" << endl;
		else if(m+f>=50 && m+f<65) cout << "C" << endl;
		else if(m+f>=30 && m+f<50 && r>=50) cout << "C" << endl;
		else if(m+f>=30 && m+f<50 && r<50) cout << "D" << endl;
		else if(m+f<30) cout << "F" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n;
	vector<int> h(8);
	cin >> n;
restart:
	for(int i=0;i<n;i++){
		for(int j=0;j<8;j++) { cin >> h[j]; }
		cout << h[0]*h[4]-h[1]*h[5]-h[2]*h[6]-h[3]*h[7] << " ";
		cout << h[0]*h[5]+h[1]*h[4]+h[2]*h[7]-h[3]*h[6] << " ";
		cout << h[0]*h[6]-h[1]*h[7]+h[2]*h[4]+h[3]*h[5] << " ";
		cout << h[0]*h[7]+h[1]*h[6]-h[2]*h[5]+h[3]*h[4] << endl;
		h.clear();
	}
	cin >> n;
	if(n!=0) goto restart;
	return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <cmath>
using namespace std;
typedef unsigned long long ull;
static const int M = 1000000007;

ull power(int x, int n) {
    ull res = 1;
    if ( n > 0) {
        res = power(x, n/2);
        if (!(n & 1)) res = (res * res) % M;
        else res = (((res*res) % M) * x) % M;
    }
    return res;
}

int main()
{
    int m, n;
    scanf("%d %d", &m, &n);
    printf("%llu\n", power(m, n));
    return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    ll now = 1;
    ll tot = 0;
    cin >> n;
    while(n >= 1) {
        tot += now;
        now <<= 1;
        n /= 2;
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 256
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod 1e9+7
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define mp make_pair

int main()
{
    ll a,b;
    in2(a,b);
    ll n = __gcd(a,b);
    set<ll> s;
    s.insert(1);
    for(ll i=2;i*i<=n;i++) {
        while(n%i==0) {
            s.insert(i);
            n/=i;
        }
    }
    s.insert(n);
    cout<<s.size()<<endl;    
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int result = 0 ;

    for(int i = 0  ;i < S.length() ; i ++){
      if( S.charAt(i) == '1' ){
        result ++ ;
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 24020
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            var hash = new HashSet<long>();
            long before = 1;
            long pool = 1;
            var list = PrimeFactors(N).ToList().OrderByDescending(elem => elem);
            foreach (var prime in list)
            {
                if (before != prime)
                {
                    pool = 1;
                }

                before = prime;
                pool *= prime;
                if (!hash.Contains(pool))
                {
                    hash.Add(pool);
                    pool = 1;
                }
            }

            Console.WriteLine(hash.Count());
        }

        public static IEnumerable<long> PrimeFactors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
    }
}


Measured memory_bytes: 28388
// All Heil Fire Lord Zuko

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

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

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

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
 
const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
int h, w, k;
string grid[M];
int dir[] = {-1,1,0,0};
int dic[] = {0,0,-1,1};
int dis[M], directions[M];
 
bool valid(int r, int c)
{
    return r >= 0 && r < h && c >= 0 && c < w && grid[r][c] != '@';
}
 
 
int main()
{
    int x1, x2, y1, y2;
    scanf("%d %d %d ", &h, &w, &k);
    scanf("%d %d %d %d ", &x1, &y1, &x2, &y2);
 
    for(int i = 0 ; i< h ;i++)
    {
        string s;
        getline(cin, s);
        grid[i] = s;
    }
    x1--; y1--; x2--; y2--;
    memset(dis, -1, sizeof dis);
    dis[x1*w + y1] = 0;
    directions[x1*w+y1] = 15;
    queue<pair<int, int> > q;
    q.push({x1, y1});
    while(!q.empty())
    {
        int ur = q.front().first, uc = q.front().second;
        // cout<<ur<<" "<<uc<<endl;
        q.pop();
        if(ur == x2 && uc == y2)
            break;
        for(int i = 0 ; i< 4 ; i++)
        {
            int steps = 1, vr, vc;
            while(steps <=k)
            {
                vr = ur + (dir[i] * steps);
                vc = uc + (dic[i] * steps);
                if(valid(vr, vc))
                {
                    if(!((directions[vr*w+vc]>>i) & 1))
                    {
                        if(!directions[vr*w+vc])
                        {
                            dis[vr*w+vc] = dis[ur*w+uc] + 1;
                            q.push({vr, vc});
                        }
                        directions[vr*w+vc] |= (1 << i);
                    }
                    else if(dis[vr*w + vc] ==dis[ur*w+uc] + 1 )
                    {
                        steps++;
                        continue;
                    }
                    else
                        break;
                    
                }
                else
                    break;
                steps++;
            }
        }
    }
    printf("%d", dis[x2*w+y2]);
    return 0;
}

Measured memory_bytes: 43284
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    bool used[26];
    fill(used, used + 26, false);
    string s;
    cin >> s;
    rep(i, s.size())
    {
        used[s[i] - 'a'] = true;
    }

    rep(i, 26)
    {
        if (!used[i])
        {
            printf("%c\n", i + 'a');
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
$stdin.each {|x|
  a = x.split(",").map(&:to_i)
  v2, v1 = a.pop, a.pop
  total = a.inject(:+)
  at = 1.0 * total * v1 / (v1 + v2)
  a.each_with_index{|l,i|
    at -= a[i]
    if at <= 0
      p i+1
      break
    end
  }
}

Measured memory_bytes: 6116
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = b-a;
		int e = c-b;
		System.out.println(d == e ? "YES":"NO");
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, ll> m;
    REP(i, N) {
        string s;
        cin >> s;
        SORT(s);
        m[s]++;
    }
    ll res = 0;
    for (auto x : m) {
        res += x.second * (x.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}


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

#define N 100004

using namespace std;

int main(void){
  bool isprime[N] = {0, 0, };
  for(int i = 2; i < N; i++) isprime[i] = true;
  for(int p = 2; p <= N; p++){
    if(!isprime[p]) continue;
    for(int q = 2; p * q <= N; q++) isprime[p * q] = false;
  }
  int X;
  cin >> X;
  while(!isprime[X]) X++;
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

long long gcd(long long x, long long y){
    if (y>x){
       swap(x,y); 
    }
    while (y!=0){
        long long r=x%y;
        x=y;
        y=r;
    }
    return x;
}

bool sosu(long long x){ //trueなら素数
    bool ans=true;
    long long y=pow(x, 0.5);
    for (int i=2; i<=y; i++){
        if (x%i==0 && x/i!=1){
            ans=false;
        }
    }
    return ans;
}

int main(){
    long long x,y;
    cin>>x>>y;
    long long p=gcd(x,y);
    long long a=1;
    vector<long long> data;
    data.push_back(0); //これを入れないと最初のdata.back()ができない
    long long count=0; //最初に1をカウントしておく
    while (p>=a*a){
        long long b=p;
        if (b%a==0){ 
            if (sosu(a)) count++;
            if (sosu(b/a)){
                if (a!=b/a) count++;
            }
        }
        a++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Set<String> hash = new HashSet<>();
        for (int i = 0; i < k; i++) {
            int d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                hash.add(sc.next());
            }

        }

        System.out.println(n - hash.size());
    }
}



Measured memory_bytes: 41676
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  long int N, A, B, Answer = 0;
  cin >> N;
  for (long int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      A = i;
    }
  }
  B = N / A;
  do {
    B /= 10;
    Answer++;
  } while (B != 0);
  cout << Answer << endl;
  return 0;
}

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

typedef long long ll;
char s[104];
const int mod = 998244353;
map<ll, int> f[52];
int n, g[104];
int calc(ll d, int m) {
  if (!m) return 1;
  if (f[m].find(d) != f[m].end()) return f[m][d];
  int ret = ((d & 1) + 1) * calc(d >> 1, m - 1) % mod;
  for (int j = 1; j <= m; j++) {
    for (int k = 2; k * j <= m; k++) {
      ll d2 = (1LL << j) - 1, d3 = d;
      for (int s = 1; s <= k; s++) {
        d2 &= d3;
        d3 >>= j;
      }
      ret = (ret + (ll) calc(d2, j) * calc(d3, m - k * j)) % mod;
    }
  }
  return f[m][d] = ret;
}

int main() {
  scanf("%s", s);
  n = (int) strlen(s);
  for (int i = 0; i < n; i++) {
    s[i] = s[i] - '0';
  }
  g[n] = 1;
  for (int i = n - 1; ~i; i--) {
    g[i] = (s[i] + 1) * g[i + 1] % mod;
    for (int j = 1; j <= n - i; j++) {
      for (int k = 2; k * j <= n - i; k++) {
        ll d = (1LL << j) - 1;
        for (int u = 0; u < k * j; u++) {
          d &= ~((ll) !s[i + u] << (u % j));
        }
        g[i] = (g[i] + (ll) calc(d, j) * g[i + k * j]) % mod;
      }
    }
  }
  printf("%d\n", g[0]);
}


Measured memory_bytes: 3072
def resolve():
    import sys
    from collections import Counter
    n = int(input())
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    ans = []
    for i in range(len(d)):
        if d[i][1] != e:
            break
        else:
            ans.append(d[i][0])
    for j in sorted(ans):
        print(j)
resolve()

Measured memory_bytes: 113236
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a  = sc.nextInt();
        int b  = sc.nextInt();
        int c  = sc.nextInt();
        int d  = sc.nextInt();

        if(Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)){
            System.out.println("Yes");

        }else{
            System.out.println("No");
        }
    }

}

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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    rep(i, n/4+1) {
        rep(j, n/7+1) {
            if (i*4 + j*7 == n) ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())


def main():
    t0, x0, y0 = 0, 0, 0
    for i in range(n):
        t1, x1, y1 = map(int, input().split())
        l = abs(x1 - x0) + abs(y1 - y0)
        t = t1 - t0
        if l - t > 0 or (t - l) % 2 != 0:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


main()


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([]int, n)

	ans := 1
	for i := range arr {
		num := scanInt()
		if num == 0 {
			ans = 0
		}
		arr[i] = num
	}

	if ans != 0 {
		for _, e := range arr {
			if ans > 1e18/e {
				ans = -1
				break
			}

			ans *= e
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5868
//Author:: Pham Ngoc Minh- Chuyen Thai Binh
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int const maxn=205;
int n,l;
int tao[maxn];
int sum=0;
int toti=int(1e8);
int kq;
int main()
{
    cin>>n>>l;
    for(int i=1;i<=n;i++){
        tao[i]=l+i-1;
        sum+=tao[i];
    }
    for(int i=1;i<=n;i++){
        int res=sum;
        res=res-tao[i];
        int chechlech=abs(sum-res);
        if(toti>chechlech){
            toti=chechlech;
            kq=res;
        }
    }
    cout<<kq;
    return 0;
}
// I love Chuyen Thai Binh Verry much ! Now, you alaways in my code of me <3
// Chuyen Thai Binh La Nha :>>


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

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	
	int n; 
	long long a[100005];
	long long b[100005];
	
	cin>>n;
	for (int i=1;i<=n+1;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	long long count=0;
	for (int i=1;i<=n;i++){
		
		if (b[i]>=a[i]){
			count+=a[i];
			b[i]-=a[i];
			if (b[i]>=a[i+1]){
				count+=a[i+1];	
				b[i]-=a[i+1];
				a[i+1]=0;
			}
			else{
				count+=b[i];
				a[i+1]-=b[i];
			}
		}
		else{
			count+=b[i];
			a[i]=0;
		}
	}
	
	cout<<count;
}

Measured memory_bytes: 1920
import sys
input = sys.stdin.readline

n, c, k = map(int, input().split())
T = [int(input()) for t in range(n)]
T.sort()
bus_count = 0
vacant_seat = 0
limit = 0

for t in T:
    if t > limit or vacant_seat == 0:
        bus_count += 1
        vacant_seat = c-1
        limit = t + k

    else:
        vacant_seat -= 1

print(bus_count)


Measured memory_bytes: 7384
/*
 *  if you can't see the replay
 *  Why not just work step by step
 *  rubbish is  relaxed
 *  to WzW
 */
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#include<ctype.h>
#define ll long long
#define memset(a,n) memset(a,n,sizeof(a))
using namespace std;
const int maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
void prework()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}
ll ksm(ll a,ll b)
{
    ll ans = 1;
    while(b){
        if(b & 1){
            ans *= a;ans %= mod;
        }
        b /= 2;a *= a; a %= mod;
    }
    return ans;
}




int main()
{
    prework();
    ll n,a,b;cin >> n >> a >> b;ll x = a + b;
    ll ans = 0;ll cur = n / x ;
    cur *= a;ans += cur;
    ans += n % x >= a ? a : n % x;
    cout << ans << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import combinations_with_replacement as comb
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(comb(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)

Measured memory_bytes: 25308
N,M=map(int,input().split())
H=list(map(int,input().split()))
X=[1]*N
for i in range(M):
  x,y=map(int,input().split())
  if H[x-1]>H[y-1]:
    X[y-1]=0
  elif H[x-1]<H[y-1]:
    X[x-1]=0
  else:
    X[x-1]=0
    X[y-1]=0
print(sum(X))

Measured memory_bytes: 20148
#include <iostream>
#include <map>

int main() {
  int n;
  std::cin >> n;
  std::map<int, int> numbers;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    if (++numbers[a] == 2) {
      std::cout << "NO" << std::endl;
      return 0;
    }
  }
  std::cout << "YES" << std::endl;
  return 0;
}


Measured memory_bytes: 9600
import itertools
n=int(input())
ap=0
aq=0
p=list(map(int,input().split()))
q=list(map(int,input().split()))
list1=list(itertools.permutations(list(range(1,n+1))))
list1.sort()
for i,w in enumerate(list1):
    v=list(w)
    if p==v:
        ap=i+1
    if q==v:
        aq=i+1
print(abs(ap-aq))

Measured memory_bytes: 45808
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
def comb(n):
    if n==1:
        return 0
    else:
        return n*(n-1)/2
list=Counter(A)
sum=0
for number in list:
    sum=sum+comb(list[number])

for i in A:
    print(int(sum-comb(list[i])+comb(list[i]-1)))



Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ct_r = 0, ct_l = 0;
    rep(i,n) {
        if (s[i] == '(') ct_r++;
        else ct_r--;
        if (ct_r < 0) {ct_l++; ct_r = 0;}
    }
    string s_l(ct_l,'(');
    string s_r(ct_r,')');
    cout << s_l << s << s_r << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

def sub(a,b,c,d):
    x1 = a - max(0, (a - (c+1))//b) * b
    if d<b:
        ans = "No"
    elif a<b:
        ans = "No"
    elif d%b==0:
        if x1>=b:
            ans = "Yes"
        else:
            ans = "No"
    else:
        k = gcd(d,b)
        x2 = x1 - (x1 - (c+1))//k * k
        if x2>=b:
            ans = "Yes"
        else:
            ans = "No"
    return ans

t = int(input())
ans = []
for i in range(t):
    a,b,c,d = map(int, input().split())
    ans.append(sub(a,b,c,d))
write("\n".join(ans))

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

int main() {
	string s;
	cin >> s;
	string ans = (s=="ABC") ? "ARC" : "ABC";
	
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int K;
	vector<int> ans;

	cin >> K;

	rep(i,K) {
		int cur = 0;
		rep(j,ans.size()+1){
			if(ans.size() <= cur) {
				ans.push_back(1);
				break;
			} else if(ans.size() == cur + 1) {
				if(ans[cur] < 9){
					ans[cur]++;
					break;
				}
			} else {
				if(ans[cur] < min(9, ans[cur+1] + 1)){
					ans[cur]++;
					break;
				}
			}
			cur++;
		}
		rrep(j,cur) {
			ans[j] = max(0, ans[j+1] - 1);
		}
	}

	rrep(i,ans.size()) cout << ans[i]; cout << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(N)]

ab.sort(key=lambda x:x[1])
cd.sort()
c = 0
for i in range(N):
    k = -1
    for j in range(len(ab)):
        if cd[i][0] > ab[j][0] and cd[i][1] > ab[j][1]:
            k = j
    if k != -1:
        c += 1
        ab = ab[:k] + ab[k + 1:]

print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n;
  cin >> n;
  int m;
  cin >> m;
  ll sum=0;
  int a[n];
  for(int i=0;i<n;i++){cin >> a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=0;i<m;i++){
    if(a[i]*4*m<sum){cout << "No" << endl;
    return 0;}
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d\n",&n);
    int arr[n],a[n];
    rep(i,0,n){
        char ch;
        scanf("%c",&ch);
        arr[i] = ch=='W';
        a[i] = arr[i];
    }
    int c=0;
    sort(a,a+n);
    rep(i,0,n)
        if (a[i]!=arr[i])
            c++;
    cout << c/2;

}


Measured memory_bytes: 5264
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int inf=1e9+7;
const int mod=1e9+7;

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int a,b;
	
	cin>>a>>b;
	
	if(a>=1&&a<=9&&b>=1&&b<=9)
		cout<<a*b<<endl;
	else
		cout<<-1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int a[10];
bool J;

void dfs(int n,int left,int right){
	if(n==10)
		J=true;
    if(a[n]>left)
			dfs(n+1,a[n],right);
    if(a[n]>right)
			dfs(n+1,left,a[n]);
}

int main(){
	int N;
	std::cin>>N;
	for(int i=0;i<N;++i){
		for(int i=0;i<10;++i){
			std::cin>>a[i];
		}
		J=false;
		dfs(0,0,0);
		if(J==true)
			std::cout<<"YES"<<std::endl;
		else std::cout<<"NO"<<std::endl;
	}
	return 0;
}

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

using namespace std;

#define INF 99999999

int N,W;
vector < pair <int,int> > item;
long long int memo[105][100005];

long long int solve(int idx,int w)
{
	if(idx == N || w == 0)
        return 0;

    if(memo[idx][w] != -1){
        return memo[idx][w];
    }

    int peso = item[idx].first;
    int valor = item[idx].second;

    if(peso > w) //não posso pegar o item
        return memo[idx][w] = solve(idx+1,w); 
    else{
       long long int a = valor + solve(idx+1,w - peso); //pego o item
       long long int b = solve(idx+1,w); //não pego o item

        return memo[idx][w] = max(a,b);
    }
}

int main()
{

		scanf("%d %d",&N,&W);

		for(int i=0;i<=N;i++)
			for(int j=0;j<=W;j++)
				memo[i][j] = -1;

		for(int i=0;i<N;i++){
            int v,w;
			scanf("%d %d",&w,&v);
			item.push_back({w,v});
        }
       
		printf("%lld\n",solve(0,W));
	
	return 0;
} 

Measured memory_bytes: 80128
import java.io.*;

public class Main {
	public static void main(String args[]) throws IOException{
		String str,dataSet[];
		int i,j,total,count = 1;
		BufferedReader input =
				new BufferedReader(new InputStreamReader(System.in));
		while((str = input.readLine()) != null){
			dataSet = str.split(" ");
			i = Integer.parseInt(dataSet[0]);
			j = Integer.parseInt(dataSet[1]);
			total = i+j;
			while((total /= 10) >= 1){
				count++;
				//System.out.println("total = " + total);
			}
			System.out.println(count);
			count = 1;
		}
	}
}

Measured memory_bytes: 16996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
vector<vector<int>> G;
int n;
ll dp_black[110000];
ll dp_white[110000];
bool done[110000];

void dfs(int now, int prev) {
    if (done[now]) return;
    done[now] = true;
    dp_black[now] = 1;
    dp_white[now] = 1;
    for (auto next: G[now]) {
        if (next == prev) continue;
        dfs(next, now);
        dp_white[now] *= dp_black[next] + dp_white[next];
        dp_white[now] %= MOD;
        dp_black[now] *= dp_white[next];
        dp_black[now] %= MOD;
    }
    return;
}
int main() {
    cin >> n;
    G.assign(n, vector<int>());
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1);
    cout << (dp_black[0] + dp_white[0]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 17236
main = readLn >>=
  \n -> fmap (map read . words) getLine >>=
  \as -> let xs = filter even as;
             ys = filter (\x -> x `mod` 4 /= 0) xs
             zs = filter (\x -> x `mod` 4 == 0) xs
         in if floor (n / 2) - (length zs) <= 0
            then putStrLn "Yes"
            else if n - fromIntegral (2*(length zs)) - fromIntegral (length ys) <= 0
                 then putStrLn "Yes"
                 else putStrLn "No"

Measured memory_bytes: 33148