akhauriyash/Code-Regression huggingface dataset:
use std::collections::BTreeMap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: usize = sc.read();
    let l: usize = sc.read();

    let mut uf1 = UnionFind::new(n);
    for _ in 0..k {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        uf1.unite(a, b);
    }

    let mut uf2 = UnionFind::new(n);
    for _ in 0..l {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        uf2.unite(a, b);
    }

    let mut map = BTreeMap::new();
    for i in 0..n {
        let root1 = uf1.find(i);
        let root2 = uf2.find(i);
        *map.entry((root1, root2)).or_insert(0) += 1;
    }

    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        let root1 = uf1.find(i);
        let root2 = uf2.find(i);
        let ans = *map.get(&(root1, root2)).unwrap();
        print!("{}", ans);
    }
    println!();
}

pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    size: usize,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            size: n,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;
        self.size -= 1;
        return true;
    }
}
pub struct Scanner<R> {
    stdin: R,
}

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


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

int main() {
    int x_1, y_1, x_2, y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    int dx = x_2 - x_1;
    int dy = y_2 - y_1;
    int x = x_2, y = y_2;
    rep(i, 2){
        int _dx = -dy;
        int _dy = dx;
        dx = _dx;
        dy = _dy;
        x += dx;
        y += dy;
        cout << x << " " << y;
        if (i == 0) cout << " ";
        else cout << endl;
    }

}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int k;
  cin >> k;
  int kisu, gusu;
  gusu = k / 2;
  kisu = k / 2;
  if (k % 2 == 1) {
    kisu++;
  }
  P(gusu * kisu);



  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

int main() {
    int n;
    cin >> n;
    f(n) {
        int x;
        cin >> x;
        if (x % 2 == 0 && x % 3 && x % 5) {
            cout << "DENIED\n";
            exit(0);
        }
    }
    cout << "APPROVED\n";
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N+1];
    
    for(int i=1; i<=N; i++){
      int b = sc.nextInt();
      A[b] = i;
    }
    
    for(int i=1; i<=N; i++){
      System.out.println(A[i]+" ");//arraneg student from No1
    }
  }
}
    

Measured memory_bytes: 60272
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int A = 0;
      int B = 0;
      int AB = 0;
      int O = 0;
      while(sc.hasNext()) {
         String[] input = sc.nextLine().split(",");
         String bt = input[1];
         
         switch(bt) {
            case "A":
               A ++;
               break;
            case "B":
               B ++;
               break;
            case "AB":
               AB ++;
               break;
            case "O":
               O ++;
               break;
         }
         
      }
      
      System.out.println(A);
      System.out.println(B);
      System.out.println(AB);
      System.out.println(O);
   }
}


Measured memory_bytes: 25756
#include <iostream>
#define For(i, n) for(int i = 0; i < (n); i ++)
using namespace std;

int main(void){
  int n;
  cin >> n;
  int a[] = {-1,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,3,8,8,11,11,11,11,14,14,32,32,35,35,35,35,42,42,42,42,49,49,49,49,49,49,75,75,86,86,86,86,86,86,123,123,131,131,131,131,148,148,153,153,170,170,170,170,170,170,227,227,227,227,227,227,250,250,323,323,324,324,324,324,354,354,354,354,384,384,384,384,384,391,491,491,529,529,529,529,529,529,543};
  cout << a[n] << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define MAX 101
#define WHITE -1
#define GRAY 2
#define BLACK 1
using namespace std;

int G[MAX][MAX]={},d[MAX]={},f[MAX]={},color[MAX]={},times=0,Adj[MAX]={};

void print(int n){
  for(int i=1;i<=n;i++){
    cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
  }
}

void visit(int u,int n){
    color[u]=GRAY;
    d[u]=++times;
    int v=1;
    while(v<=n){
        if(G[u][v]>0){
            if(color[v]==WHITE)visit(v,n);
        }
        v++;
    }
    color[u]=BLACK;
    f[u]=++times;
}

void dfs(int V[],int n){
    int u;
    for(u=1;u<=n;u++){
        color[u]=WHITE;
    }
    times =0;
    for(u=1;u<=n;u++){
        if(color[u]==WHITE)visit(u,n);
    }
}

int main(){
  int n,i,k,j,A,B,V[MAX]={};
  cin>>n;
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
        G[i][j]=-1;
    }
  }
  for(i=0;i<n;i++){
    cin>>A>>k;
    for(j=0;j<k;j++){
      cin>>B;
      G[A][B]=1;
    }
  }
  dfs(V,n);
  print(n);
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

