akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  int A,B;
  cin>>A>>B;
  int C,D,E;
  C=A+B;
  D=A-B;
  E=A*B;
  int F;
  F=max(C,D);
  int ans;
  ans=max(E,F);
  cout<<ans<<endl;
}

        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, m;
  cin >> n >> m;

  vector<ll> a(m), b(m);
  vector<vector<ll>> adj(n);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;

    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);
  }

  queue<ll> q;
  q.push(0);

  int d[n];
  for (int i = 0; i < n; i++) {
    d[i] = INF;
  }

  d[0] = 0;

  vector<ll> ansv(n);
  while (!q.empty()) {
    ll v = q.front();
    q.pop();

    for (int i = 0; i < adj[v].size(); i++) {
      if (d[adj[v][i]] > d[v] + 1) {
        d[adj[v][i]] = d[v] + 1;
        ansv[adj[v][i]] = v;
        q.push(adj[v][i]);
      }
    }
  }

  string ans = "Yes";
  for (int i = 0; i < n; i++) {
    if (d[i] == INF) {
      ans = "No";
      break;
    }
  }

  cout << ans << ln;

  if (ans == "Yes") {
    for (int i = 1; i < n; i++) {
      cout << ansv[i] + 1 << ln;
    }
  }

  return 0;
}

Measured memory_bytes: 16448
import java.util.Scanner;

class Main {
    
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n, x, i, j, k, cnt;
    	
    	while(true) {
    		cnt = 0;
    		n = sc.nextInt();
    		x = sc.nextInt();
    		
    		if(n == 0 && x == 0) break;
    		
    		for(i = 1; i <= n; i++) {
    			for(j =i; j <= n; j++) {
    				for(k = j; k <= n; k++) {
    					if(i != k && k != j && i != j && i + j + k == x) {
    						cnt++;
    					}
    				}
    			}
    		}
    		
    		System.out.println(cnt);
    		
    	}
    }
}


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

using namespace std;

int main()
{
    long long int i;

    char s[10];

    char t[10];

    for(i = 0;i < 3;i++)
    {

        cin >> s[i];

    }
    for(i = 0;i < 3;i++)
    {

        cin >> t[i];

    }
    int count1 = 0;
     for(i = 0;i < 3;i++)
    {

        if(s[i] == t[i])
        {

            count1++;
        }

    }
    cout << count1;
}




Measured memory_bytes: 256
def contains(ring, p)
  length = ring.length
  p_length = p.length
  ring_array = substrings(ring, p_length)
  for i in 0..length-1
    if ring_array[i] == p
      return true
    end
  end
end

def substrings(ring, len)
  array_size = ring.length
  ring = ring + ring
  output = []
  for i in 0..(array_size-1)
    substring = ring[i..i+len-1]
    output.push(substring)
  end
  return output
end

ring = gets.chomp
p = gets.chomp
if contains(ring, p) == true
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8628
s = list(input())
count1 = 0
count2 = 0

if s[0] == '0':
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == '0':
                continue
            else:
                count1 +=1
        else:
            if s[i] == '1':
                continue
            else:
                count1 += 1
            
else:
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == '1':
                continue
            else:
                count2 += 1
        else:
            if s[i] == '0':
                continue
            else:
                count2 += 1
            
print(max(count1,count2))
        

Measured memory_bytes: 3956
import math

def is_prime(num):
	if num <= 1: return False
	if num == 2: return True
	if num % 2 == 0: return False
	i = 3
	while i <= num**0.5:
		if num % i == 0: return False
		i += 2
	return True

n = int(input())
count = 0
for i in range(n):
	m = int(input())
	if is_prime(m):
		count += 1
print(count)



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

static string PLUS = "+";
static string MINUS = "-";
static string MULTIPLY = "*";

int top = 0;
int S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    return S[top--];
}