char map[100][100];

int main(){
	ios::sync_with_stdio(false);
	int h,w,flag;
	while(cin>>h>>w){
		int i,j;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>map[i][j];
			}
		}
		for(i=0;i<h;i++){
			flag=1;
			for(j=0;j<w;j++){
				if(map[i][j]=='#'){
					flag=0;
					break;
				}
			}
			if(flag){
				for(j=0;j<w;j++){
					map[i][j]='e';
				}
			}
		}
		for(i=0;i<w;i++){
			flag=1;
			for(j=0;j<h;j++){
				if(map[j][i]=='#'){
					flag=0;
					break;
				}
			}
			if(flag){
				for(j=0;j<h;j++){
					map[j][i]='e';
				}
			}
		}
		cout<<endl;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(map[i][j]!='e')
				cout<<map[i][j];					
			}
			for(j=0;j<w;j++){
				if(map[i][j]=='#'){
					cout<<endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int total = 0;
		for (char c : arr) {
			total += c - '0';
		}
		System.out.println(total);
	}
}


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

struct Vec {
        int x, y, n, t;
        bool operator < (const Vec &temp) const {
                return x < temp.x;
        }
};

int n, a[19][2], ans = 2e9;

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

	cin >> n;
	for(int k = 0; k <= 1; ++k)
		for(int i = 1; i <= n; ++i) cin >> a[i][k];
	for(int mask = 0; mask < (1 << n); ++mask) {
		vector<Vec> v(n + 1);
		int moves = 0, step = n;
		for(int i = 1; i <= n; ++i) v[i] = {a[i][0], a[i][1], 0, ((mask >> (i - 1)) & 1)};
		while(step > 0) {
			int mx = 0, pos = 0;
			for(int i = 1; i <= step; ++i) {
				int after = ((step - i) % 2) ^ v[i].n;
				if(after != v[i].t) continue;
				int destval = (after == v[i].n ? v[i].x : v[i].y);
				if(destval >= mx) mx = destval, pos = i;
			}
			if(pos == 0) {
                moves = 2e9;
				break;
			}
			for (int i = pos; i < step; ++i, ++moves) {
				swap(v[i].x, v[i].y);
				v[i].n ^= 1;
				swap(v[i + 1].x, v[i + 1].y);
				v[i + 1].n ^= 1;
				swap(v[i], v[i + 1]);
			}
			--step;
		}
		if(is_sorted(v.begin() + 1, v.end())) ans = min(ans, moves);
	}
	cout << (ans == 2e9 ? -1 : ans);
} 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,k,a[51];
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;++i)cin>>a[i];
    nth_element(a+1,a+k+1,a+n+1,greater<int>());
    cout<<accumulate(a+1,a+k+1,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(int(a*b))
    elif op == "/":
        print(int(a/b))
    else:
        break


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Dice
{
    int top;
    int front;
    int right;
    int left;
    int back;
    int bottom;

public:
    Dice(int top, int front, int right, int left, int back, int bottom);
    bool is_same(Dice d);
    void roll_char(Dice *d, char command);
    void roll_left(Dice *d);
    bool is_same_four(Dice *d);
};
Dice::Dice(int top, int front, int right, int left, int back, int bottom)
{
    this->top = top;
    this->front = front;
    this->right = right;
    this->left = left;
    this->back = back;
    this->bottom = bottom;
}
void Dice::roll_char(Dice *d, char command)
{
    int tmp;
    switch (command)
    {
    case 'S':
        tmp = d->top;
        d->top = d->back;
        d->back = d->bottom;
        d->bottom = d->front;
        d->front = tmp;
        break;
    case 'N':
        tmp = d->top;
        d->top = d->front;
        d->front = d->bottom;
        d->bottom = d->back;
        d->back = tmp;
        break;
    case 'W':
        tmp = d->top;
        d->top = d->right;
        d->right = d->bottom;
        d->bottom = d->left;
        d->left = tmp;
        break;
    case 'E':
        tmp = d->top;
        d->top = d->left;
        d->left = d->bottom;
        d->bottom = d->right;
        d->right = tmp;
        break;
    }
}
void Dice::roll_left(Dice *d)
{
    string command = "NWS";
    for (int i = 0; i < 3; i++)
    {
        roll_char(d, command.at(i));
    }
}
bool Dice::is_same_four(Dice *d)
{
    for (int j = 0; j < 4; j++)
    {
        if (d->right == right && d->left == left && d->back == back && d->front == front)
        {
            return true;
        }
        roll_left(d);
    }
    return false;
}
bool Dice ::is_same(Dice d)
{
    //NENENで転がしつつ回って判定
    string command = "NENENE";
    for (int i = 0; i < command.length(); i++)
    {
        //まずtopが同じか判定
        //同じでなければ転がる
        if (d.top == top && d.bottom == bottom)
        {

            //topとbottom同じなら残る4面を判定
            if (is_same_four(&d))
            {
                return true;
            }

            //bottomが違うもしくは左回転で一周したら転がる
        }
        //転がる
        roll_char(&d, command.at(i));
    }
    //転がりきったら
    return false;
}

int main()
{

    int n;
    cin >> n;
    vector<Dice> D;
    int top, front, right, left, back, bottom;

    //まず全部入力
    for (int i = 0; i < n; i++)
    {
        cin >> top >> front >> right >> left >> back >> bottom;
        D.push_back(Dice(top, front, right, left, back, bottom));
    }

    //i = 末尾
    //j = 末尾より前の全てを一つずつ見ていく
    bool all_different = true;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (D.at(i).is_same(D.at(j)))
            {
                all_different = false;
                break;
            }
        }
    }
    if (all_different)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#define MAXV 100005