int main () {
    string s;
    while (cin >> s) {
        if (s == PLUS) {
            int a = pop();
            int b = pop();
            push(a + b);
        } else if (s == MINUS) {
            int a = pop();
            int b = pop();
            push(b - a);
        } else if (s == MULTIPLY) {
            int a = pop();
            int b = pop();
            push(a * b);
        } else {
            push(atoi(s.c_str()));
        }
    }
    cout << pop() << endl;

    return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

int n, m, ans;

class Dsu{
public:
	int fa[maxn];
	inline void init(){ FOR(i, 0, n) fa[i] = i; return; }
	inline int find(int x){ return (x == fa[x]) ? x : (fa[x] = find(fa[x])); }
	inline void combine(int x, int y){
		x = find(x); y = find(y);
		fa[x] = y;
		return;
	}
}dsu;

int main(){
	scanf("%d%d", &n, &m);
	dsu.init();
	FOR(i, 0, m){
		int u, v; scanf("%d%d", &u, &v); --u; --v;
		dsu.combine(u, v);
	}
	FOR(i, 0, n)
		ans += (dsu.find(i) == i);
	printf("%d\n", max(0, ans - 1));
	return 0;
}


Measured memory_bytes: 4120
AB = list(map(int, input().split()))
AB.sort()
i = 2 
j = 1 
while 1:
        if AB[0] * i == AB[1] * j:
                print(AB[0] * i)
                break
        if AB[0] * i > AB[1] * j:
                j += 1
        else:
                i += 1

Measured memory_bytes: 3060
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;

	cin >> s;

	if (s == "ARC") {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
# n=14
# this solution can exactly hit m=60

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

li=[1]
back=[0]
edges=[]

for i in range(2,14):
    b=3
    edges.append((15-i,16-i,0))
    edges.append((15-i,16-i,li[-1]))
    edges.append((15-i,16-i,li[-1]*2))
    li.append(li[-1]*b)
    back.append(b)
    #print(li[-1],back[-1])
#print(sum(back))

# 36 edges so far
# do the last edge
l=int(input())
s=0
for i in range(13)[::-1]:
    while s+li[i]<=l:
        edges.append((1,14-i,s))
        s+=li[i]

edges.sort()
print(14,len(edges))
for e in edges: print("%d %d %d"%e)

Measured memory_bytes: 38544
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int h,w,d[20][20],r[20][20],vx[4]={0,1,0,-1},vy[4]={1,0,-1,0},ans=0,z=0;
char maze[20][20];
int bfs(int s,int t){
    if(maze[s][t]=='#') return 0;
    rep(i,h)rep(j,w) d[i][j]=0,r[i][j]=0;
    queue<P> que;
    que.push(P(s,t));
    r[s][t]=1;
    while (!que.empty()) {
        P v=que.front();
        que.pop();
        rep(i,4){
            int x=v.first+vx[i],y=v.second+vy[i];
            if(maze[x][y]=='#'||r[x][y]||x<0||x>=h||y<0||y>=w) continue;
            r[x][y]++;
            d[x][y]=d[v.first][v.second]+1;
            que.push(P(x,y));
        }
    }
    rep(i,h)rep(j,w) ans=max(ans,d[i][j]);
}
int main(){
    cin>>h>>w;
    rep(i,h)rep(j,w) cin>>maze[i][j];
    rep(i,h)rep(j,w) bfs(i,j);
    cout<<ans;
}

Measured memory_bytes: 256
class Dice:
	
	def __init__(self, faces):
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def set_top(self, face):
		if self.t == face:
			return
		elif self.s == face:
			self.roll('N')
		elif self.e == face:
			self.roll('W')
		elif self.w == face:
			self.roll('E')
		elif self.n == face:
			self.roll('S')
		else:
			self.roll('N')
			self.roll('N')
			
	def get_right_face(self, f):
		if self.s == f:
			return self.e
		elif self.e == f:
			return self.n
		elif self.w == f:
			return self.s
		else:
			return self.w
	
faces = list(map(int, input().split()))
dice = Dice(faces)

n = int(input())
for i in range(n):
	t, f = map(int, input().split())
	dice.set_top(t)
	print(dice.get_right_face(f))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<vector<double>> P(n);
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        P[i] = {atan2(x, y), x, y};
    }
    sort(all(P));
    double ans = 0;
    rep(s, n){
        double x = 0, y = 0;
        rep(idx, n) {
            int i = (s + idx) % n;
            x += P[i][1];
            y += P[i][2];
            chmax(ans, hypot(x, y));
        }
    }
    cout << fixed << setprecision(12) << ans << endl;
    return;
}

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


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

using namespace std;

int n, k;
int buckit[200001];

int main() {
    cin >> n >> k;
    int t;
    
    for (auto i = 0; i < n; i++) {
        cin >> t;
        buckit[t]++;
    }
    
    sort(buckit, buckit + n + 1, greater<int>());
    
    int ans = 0;
    for (auto i = k; i < n; i++) {
        ans += buckit[i];
        if (!buckit[i])
            break;
    }

    if (ans > 0)
        cout << ans << endl;
    else
        cout << 0 << endl;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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




int main(void) {
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K;
    cin >> N >> K;
    Vec<i64> A(N);
    for (i32 i = 0; i < K; i++) {
        cin >> A[i];
    }
    for (i32 i = K; i < N; i++) {
        cin >> A[i];
        cout << YN("Yes", "No", A[i] > A[i - K]) << endl;
    }

}


Measured memory_bytes: 4776
#include<cstdio>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int prime[300000];
int main() {
	int n;
	while(cin >> n,n) {
		int ans = 0;
		vector<int> data;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			data.push_back(t);
			ans += t;
		}
		sort(data.begin(), data.end());
		ans = ans - data[data.size()-1] - data[0];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};


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


Measured memory_bytes: 1024
# for num in range(1, 200+1):
#     divisor_array = []
#     for i in range(1, num+1):
#         if num % i == 0:
#             divisor_array.append(i)
#     else:
#         if len(divisor_array) == 8 and num % 2 == 1:
#                 print(num)
# ----result----
# 105
# 135
# 165
# 189
# 195
# --------------

N = int(input())
if N >= 195:
    print('5')
elif N >= 189:
    print('4')
elif N >= 165:
    print('3')
elif N >= 135:
    print('2')
elif N >= 105:
    print('1')
else:
    print('0')

Measured memory_bytes: 2940
#include <stdio.h>
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[25], V[25], W[25];

void Preorder(int);
void Inorder(int);
void Postorder(int);

int main()
{
  int n, i, j, id, left, right, root;


  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    T[i].parent = NIL;
  }

  for( i=0 ; i<n ; i++ ){
    scanf("%d %d %d",&id,&left,&right);
    T[id].left = left;
    T[id].right = right;
    if(left!=NIL)
      T[left].parent = id;
    if(right!=NIL)
      T[right].parent = id;
  }

  for( i=0 ; i<n ; i++ ){
    V[i] = T[i];
    W[i] = T[i];
    if(T[i].parent==NIL) 
      root = i;
  }

  

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

void Preorder(int u)
{
  if(u==NIL) return;
  printf(" %d",u);
  Preorder(T[u].left);
  Preorder(T[u].right);
}

void Inorder(int u)
{
  if(u==NIL) return;
  Inorder(V[u].left);
  printf(" %d",u);
  Inorder(V[u].right);
}

void Postorder(int u)
{
  if(u==NIL) return;
  Postorder(W[u].left);
  Postorder(W[u].right);
  printf(" %d",u);
}

Measured memory_bytes: 616
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    bool f = false;
    REP(i, N) {
        if (S[i][0] == 'Y') {
            f = true;
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;

    return 0;
}

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

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

  vector<int64_t> Lucas(N + 1);
  Lucas.at(0) = 2;
  Lucas.at(1) = 1;

  for (int i = 2; i <= N; i++)
  {
    Lucas.at(i) = Lucas.at(i - 1) + Lucas.at(i - 2);
  }

  cout << Lucas.at(N) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
    string s, t; cin >> s >> t;
    if(s[0]==t[2] and s[1]==t[1] and s[2]==t[0]) cout << "YES" << ln;
    else cout << "NO" << ln;
}

Measured memory_bytes: 256
s = input()
q = int(input())

for i in range(q):
    instruction = list(input().split())
    i_name = instruction[0]
    a, b = int(instruction[1]), int(instruction[2])

    if i_name == 'print':
        print(s[a:b+1])
    elif i_name == 'reverse':
        s = s[:a] + ''.join(list(reversed(s[a:b+1]))) + s[b+1:]
    elif i_name == 'replace':
        p = instruction[3]
        s = s[:a] + p + s[b+1:]



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


int main(){
    ll N,H;cin >> N >> H;
    vector<ll> A(N),B(N);
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    ll No = A[N-1];
    ll S = 0;
    stack<ll> st;
    for(int i = 0;i < N;i++){
        if(B[i] >= No){
            S += B[i];
            st.push(B[i]);
        }
    }
    ll ans = 0;
    bool frag = 0;
    while(H > 0){
        if(H <= S){
            frag = 1;
        }
        if(frag){
            H -= st.top();
            st.pop();
            ans++;
        }else{
            //ll a = 0;
            //ans += (H-S)/No;
            //H -= No * (H-S)/No;
            H -= No;
            ans++;
        }
        if(H <= 0){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
const int maxn = 1e3 + 10;

struct node
{
	int x, y;
}q[maxn];
int n;
int b[40];
char ANS[40];
int main()
{
	scanf("%d", &n);
	int c = 0;
	for(int i = 1; i <= n; i ++)
	{
		scanf("%d %d", &q[i].x, &q[i].y);
		if((q[i].x + q[i].y) % 2 == 0)
			c --;
		else
			c ++;
	}
	if(abs(c) != n)
	{
		cout << -1;
		return 0;
	}
	int cnt = 31;
	if(c < 0)
		b[32] = 1, cnt ++;
	b[1] = 1;
	for(int i = 2, temp = 1; i <= 31; i ++)
	{
		temp *= 2;
		b[i] = temp;
	}
	cout << cnt << endl;
	for(int i = 1; i <= cnt; i ++)
		cout << b[i] << " ";
	cout << endl;
	for(int i = 1; i <= n; i ++)
	{
		if(c < 0)
			ANS[cnt] = 'R', q[i].x --;
		for(int j = 31; j >= 1; j --)
		{
			if(abs(q[i].x) >= abs(q[i].y))
			{
				if(q[i].x > 0)
					ANS[j] = 'R', q[i].x -= b[j];
				else
					ANS[j] = 'L', q[i].x += b[j];
			}
			else
			{
				if(q[i].y > 0)
					ANS[j] = 'U', q[i].y -= b[j];
				else
					ANS[j] = 'D', q[i].y += b[j];
			}
		}
		for(int j = 1; j <= cnt; j ++)
			cout << ANS[j];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
A2 = bin(A)[2:]
B2 = bin(B)[2:]
N = len(B2)
A2 = "0"*(N-len(A2))+A2
C = [0 for _ in range(N)]
T = B-A
for k in range(N):
    ind = A%(2**(k+1))
    if k==0:
        t = T%(2**(k+2))
        s = "01010101"
        c1 = 0
        for i in range(ind,ind+t+1):
            if s[i]=="1":
                c1 += 1
    else:
        t = T%(2**(k+1))
        if ind<2**k:
            if ind+t<2**k:
                c1 = 0
            elif ind+t<2**(k+1):
                c1 = ind+t-(2**k-1)
            else:
                c1 = 2**k
        else:
            if ind+t<2**(k+1):
                c1 = t+1
            elif ind+t<3*(2**k):
                c1 = 2**(k+1)-ind
            else:
                c1 = t-2**k+1
    C[N-1-k] = c1%2
a = 0
for i in range(N):
    a = 2*a+C[i]
print(a)

Measured memory_bytes: 9256
// inputに入力データ全体が入る
function Main(input) {
    var S = input[0].split("");
    var ans = true;
    S.forEach((v,i)=>{
        if(i%2==0 && v!= "h") ans = false;
        if(i%2==1 && v!= "i") ans = false;
    });
    if(S.length %2==1) ans = false;
    console.log(ans?"Yes":"No");
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 21952
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  set<int> se;
  se.insert(A);
  se.insert(B);
  se.insert(C);
  if(se.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
let s = readLine()!
if s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR" {
  print(1)
} else if s == "RRS" || s == "SRR" {
  print(2)
} else if s == "RRR" {
  print(3)
} else {
  print(0)
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    ll k;
    cin >> k;

    queue<ll> q;
    for (int i = 1; i <= 9; ++i) {
        q.push(i);
    }
    for (int i = 0; i < k; ++i) {
        auto t = q.front();
        q.pop();
        if (i == k-1) {
            cout << t << endl;
            return;
        }
        if (t%10 != 0) {
            q.push(10*t + (t%10) - 1);
        }
        q.push(10*t + t%10);
        if (t%10 != 9) {
            q.push(10*t + (t%10) + 1);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 1792
int main() {
    int A, B;
    int a, b;
    int yen=-1;
    
    scanf("%d%d", &A, &B);
    
    for(int i=0; i<1001;i++){
        a = i*0.08;
        b = i*0.1;
        if(a==A && b==B){
            yen = i;
            break;
        }
    }
    printf("%d\n", yen);

    return 0;

}


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

int main(){
    long long int x, ans=0;
    scanf("%lld",&x);
    while(x>499){
        x -= 500;
        ans += 1000;
    }
    while(x>4){
        x -= 5;
        ans += 5;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i,ans = 0,a,b,c;cin >> n >> m;queue<int> q;
  vector<int> k[n];int v[m][2];
  for(i=0;i<m;i++){
    cin >> v[i][0] >> v[i][1];v[i][0]--;v[i][1]--;
    k[v[i][0]].push_back(v[i][1]);k[v[i][1]].push_back(v[i][0]);
  }
  for(i=0;i<m;i++){
    queue<int>().swap(q);bool ok[n] = {};
    q.push(0);
    while(!q.empty()){
      c = q.front();q.pop();
      ok[c] = 1;
      for(int x:k[c]){
        if(!(x==v[i][0] && c==v[i][1]) && !(x==v[i][1] && c==v[i][0]) && ok[x]==0) q.push(x);
      }
    }
    for(int x:ok){
      if(x==0){
        ans--;break;
      }
    }
    ans++;
  }
  cout << m-ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << "ABC"<< n << endl;
  return 0;
    

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

			if (s.endsWith("s")) {
				System.out.println(s + "es");
			} else {
				System.out.println(s + "s");
			}
		}
	}
}


Measured memory_bytes: 38516
#include<iostream>
#include<set>
#include<vector>
#include <algorithm>
using namespace std;
int X;
int main(){
	cin>>X;
	long long l=0,ans=1;
	while(1){
		l+=ans;
		if(l>=X)break;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let t1t2 = readn::<usize>(" ");
    let t1 = t1t2[0];
    let t2 = t1t2[1];
    let a1a2 = readn::<usize>(" ");
    let a1 = a1a2[0];
    let a2 = a1a2[1];
    let b1b2 = readn::<usize>(" ");
    let b1 = b1b2[0];
    let b2 = b1b2[1];

    let t1a1 = t1 * a1;
    let t2a2 = t2 * a2;
    let t1b1 = t1 * b1;
    let t2b2 = t2 * b2;

    if t1a1 == t1b1 && t2a2 == t2b2 {
        println!("infinity");
    } else if t1a1 >= t1b1 {
        let ab1 = t1a1 - t1b1;
        if t2a2 >= t2b2 {
            println!("0");
        } else {
            let ab2 = t2b2 - t2a2;
            if ab1 == ab2 {
                println!("infinity");
            } else {
                if ab1 > ab2 {
                    println!("0");
                } else {
                    let r = ab2 - ab1;
                    let mut ans = 1;
                    let t = (ab1 + r - 1) / r;
                    if ab1 % r == 0 {
                        ans += (t - 1) * 2 + 1;
                    } else {
                        ans += (t - 1) * 2;
                    }
                    println!("{}", ans);
                }
            }
        }
    } else {
        let ab1 = t1b1 - t1a1;
        if t2a2 <= t2b2 {
            println!("0");
        } else {
            let ab2 = t2a2 - t2b2;
            if ab1 == ab2 {
                println!("infinity");
            } else {
                if ab1 > ab2 {
                    println!("0");
                } else {
                    let r = ab2 - ab1;
                    let mut ans = 1;
                    let t = (ab1 + r - 1) / r;
                    if ab1 % r == 0 {
                        ans += (t - 1) * 2 + 1;
                    } else {
                        ans += (t - 1) * 2;
                    }
                    println!("{}", ans);
                }
            }
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long *l = new long long[86];
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++)
        l[i] = l[i-1] + l[i-2];

    cout << l[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int W, H, x, y, r;
int main(){
	cin >> W >> H >> x >> y >> r;

	if (x - r < 0 || y - r < 0){
		cout << "No" << endl;
	}
	else if (x + r > W || y + r > H){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
 
	return 0;
}

Measured memory_bytes: 1156
from collections import deque
from sys import stdin

def read_and_print_DLList(lst, n):
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.appendleft(cmd[1])
        elif cmd[0] == 'delete':
            if cmd[1] in lst:
                lst.remove(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.popleft()
        elif cmd[0] == 'deleteLast':
            lst.pop()
    print(*lst, sep=" ")
    
n = int(input())

lst = deque([])

read_and_print_DLList(lst, n)


Measured memory_bytes: 69732
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([(i % 2019) * (j % 2019) % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)]))


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


Measured memory_bytes: 75332
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair <int,int> P;
string mp[501];
int m,n,used[26],ans;
vector <P>  a[26];

int saiki(int);

bool check(int c,int s,int t,int f){
  int res=1;
  for(int i=s+1;i<t;i++){
    if(!f&&mp[i][c]!='.'&&!saiki(mp[i][c]-'A'))res=0;
    if(f&&mp[c][i]!='.'&&!saiki(mp[c][i]-'A'))res=0;
  }
  return res;
}

int saiki(int ch){
  int x1=a[ch][0].x,x2=a[ch][1].x;
  int y1=a[ch][0].y,y2=a[ch][1].y;
  int res=0;
  if(used[ch])return 0;
  used[ch]=1;
  
  if(x1==x2&&y2-y1!=1) res=check(x1,y1,y2,0);
  if(y1==y2&&x2-x1!=1) res=check(y1,x1,x2,1);
  
  if(x1!=x2&&y1!=y2) {
    if(x1<x2){
      res=check(y1,x1,x2+1,1)&check(x2,y1,y2,0);
      res|=check(x1,y1,y2+1,0)&check(y2,x1,x2,1);
    }
    else{
      swap(x1,x2);
      res=check(y1,x1-1,x2,1)&check(x1,y1,y2,0);
      res|= check(x2,y1,y2,0)&check(y2,x1,x2+1,1);
      swap(x1,x2);
    }
  }
  
  if(res) {
    mp[y1][x1]=mp[y2][x2]='.';
    a[ch].clear();
    ans+=2;
  }
  return res;
}

int main(){
  
  cin>>m>>n;
  for(int i=0;i<m;i++)cin>>mp[i];
  
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(mp[i][j]!='.')a[mp[i][j]-'A'].push_back(P(j,i));
  
 
  int f=1;
  while(f--) 
    for(int i=0;i<26;i++){
       memset(used,0,sizeof(used));
      if(a[i].size()) f|=saiki(i);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define scan(x) cin >>x;
#define print(x) cout << x << endl;
#define Endl endl
#define inf 99999999
#define llinf 1LL << 32

string s;

int main() {

	float a,b;
	scan(a);
	scan(b);

	cout << int((a + b) / 2 + 0.5) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int R, C, sy, sx, gy, gx;
char m[51][51] = {};
int d[51][51] = {};
bool v[51][51] = {};
int qy[100000] = {};
int qx[100000] = {};
int s = 0, e = 0;
int y[4] = { 0,1, -1,0 };
int x[4] = { 1,0,0,-1 };

void p() {
	repe(i, 1, R) {
		repe(j, 1, C) {
			cout << (int)(d[i][j]) % 10;
		}
		cout << endl;
	}
	cout << endl;
}

int main() {
	cin >> R >> C;
	sy = 1;
	sx = 1;
	gy = R;
	gx = C;
	int white = 0;
	repe(i, 1, R)repe(j, 1, C) {
		cin >> m[i][j];
		if (m[i][j] == '.')white++;
	}
	repe(i, 1, R)repe(j, 1, C)d[i][j] = 0;

	qy[e] = sy;
	qx[e] = sx;
	e++;
	d[sy][sx] = 1;
	v[sy][sx] = true;

	while (s != e) {
		int cy = qy[s];
		int cx = qx[s];
		s++;
		if (cy == gy && cx == gx)break;

		//p();

		rep(i, 0, 4) {
			int ny = cy + y[i];
			int nx = cx + x[i];

			if (ny > 0 && nx > 0 && ny <= R && nx <= C && m[ny][nx] == '.' && !v[ny][nx]) {
				v[ny][nx] = true;
				d[ny][nx] = d[cy][cx] + 1;
				qy[e] = ny;
				qx[e] = nx;
				e++;
			}
		}
	}
	if (d[R][C] == 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << white - d[R][C] << endl;;
	return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a = make_divisors(n-1)
b = make_divisors(n)

a.remove(1)
b.remove(1)

count = len(a)

for i in b:
    n_new = n // i
    while n_new % i == 0:
        n_new = n_new // i
    if n_new % i == 1:
        count += 1

print(count)

Measured memory_bytes: 3316
#include <stdio.h>
int main(void)
{
    int N, K, X, Y;
    scanf("%d %d %d %d", &N, &K, &X, &Y);
    if (K >= N) printf("%d\n", (N * X));
    else printf("%d\n", K * X + (N - K) * Y);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);

    for(int i = 0; i < N ; i ++){
        cin >> a[i];
    }
    
    int s = 0;

    for(int i = 0 ; i < N ; i++){
        s ^= a[i];
    }    
    for(int i = 0 ; i < N ; i++){
        a[i] ^= s;
    }
    for(int i = 0 ; i < N ; i++){
        cout << a[i] << endl;
    }
    return 0;
}

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

long long N, M, K, a[100009], p[100009], x1[100009], x[100009], GG[100009]; vector<long long>J;

vector<long long>add(vector<long long>A1, vector<long long>A2) {
	vector<long long>A3 = A1;
	for (int i = 0; i < A1.size(); i++) {
		A3[i] = A2[A1[i]];
	}
	return A3;
}
vector<long long>rep(vector<long long>A2, long long P) {
	vector<long long>B1 = J, B2 = A2;
	for (int i = 0; i < 62; i++) {
		if ((P / (1LL << i)) % 2 == 1) { B1 = add(B1, B2); }
		B2 = add(B2, B2);
	}
	return B1;
}

int main() {
	cin >> N; for (int i = 0; i < N; i++) { cin >> a[i]; x1[i] = i; x[i] = i; }
	cin >> M >> K;
	for (int i = 1; i <= M; i++) {
		cin >> p[i]; p[i]--; swap(x[x1[p[i] - 1]], x[x1[p[i]]]);
		swap(x1[p[i] - 1], x1[p[i]]);
	}
	vector<long long>F;
	for (int i = 0; i < N - 1; i++)J.push_back(i);
	for (int i = 0; i < N - 1; i++)F.push_back(x[i]);
	vector<long long>G = rep(F, K);
	for (int i = 0; i < G.size(); i++) GG[G[i]] = i;
	long long I = a[0]; cout << I << endl;
	for (int i = 0; i < G.size(); i++) {
		I += a[GG[i] + 1] - a[GG[i]];
		cout << I << endl;
	}
	return 0;
}

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

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

  int plan1 = N * A;
  int plan2 = B;

  if(plan1 <= plan2){
    cout << plan1 << endl;
  }
  else{
    cout << plan2 << endl;
  }
}

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

int main(){
  int a,b,c,d,area1,area2;
  cin>>a>>b>>c>>d;
  area1=a*b;
  area2=c*d;
  if(area1>area2){
    cout<<area1;
  }else{
    cout<<area2;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
const int N=2e5 + 5;
int n,a[N],f[N],res,id=INT_MAX;
priority_queue<pii> h;
main()
{
    n=in;
    forinc(i,1,n) h.push({in,i});
    while(!h.empty())
    {
        int now=h.top().fi;
        while(!h.empty()&&h.top().fi==now)
            ++res,id=min(id,h.top().se),h.pop();
        int nx=0;
        if(!h.empty()) nx=h.top().fi;
        f[id]+=res*(now-nx);
    }
    forinc(i,1,n) cout<<f[i]<<"\n";
}


Measured memory_bytes: 3568
# 1 0 2 2 3 2
n = gets.to_i
a, b = gets.split.map(&:to_i).each_slice(2).to_a.transpose
cnt = 0
# p [a,b]

ag = a.group_by{|x|x}.map{|k,v|[k,v.size]}.sort_by{|x|-x[1]}
bg = b.group_by{|x|x}.map{|k,v|[k,v.size]}.sort_by{|x|-x[1]}
# p [ag, bg]

a1 = ag[0][0]
a2 = ag[1] ? ag[1][0] : nil
b1 = bg[0][0]
b2 = bg[1] ? bg[1][0] : nil
# p [a1, a2, b1, b2]

af = ag.flat_map{|(x,c)|[x] * c}
bf = bg.flat_map{|(x,c)|[x] * c}
# p [af, bf]

result = []
if a1 != b1
  ac = af.count{|x|x != a1}
  bc = bf.count{|x|x != b1}
  result << ac + bc
else
  ac = af.count{|x|x != a1}
  bc = bf.count{|x|x != b2}
  result << ac + bc
  ac = af.count{|x|x != a2}
  bc = bf.count{|x|x != b1}
  result << ac + bc
end
p result.min


Measured memory_bytes: 36352
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll f[10000010];
int main()
{
    int n; cin>>n;
    for(int d=1; d<=n; d++){
        for(int i=d; i<=n; i+=d) f[i]++;
    }
    ll ans=0;
    for(int i=1; i<=n; i++){
        ans+=i*f[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81748
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";

}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
int c=0;

int* Bubble(int N, int *A){
  int flag=1, j, num;
  while(flag){
    flag=0;
    for(j=N-1 ; j>0 ; j--){
      if(A[j]<A[j-1]){
        num=A[j];
        A[j]=A[j-1];
        A[j-1]=num;
        flag=1;
        c++;
      }
    }
  }
  return A;
}

int main(void){
  int N,i;
  int *A;
  scanf("%d",&N);
  A = (int*)malloc(sizeof(int)*N);
  for(i=0 ; i<N ; i++){
    scanf("%d",&A[i]);
  }
  A=Bubble(N,A);
  printf("%d",A[0]);
  for(i=1 ; i<N ; i++){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2124
def check(str1,str2):
    if not(len(str1)==len(str2)):
        return False 
    for i in range(len(str1)):
        if not(str1[i]==str2[i]):
            return False
    return True


def solve(s1,s2):
    #print(len(s1),len(s2))
    if not(len(s1) == len(s2)):
        print("DIFFERENT")
        return
    flag = True
    for i in range(len(s1)):
        if not(check(s1[i],s2[i])):
            if i%2==1:
                if flag:
                    flag = False
                else:
                    print("DIFFERENT")
                    return
            else:
                print("DIFFERENT")
                return
    if flag:
        print("IDENTICAL")
    else:
        print("CLOSE")
        
    return


while True:
    s1=input().split('"')
    if s1[0] == '.':
        break
    s2 = input().split('"')
    solve(s1,s2)




Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s,ans="";
    cin>>s;
    int n=s.size(),dp[200010],pos=0;
    vector<int>v[26];
    rep(i,n)v[s[i]-'a'].pb(i);
    rep(i,26)v[i].pb(n);
    fill(dp,dp+n,INF);
    dp[n]=1,dp[n+1]=0;
    for(int i=n-1;i>=0;i--)rep(j,26)chmin(dp[i],dp[*lower_bound(all(v[j]),i)+1]+1);
    while(pos<=n){
        rep(i,26){
            int nxt=*lower_bound(all(v[i]),pos);
            if(dp[pos]==dp[nxt+1]+1){
                ans+='a'+i;
                pos=nxt+1;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
bool b[100010];
int main(){
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		a[i]++;
	}
	ll ans=1;
	b[0]=true;
	for(int i=0;i<m;i++){
		ll l,r;
		cin>>l>>r;
		l--;r--;
		if(b[l]){
			if(a[l]==1){
				ans--;
				b[l]=false;
			}
			a[l]--;
			a[r]++;
			if(b[r]!=true){
				ans++;
				b[r]=true;
			}
		}
		else{
			a[l]--;
			a[r]++;
		}
	}
	cout << ans;
}

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

int main(){
    int N;
    cin >> N;
    set<int> mochi;
    for(int i = 0; i < N; i++){
        int mochi_size;
        cin >> mochi_size;
        mochi.insert(mochi_size);
    }
    cout << mochi.size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(1e5+100)
#define pi 3.141592653589793238
#define ll unsigned long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r;
	cin>>r;
	cout<<(2*pi*r)<<'\n';
   return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,x;
    cin >> n >> x;
    int m[n];
    int ans=n;
    int minv = 10000000;
    rep(i,n){
        cin >> m[i];
        x-=m[i];
        minv = min(minv,m[i]);
    }
    
    cout << n + x/minv;
    
	return 0;
}

Measured memory_bytes: 3568