#define F(a,b) for(int a = 0; a < b; ++ a)
#define FF(a,b) for(int a = 1; a <= b; ++ a)
#define INF 1LL << 60
typedef long long ll;
using namespace std;
struct Node
{
	int v, dis;
	Node(int _v):v(_v), dis(-1){}
};
vector<Node>Adj[MAXV];
bool vis[MAXV] = {false};
int N, M;
int d[MAXV];
int DFS(int u){
	vis[u] = true;
	int res = 0;
	// if(Adj[u].size() == 0) return res;

	
	F(j,Adj[u].size()){
		int v = Adj[u][j].v;
		if(!vis[v]){
			d[v] = DFS(v);
		}
		res = max(res, d[v]);
	}
	return res + 1;
}
int main(){
	
	int u, v;
	scanf("%d%d", &N, &M);
	F(i,M){
		scanf("%d%d", &u, &v);
		Adj[u].push_back(Node(v));
	}
	memset(d, -1, sizeof(d));
	FF(u,N){
		if(!Adj[u].empty() && !vis[u])
			d[u] = DFS(u);
	}
	int maxn = -1;
	FF(u,N){
		// printf("%d\n", d[u]);
		maxn = max(maxn, d[u] - 1);
	}
	printf("%d\n", maxn);
	return 0;
}


Measured memory_bytes: 8192
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

bc.sort(key=lambda x: x[1], reverse=True)
a.sort()

i = 0
for b, c in bc:
    for _ in range(b):
        if i < n and a[i] < c:
            a[i] = c
            i += 1
        else:
            break

ans = sum(a)
print(ans)


Measured memory_bytes: 32888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int dp[5005][5005];

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = n - 1; j >= 0; j--)
        {
            if (s[i] != s[j])
                dp[i][j] = 0;
            else
                dp[i][j] = dp[i + 1][j + 1] + 1;
        }
    }
    int ans = 0;
    rep(i, n) rep(j, n)
    {
        if (i >= j)
            continue;
        int now = min(dp[i][j], j - i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98048
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;
const int INF = 1001001001;

int main()
{
    int h, w;
    cin >> h >> w;
    char maze[h][w];

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> maze[i][j];
        }
    }

    
    

    int x[4] = {1, 0, -1, 0};
    int y[4] = {0, 1, 0, -1};

    int ans = 0;

    for (int i = 0; i <h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(maze[i][j] == '#') continue;
            queue<pair<int, int>> que;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            que.push({i, j});
            dist[i][j] = 0;
            while (!que.empty())
            {
                pair<int, int> now = que.front();
                que.pop();
                int f = now.first;
                int s = now.second;
                for(int k = 0; k< 4; k++){
                    if(f+x[k] < 0 || f+x[k] >= h || s+y[k] < 0 || s+y[k] >= w) continue;
                    if(maze[f+x[k]][s+y[k]]=='#') continue;
                    if(dist[f+x[k]][s+y[k]] != INF) continue;
                    dist[f+x[k]][s+y[k]] = dist[f][s]+1;
                    que.push({f+x[k], s+y[k]});
                }
            }
            for(int a = 0; a < h; a++){
                for(int b = 0; b < w; b++){
                    if(dist[a][b] == INF) continue;
                    ans = max(ans, dist[a][b]);
                }
            }
        }
    }

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
	int N; cin >> N;
	int A[N+2];
	A[0] = 0; A[N+1] = 0;
	int ans = 0;
	for(int i = 1; i <= N+1; i++) {
		cin >> A[i];
		ans += abs(A[i] - A[i-1]);
	}

	int res[N+1];
	for (int i = 1; i <= N; i++)
	{
		res[i] = ans - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]);
	}
//	cout << ans << endl;
	for (int i = 1; i <= N; i++)
	{
		cout << res[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, ans=0, i=1; scanf("%d %d", &a, &b);
	while (2+2==4){
		if (i>=b){cout<<ans; return 0;}
		i = i-1+a;
		ans++;
	}
	return 0;
}


Measured memory_bytes: 256
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n, kk;
	cin >> n >> kk;
	vector<ll> p(n+1), c(n+1);
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	for(int i = 1; i <= n; i++)
		cin >> c[i];

	vector<ll> res1[n+1];
	for(int i = 1; i <= n; i++)
	{
		vector<bool> done(n+1, 0);
		ll curr = i;
		while(!done[curr])
		{
			res1[i].push_back(c[p[curr]]);
			done[curr] = 1;
			curr = p[curr];
		}
	}
	ll ans[n+1];
	for(int i = 1; i <= n; i++)
		ans[i] = LLONG_MIN;
	for(int i = 1; i <= n; i++)
	{
		ll k = kk;
		vector<ll> v = res1[i];
		ll ans1 = 0, zz = 0, nn = v.size();
		for(int j = 0; j < min(k, nn); j++)
		{
			ans1 += v[j];
			ans[i] = max(ans[i], ans1);
			zz += v[j];
		}
		k -= min(nn, k);
		ll xx = (k - nn) / nn;
		xx = max(xx, 0ll);
		ans1 += zz * xx;
		ans[i] = max(ans[i], ans1);
		k -= xx * nn;
		for(int j = 0; j < min(k, nn); j++)
		{
			ans1 += v[j];
			ans[i] = max(ans[i], ans1);
		}
		k -= min(nn, k);
		for(int j = 0; j < min(k, nn); j++)
		{
			ans1 += v[j];
			ans[i] = max(ans[i], ans1);
		}
	}
	ll fans = LLONG_MIN;
	for(int i = 1; i <= n; i++)
	{
		fans = max(fans, ans[i]);
	}
	cout << fans << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

#define MAX 500000

typedef struct _list{
    int data;
    struct _list *next;
}list;
typedef struct{
    list *head;
    list *tail;
}LIST;

void dump(LIST l){
    list *p=l.head;
    while(p!=NULL){
        if(p==l.head)printf("%d",p->data);
        else printf(" %d",p->data);
        p=p->next;
    }
    printf("\n");
}
void freeAll(LIST l[],int n){
    int i;
    list *p,*pp;
    for(i=0;i<n;i++){
        p=l[i].head;
        while(p!=NULL){
            pp=p;
            free(p);
            p=pp->next;
        }
    }
}

int main(){
    int i;
    
    int n,q;
    scanf("%d %d\n",&n,&q);
    
    LIST l[n];
    for(i=0;i<n;i++){
        l[i].head=NULL;
        l[i].tail=NULL;
    }
    
    int com,t,x,s;
    while(q--){
        scanf("%d ",&com);
        switch(com){
            case 0:
                //insert
                scanf("%d %d\n",&t,&x);
                if(l[t].head==NULL){
                    l[t].head=(list*)malloc(sizeof(list));
                    l[t].head->data=x;
                    l[t].head->next=NULL;
                    l[t].tail=l[t].head;
                }else{
                    l[t].tail->next=(list*)malloc(sizeof(list));
                    l[t].tail=l[t].tail->next;
                    l[t].tail->data=x;
                    l[t].tail->next=NULL;
                }
                break;
            case 1:
                //dump
                scanf("%d\n",&t);
                dump(l[t]);
                break;
            case 2:
                //splice
                scanf("%d %d\n",&s,&t);
                if(l[t].tail!=NULL)l[t].tail->next=l[s].head;
                else l[t].head=l[s].head;
                l[t].tail=l[s].tail;
                l[s].head=NULL;
                l[s].tail=NULL;
                break;
        }
    }
    
    freeAll(l,n);
    
    return 0;
}


Measured memory_bytes: 17356
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;
int main(){

  int x;
  cin>>x;
  if(x<1200) cout<<"ABC";
  else cout<<"ARC";

}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k;
  int N;
  
  scanf("%d",&N);
  long A[5];
  
  for(i=0;i<5;i++)
    A[i]=0;
  
  char S[N][10];
  
  for(i=0;i<N;i++){
    scanf("%s",S[i]);
    if(S[i][0]=='M')
      A[0]++;
    else if(S[i][0]=='A')
      A[1]++;
    else if(S[i][0]=='R')
      A[2]++;
    else if(S[i][0]=='C')
      A[3]++;
    else if(S[i][0]=='H')
      A[4]++;
    else
      continue;
  }
  
  
  long ans=0;
  ans += A[0]*A[1]*A[2];
  ans += A[1]*A[2]*A[3];
  ans += A[2]*A[3]*A[4];
  ans += A[0]*A[2]*A[3];
  ans += A[0]*A[3]*A[4];
  ans += A[0]*A[1]*A[3];
  ans += A[0]*A[1]*A[4];
  ans += A[1]*A[3]*A[4];
  ans += A[0]*A[2]*A[4];
  ans += A[1]*A[2]*A[4];
  printf("%ld\n",ans);
  return 0;
}
  
  



Measured memory_bytes: 1152
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

S = input()
N = len(S)
i = 0

ANS = []
while i < N :
    # print(S[i:i + 2])

    if S[i:i + 2] == 'RL':
        li = i
        while li > 0 and S[li] == 'R':
            li -= 1
        if li != 0:
            li += 1

        ri = i + 1
        while ri < N and S[ri] == 'L':
            ri += 1
        ri -= 1
        # print([li, i, ri])
        cnt = ri - li + 1
        if cnt % 2 == 0:
            ANS.append(cnt // 2)
            ANS.append(cnt // 2)
        else:
            if ri % 2 == i % 2:
                ANS.append(cnt // 2 + 1)
                ANS.append(cnt // 2)
            else:
                ANS.append(cnt // 2)
                ANS.append(cnt // 2 + 1)
        i += 2
    else:
        ANS.append(0)
        i += 1

print(" ".join([str(s) for s in ANS]))


Measured memory_bytes: 11252
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


int main() {
    long n,k;
    cin >> n >> k;
    double t = 0;
    for(long i = 1;i <= n;++i){
        long j = i;
        int c = 0;
        while(j < k){
            j = j << 1;
            ++c;
        }
       // cout << c << endl;
        t += (1 / pow(2,c)) / n;
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(10) << t << endl;

}







Measured memory_bytes: 384
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let n = lines.shift().split(/\s/)[0];
    let N =Number(n);
let ans = "";
while (N != 0) {
		if (N % 2 != 0) {
			N--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		N /= -2;
	}
	if (ans == "") ans = "0";
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, m = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for j in range(n)]
ab.sort()
money = 0
for a, b in ab:
  if b < m:
    money += a * b
    m -= b
  else:
    money += a * m
    break
print(money)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];
    
    ASC(A);
    bool f = true;
    REP(i,0,N-1) {
        if(A[i] == A[i+1]) {
            f = false;
            break;
        }
    }
    if(f) PR("YES");
    else PR("NO");
    

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	if(a<b&&b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2704
/*
Sometimes I feel like I don't have a partner
Sometimes I feel like my only friend
It's the city I live in, the City of Angels
Lonely as I am, together we cry

I drive on her streets 'cause she's my companion
I walk through her hills cause she knows who I am
She sees my good deeds and she kisses me windy
I never worry, now that is a lie

I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
Yeah, yeah, yeah

It's hard to believe that there's nobody out there
It's hard believe that I'm all alone
At least I have her love the city, she loves me
Lonely as I am, together we cry

And I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
And I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
Yeah, yeah, yeah, oh, no, no, no
Yeah, yeah, love me I say yeah, yeah

Under the bridge downtown is where I drew some blood
Under the bridge downtown I could not get enough
Under the bridge downtown forgot about my love
Under the bridge downtown I gave my life away
Yeah, yeah, yeah

Yeah, yeah, yeah, oh, no, no, no
Yeah, yeah, oh, no, no
I said yea yeah, Ill stay
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 500031;

string st;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> st;
	for (int i = 0; i < 4; i++)
	{
		cout << st[i];
	}
	cout << " ";
	for (int i = 4; i < st.size(); i++)
	{
		cout << st[i];
	}
	cout << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 256
var
	n,i,j,p:Longint;
	c,s,f:array[1..500]of Longint;
begin
	read(n);
	for i:=1 to n-1 do read(c[i],s[i],f[i]);
	for i:=1 to n do begin
		p:=0;
		for j:=i to n-1 do begin
			if p<s[j] then p:=s[j] else p:=(p-1)div f[j]*f[j]+f[j];
			p:=p+c[j];
		end;
		writeln(p);
	end;
end.


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DSumOfDivisors {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      ll ans = 0;
      for(int i=1; i<=n; i++) {
        for(int j=i; j<=n; j+=i) {
          ans += j;
        }
      }
      cout << ans << endl;
    }
};

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

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

int main()
{
    int x, y, n[8], f = 0;
    cin >> x;
    y = x;
    for (int i = 8; i >= 0; i--)
    {
        n[i] = y / pow(10, i);
        y -= n[i] * pow(10, i);
        f += n[i];
    }
    if (x % f == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdint>
#include <cmath>

using namespace std;

const u_int64_t D = 1'000'000'007LL;

u_int64_t xgdf(u_int64_t a, u_int64_t b, int64_t *co)
{
    if (b == 0)
    {
        return a;
    }

    int64_t c = a / b;
    int64_t old[4];
    old[0] = co[0];
    old[1] = co[1];
    old[2] = co[2];
    old[3] = co[3];

    co[0] = 0LL * old[0] + 1LL * old[1];
    co[1] = 1LL * old[0] - c * old[1];
    co[2] = 0LL * old[2] + 1LL * old[3];
    co[3] = 1LL * old[2] - c * old[3];

    return xgdf(b, a % b, co);
}

u_int64_t hoge(const u_int64_t N)
{
    return N * (N - 1) * (N + 1) / 6;
}

u_int64_t comb(const u_int64_t a, const u_int64_t b)
{
    u_int64_t numerator = 1;
    u_int64_t denominator = 1;

    for (u_int64_t i = b; i > 0; i--)
    {
        numerator = ((a - i + 1) * numerator) % D;
        denominator = (i * denominator) % D;
    }

    int64_t co[4];
    co[0] = 1LL;
    co[1] = 0LL;
    co[2] = 0LL;
    co[3] = 1LL;

    xgdf(denominator, D, co);
    int64_t inv_d = (co[0] + D) % D;

    return numerator * inv_d;
}

int main()
{
    u_int64_t N, M, K;

    cin >> N >> M >> K;

    const u_int64_t c = comb(N * M - 2, K - 2) % D;
    const u_int64_t m2 = (M * M) % D;
    const u_int64_t n2 = (N * N) % D;
    const u_int64_t xx = hoge(N) % D;
    const u_int64_t yy = hoge(M) % D;

    const u_int64_t sx = (((m2 * xx) % D) * c) % D;
    const u_int64_t sy = (((n2 * yy) % D) * c) % D;

    const u_int64_t sum = (sx + sy) % D;

    cout << (u_int64_t)sum << endl;
    return 0;
}


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

namespace AtCoder.Question
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var (a, b) = ReadHelper.ReadValue<decimal, decimal>();
            Console.WriteLine(Math.Floor(a * b));
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27644
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  long long n; cin >> n;
  long long ans = n - 1;

  for(int i = 2; i <= 1000000 ; i++) {
    if( (n % i) == 0) {
      long long j = (long long)n / i; 
      ans = min(ans,(j - 1) + ( i - 1));
    }
  } 

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#include <unordered_map>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  unordered_map<int, bool> h;
  ll n, a, cnt = 0;
  cin >> n;
  while (n--) {
    cin >> a;
    if (h[a]) {
      cnt--;
    } else {
      cnt++;
    }
    h[a] = !h[a];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll h, n;
    cin>>h>>n;
    ll a[n];
    ll sim  = 0;
    loop(i,0,n){
        cin>>a[i];
        sim += a[i];
    }
    if(sim >= h){
        print("Yes");
    }
    else print("No");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::vector<std::pair<int, int>>> g;
std::vector<int> ret;

void dfs(int v, int p, int c) {
    int j = c ? 0 : 1;
    for (auto e : g[v]) {
        int to = e.first, index = e.second;
        if (to == p) continue;
        dfs(to, v, j);
        ret[index] = j++;
        if (j == c) j++;
    }
}

int main() {
    int n;
    std::cin >> n;
    g.resize(n); ret.resize(n - 1);
    for (int i = 0; i + 1 < n; i++) {
        int u, v;
        std::cin >> u >> v;
        --u; --v;
        g[u].emplace_back(v, i);
        g[v].emplace_back(u, i);
    }

    int k = 0;
    for (auto &v : g) if (v.size() > k) k = v.size();

    dfs(0, -1, -1);
    std::cout << k << std::endl;
    for (int r : ret) std::cout << r + 1 << std::endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> R(n);
    for (int i = 0; i < n; ++i) {
        cin >> R.at(i);
    }
    int maxv = -2000000000;
    int minv = R.at(0);
    for (int j = 1; j < n; ++j) {
        maxv = max(maxv, R.at(j)-minv);
        minv = min(minv, R.at(j));
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3636
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 
#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)
 
#define endl '\n'
#define debug cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;
 
#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 
 
#define fr first
#define sc second
 
#define MAXN 200005
#define INF 9223372036854775807
signed main(){
    fastio
    int n,ans=0;
    cin>>n;
    vector<int> a(n);
    f(i,0,n)
        cin>>a[i];
    sort(all(a));
    vector<int> b(1000010,0);
    f(i,0,n-1){
    	if(a[i]==a[i+1])
    	    b[ a[i] ]=1;
	}
	for(int j=2*a[0];j<1000001;j+=a[0])
		b[j]=1;
	f(i,1,n){
		if(a[i]!=a[i-1])
		    for(int j=2*a[i];j<1000001;j+=a[i])
			    b[j]=1;
	}
	f(i,0,n){
		if( !b[ a[i] ] )
		    ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 12700
#include <iostream>

using namespace std;

int main() {
	int s[2000001] = {};
	int K;
	int X;
	cin >> K >> X;
	s[X] = 1;
	int j;
	for (j = X - K + 1; j < X+K; j++) {
		s[j] = 1;
		cout << j << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;



int main (){
  int n,x;
  int i;
  int ans = 0;
  int m[100];

  std::cin >> n>>x;

  for (i = 0;i < n;i++){
    std::cin >> m[i];
  }
  sort(m,m+n);
  for (i = 0 ; i < n; i++){
    x -= m[i];
    ans++;
  }
  while(x >= m[0] ){

    x -= m[0];
    ans++;
  }
std::cout << ans << '\n';





  return 0;


}


Measured memory_bytes: 256
a,b = [i for i in input().split()]
is_honest = True
if (a == 'H') :
	is_honest = True
else :
	is_honest = False

if (b == 'H' and is_honest) :
	print("H")
elif (b == 'H' and not is_honest) :
	print("D")
elif (b == 'D' and is_honest) :
	print("D")
else :
	print("H")

Measured memory_bytes: 3060
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.append(b[0])
a.append(b[1])
a.append(c[0])
a.append(c[1])
x = [0] * 4

for i in a:
    x[i-1] += 1

f = 0
for i in range(4):
    if x[i] in [1, 2]:
        f += 1

if f == 4:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([5, 2, 3, 4, 1]), 'YES')

    def test_2(self):
        self.assertEqual(think([2, 4, 3, 5, 1]), 'NO')

    def test_3(self):
        self.assertEqual(think([1, 2, 3, 4, 5, 6, 7]), 'YES')


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    reverse = []
    for i in range(1, len(data)):
        if data[i] < data[i - 1]:
            if reverse:
                reverse.append(i)
            else:
                reverse.append(i - 1)
    if not reverse:
        return 'YES'

    if len(reverse) == 2:
        i, j = reverse
        data[i], data[j] = data[j], data[i]
        for i in range(1, len(data)):
            if data[i] < data[i - 1]:
                return 'NO'
        return 'YES'
    else:
        return 'NO'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5700
#include<stdio.h>

int main(){
  int j,i,count=0,N,A[100],l=1,k;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  /*for(i=0;i<N;i++){
    printf("%d ",A[i]);
    }*/
  for(j=0;j<N;j++){
    for(i=N-1;i>=l;i--){
      if(A[i]<A[i-1]){
	k=A[i];
	A[i]=A[i-1];
	A[i-1]=k;
	count++;
      }
    }
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i<N-1)printf(" ");
    else if(i==N-1)printf("\n");
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2104
import sys
import collections
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N = int(sys.stdin.readline().rstrip())
SList=[]
for i in range(N):
  S=sys.stdin.readline().rstrip()
  SList.append("".join(sorted(S)))
  
c = collections.Counter(SList)

ans=0
for v in c.values():
  if v<=1:
    continue
  ans+=combinations_count(v, 2)
print(ans)

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

int main(){
    int N;
    string S,S2;
    char c;
    cin >> N >>S;
    for(int i=0; i<S.size(); i++){
        c=S[i]+N;
        if(c>'Z'){
            c='A'-1+c-'Z';
        }
        S2.append(1,c);
    }
    cout << S2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <bitset>
#include <cmath>

#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//桁DP
ll dp[100][2];
int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,100){
        dp[i][0]=-1;
        dp[i][1]=-1;
    }
    dp[45][0]=0;
    for(int i=44;i>=0;i--){
        ll mask = 1LL<<i;
        int num = 0;
        rep(j,n) if(a[j]&mask) num++;
        if(dp[i+1][1]>=0) chmax(dp[i][1],dp[i+1][1]+mask*max(num,n-num));
        if(dp[i+1][0]>=0){
            if(k&(1LL<<i)){
                chmax(dp[i][1],dp[i+1][0]+mask*num);
                chmax(dp[i][0],dp[i+1][0]+mask*(n-num));
            }else{
                chmax(dp[i][0],dp[i+1][0]+mask*num);
            }
        }
    }
    cout << max(dp[0][0],dp[0][1]) << endl;
}


Measured memory_bytes: 1024