akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// z-algo
struct ZAlgo {
  vector<int> a;
  ZAlgo(){}
  ZAlgo(const vector<long long> &s) {
    a.resize(s.size());
    a[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
      while (i+j < s.size() && s[j] == s[i+j]) ++j;
      a[i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < s.size() && k+a[k] < j) a[i+k] = a[k], ++k;
      i += k; j -= k;
    }
  }
  ZAlgo(const string &s) {
    a.resize(s.size());
    a[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
      while (i+j < s.size() && s[j] == s[i+j]) ++j;
      a[i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < s.size() && k+a[k] < j) a[i+k] = a[k], ++k;
      i += k; j -= k;
    }
  }
  int & operator [](int n) {return a[n];}
  int size() {return a.size();}
};

int main() {
  
  int n; cin >> n;
  vector<lint> a(n);
  vector<lint> b(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  vector<lint> A(n);
  vector<lint> B(n);
  for(int i = 0; i < n; i++) {
    A[i] = a[i] ^ a[(i + 1) % n];
    B[i] = b[i] ^ b[(i + 1) % n];
  }
  
  vector<lint> s;
  for(int i = 0; i < n; i++) {
    s.push_back(A[i]);
  }
  s.push_back(-1);
  for(int j = 0; j < 2; j++) {
    for(int i = 0; i < n; i++) {
      s.push_back(B[i]);
    }
  }
  ZAlgo za(s);

  /*
  for(int i = 0; i < s.size(); i++) {
    cerr << i << " ";
  }
  cerr << endl;
  for(int i = 0; i < s.size(); i++) {
    cerr << s[i] << " ";
  }
  cerr << endl;
  for(int i = 0; i < za.size(); i++) {
    cerr << za[i] << " ";
  }
  cerr << endl;
  */

  vector<pair<lint, lint>> ans; // {k, x}
  for(int i = n + 1; i <= n + n; i++) {
    if(za[i] == n) ans.push_back({(n + n - i + 1) % n, -1});
  }

  for(int i = 0; i < ans.size(); i++) {
    lint k = ans[i].first;
    ans[i].second = a[k % n] ^ b[0];
  }

  sort(ALL(ans));
  for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl;

  return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		for (int i = 0; i < b; ++i)cout << a;
	}
	else
	{
		for (int i = 0; i < a; ++i)cout << b;
	}cout << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque,defaultdict
from fractions import gcd
from math import ceil

def N():
    return int(sys.stdin.readline())
def NK():
    return map(int,sys.stdin.readline().split())
def LS_I():
    return [int(x) for x in sys.stdin.readline().split()]
def LS_S():
    return list(input())
def main():
    a,b = NK()
    if a>=10 or b>=10:
        print(-1)
    else:
        print(a*b)

if __name__ == "__main__":
    main()

Measured memory_bytes: 66028
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << p.first << " " << p.second ;
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	rep(i, v.size()) {
		if (i) os << endl;
		os << v[i];
	}
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	VPi path;
	cin >>n>>k;
	int dis = (n-1) * (n - 2) / 2;
	if(dis <k){
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n-1 ;i++){
		path.eb(i+1, n );
	}
	for (int i = 1; i <= n - 1;i++){
		for (int j = i + 1; j <= n - 1 and dis > k;j++){
			path.eb(i, j);
			dis--;
		} }
	cout << path.size() << endl
	<< path << endl;
}

Measured memory_bytes: 3708
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, w) = scan!(i64, i64);
    let v1 = (1..h)
        .map(|i| {
            let v = vec![i * w, (h - i) / 2 * w, (h - i - (h - i) / 2) * w];
            v.iter().max().unwrap() - v.iter().min().unwrap()
        })
        .min()
        .unwrap();

    let v2 = (1..w)
        .map(|i| {
            let v = vec![i * h, (w - i) / 2 * h, (w - i - (w - i) / 2) * h];
            v.iter().max().unwrap() - v.iter().min().unwrap()
        })
        .min()
        .unwrap();

    let v3 = (1..h)
        .map(|i| {
            let v = vec![i * w, (h - i) * (w / 2), (h - i) * (w - w / 2)];
            v.iter().max().unwrap() - v.iter().min().unwrap()
        })
        .min()
        .unwrap();

    let v4 = (1..w)
        .map(|i| {
            let v = vec![i * h, (w - i) * (h / 2), (w - i) * (h - h / 2)];
            v.iter().max().unwrap() - v.iter().min().unwrap()
        })
        .min()
        .unwrap();

    println!("{}", vec![v1, v2, v3, v4].iter().min().unwrap())
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

long long gcd(long long x, long long y) {
	return y ? gcd(y, x % y) : x;
}

int main() {
	int n; cin >> n;
	long long t, ans = 1;
	for (int i = 0; i < n; ++i) {
		cin >> t;
		ans = ans / gcd(ans, t) * t;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
// initial x=l:	l->(x + d)repeat -> r
	//magic point |x - i| + |y - j| when (x, y)<-(i, j) 
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt(), d = sc.nextInt();
		int p[][] = new int[h * w + 1][2];
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				int a = sc.nextInt();
				p[a][0] = i;
				p[a][1] = j;
			}
		}
		int dis[] = new int[h * w + 1];
		for(int i = d + 1; i < h * w + 1; ++i) {
			dis[i] = dis[i - d] + Math.abs(p[i][0] - p[i - d][0]) + Math.abs(p[i][1] - p[i - d][1]);
		}
		int q = sc.nextInt(), ans = 0;
		for (int i = 0; i < q; ++i) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			ans = dis[r] - dis[l];
			System.out.println(ans);
		}
		sc.close();
	}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> s(5, 0);
	vector<char> march = {'M', 'A', 'R', 'C', 'H'};
	rep(i, n){
		string tmp;
		cin >> tmp;
		rep(j, 5){
			if(tmp[0] == march[j]) s[j]++;
		}
	}
	ll ans = 0;
	for(int bit = 0; bit < (1 << 5); bit++){
		int digit = 0;
		ll sum = 1;
		for(int i = 0; i < 5; i++){
			if(bit & (1 << i)){
				digit++;
				sum *= s[i];
			}
		}
		if(digit == 3) ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N, M; cin >> N >> M;
  vector<int> P(M), Y(M);

  rep(i, M) {
    cin >> P[i] >> Y[i], --P[i];
  }

  vector<vector<int>> vals(N);
  for (int i = 0; i < M; i++) {
    vals[P[i]].push_back(Y[i]);
  }

  rep(i, N) {
    sort(vals[i].begin(), vals[i].end());
  }

  rep(i, M) {
    int v = P[i];
    printf("%06d", v + 1);
    int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
    printf("%06d\n", id + 1);
  }
  
}


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

typedef long long ll;

int main(void){
  int n;
  //cout << n << endl;
  while(cin >> n,n){
    int count = 0;
    int state = 0;
    rep(i,n){
      string s;
      cin >> s;
      //cout << s << endl;
      if(s == "lu"){ // +1
    	if(state == 0)
    	  state += 1;
    	else if(state == 2){
    	  state += 1;
    	  count++;
    	}else if(state == 4)
	  state = 3;
      }else if(s == "ru"){ // +2
    	if(state == 0)
    	  state += 2;
    	else if(state == 1){
    	  state += 2;
    	  count++;
    	}else if(state == 5)
	  state = 3;
      }else if(s == "ld"){
	if(state == 3)
	  state += 1;
	else if(state == 5){
	  state = 0;
	  count++;
	}else if(state == 1)
	  state = 0;
      }else if(s == "rd"){
	if(state == 3)
	  state += 2;
	else if(state == 4){
	  state = 0;
	  count ++;
	}else if(state == 2){
	  state = 0;
	}
      }
    }
  cout << count << endl;
}
}



Measured memory_bytes: 3116
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
L, R = map(int, input().split())

p, l = divmod(L, 2019)
q, r = divmod(R, 2019)

if p != q:
  print(0)
else:
  res = 2020
  for x in range(l, r+1):
    for y in range(x+1, r+1):
      res = min(res, x*y%2019)
  print(res)


Measured memory_bytes: 12492
#include <stdio.h>

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


Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int day, sumptn = 0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] plan = new int[N];
		int[][] pattern = new int[N][6];
		for(int i = 0; i < K; i++) {
			day = sc.nextInt();
			plan[day-1] = sc.nextInt();
			}
		if(plan[0] == 0) {
			for(int i = 0; i < 3; i++) pattern[0][i] = 1;
		}
		else pattern[0][plan[0]-1] = 1;
		
		for(int i= 1; i < N; i++) {
			for(int k = 0; k < 6; k++) sumptn += pattern[i-1][k]%10000;
				if(plan[i] == 0) {
					for(int j = 0; j < 6; j++) {
					if(j<3) pattern[i][j] = (sumptn-pattern[i-1][j]-pattern[i-1][j+3])%10000;
					else pattern[i][j] = pattern[i-1][j-3];
					}
				} else if(plan[i] == 1){
					pattern[i][0] = (sumptn-pattern[i-1][0]-pattern[i-1][3])%10000;
					pattern[i][3] = pattern[i-1][0];
				} else if(plan[i] == 2) {
					pattern[i][1] = (sumptn-pattern[i-1][1]-pattern[i-1][4])%10000;
					pattern[i][4] = pattern[i-1][1];
				} else if(plan[i] == 3) {						
					pattern[i][2] = (sumptn-pattern[i-1][2]-pattern[i-1][5])%10000;
					pattern[i][5] = pattern[i-1][2];
				}
				sumptn = 0;
				if(i == N-1) for(int k = 0; k < 6; k++) sumptn += pattern[N-1][k]%10000;
		}
		System.out.println(sumptn%10000);
	}
}

Measured memory_bytes: 19752
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	double ans = 0.0;
	for(int i = 0; i < n; ++i) {
		double x;
		string s;
		cin >> x >> s;
		
		if( s == "JPY" ) ans += x;
		else ans += x * 380000.0;
	}
	
	printf("%.10f\n", ans);
	
	return 0;
}


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

int main(){
int N,L;
  cin >> N >> L;
  int a=N*(N+1)/2+N*(L-1);
  if(L>0){
    cout << a-L << endl;
    }
  if(L<=0&&-1*N<L){
    cout << a << endl;
  }
   if(L<=-1*N){
    cout << a-L-N+1 << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define N 101000

using namespace std;

int f[N];
long long dis[N];

int find (int x)
{
	if (f[x] != x)
	{
		int tmp = f[x];
		f[x] = find(f[x]);
		dis[x] += dis[tmp];
	}
	return f[x];
}

bool Union (int a,int b,int c)
{
	int A = find(a);
	int B = find(b);
	if (A == B)
		return dis[b]-dis[a] == c;
	f[B] = A;
	dis[B] = dis[a]+c-dis[b];
	return true;
}

int main()
{
	int n,m,a,b,c;
	
	scanf ("%d%d",&n,&m);
	
	for (int i=1;i<=n;i++)
	{
		dis[i] = 0;
		f[i] = i;
	}
	bool flag = true;
	for (int i=1;i<=m;i++)
	{
		scanf ("%d%d%d",&a,&b,&c);
		if (flag && !Union (a,b,c))
			flag = false;
	}
	if (flag)
		printf ("Yes\n");
	else
		printf ("No\n");
	return 0;
}


Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
    };
    let mut set = HashSet::new();
    for i in 1i64.. {
        let tmp = (i * a) % b;
        if set.contains(&(tmp)){
            break;
        }
        set.insert(tmp);
    }
    println!(
        "{}",
        if set.contains(&c){
            "YES"
        }else{
            "NO"
        }
    );
}


Measured memory_bytes: 4352
using System;

class Program
{
    static void Main()
    {
        var line = Console.ReadLine();
        var tmp = line.Split(' ');

        var i = byte.Parse(tmp[0]);
        var j = byte.Parse(tmp[1]);

        var ret = i + j;

        if (ret >= 22)
        {
            Console.WriteLine("bust");
            return;
        }

        j = byte.Parse(tmp[2]);

        ret += j;

        if (ret >= 22)
        {
            Console.WriteLine("bust");
            return;
        }

        Console.WriteLine("win");
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

double sum = 0.0;
int n, a[100];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += 1.0 / (double)a[i];
	}
	sum = 1.0 / (double)sum;
	cout << setprecision(10) << sum << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

arr = [0] * N
cnt = 0

R = 0
res = -1
for i in range(N-1):
    if S[i] == "R":
        R += 1
        res += 1
    if S[i+1] == "L":
        arr[i+1] += R // 2
        arr[i] += -(-R // 2)
        R = 0
        cnt = max(cnt, res)
        res = -1

L = 0
res = -1

for i in range(N-1,0,-1):
    if S[i] == "L":
        L += 1
        res += 1
    if S[i-1] == "R":
        arr[i-1] += L // 2
        arr[i] += -(-L // 2)
        L = 0
        cnt = max(cnt, res)
        res = -1

print(*arr)

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

int main() {
  //変数の準備
  int N, M, X;
  cin >> N >> M >> X;
  int C[N];
  int A[N][M];
  for ( int i = 0; i < N; i++ ) {
    cin >> C[i];
    for ( int j = 0; j < M; j++ ) {
      cin >> A[i][j];
    }
  }
  
  //ビット演算
  int min = 12000000;
  for ( int i = 0; i < pow(2,N); i++ ) {
    int sum_cost = 0;
    int sum[M];
    int count = 0;
    for ( int j = 0; j < M; j++ ) {
      sum[j] = 0;
    }
    for ( int j = 0; j < N; j++ ) {
      if( (i & (1 << j)) ) {
        for ( int k = 0; k < M; k++ ){
          sum[k] += A[j][k];
        }
          sum_cost += C[j]; 
      }
    }
    
    for ( int j = 0; j < M; j++ ) {
      if ( sum[j] >= X ) {
        count++;
      }
    }
    if ( count == M && sum_cost < min ) {
      min = sum_cost;
    }
  }
  
  if ( min != 12000000 ) {
    cout << min << endl;
  } else {
    cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	string s;
	
	cin >> n >> s;
	
	if(n & 1){
		cout << "No" << endl;
		return 0;
	}
	
	string a = "", b = "";
	
	for(int i = 0; i < n / 2; i++){
		a += s[i];
		b += s[i + n / 2];
	}
	
	if(a == b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
    static void Main () {
        var a = int.Parse (Console.ReadLine ());
        var b = int.Parse (Console.ReadLine ());
        var h = int.Parse (Console.ReadLine ());

        Console.WriteLine((a + b) * h / 2.0);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int t = scanner.nextInt();
		
		int ans = x-t;
		if (ans<0) {
			ans=0;
		}
		System.out.println(ans);
		scanner.close();
	}

}

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

#define PI 3.141592653589793238462643383279502L

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double angle_h = (360.0 / 12.0 * h) + (360.0 / 12.0 * m / 60.0);
  double rad_h = angle_h * M_PI / 180;
  double xh = a * cos(rad_h);
  double yh = a * sin(rad_h);

  double angle_m = 360.0 / 60.0 * m;
  double rad_m = angle_m * M_PI / 180;
  double xm = b * cos(rad_m);
  double ym = b * sin(rad_m);
  double ans = sqrt(pow(xh - xm, 2) + pow(yh - ym, 2));

  // cout << ans << endl;
  // cout.precision(20);
  // cout << ans << endl;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3972
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=50;

int len;char s[maxn+5];

int main()
{
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	scanf("%s",s+1);len=strlen(s+1);
	for (int i=1;i<=len-8;i++) putchar(s[i]);
	return putchar('\n'),0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;
  
int a[4];
int c[8];
int k;
  
int calc(){
    int op = c[k++];
    int ret = 0;
    if(op >= 0){
        ret = op;
    }
    else if(op >= -3){
        int x = calc();
        int y = calc();
        if(op == -1){
            ret = x + y;
        }
        else if(op == -2){
            ret = x - y;
        }
        else{
            ret = x * y;
        }
    }
    else{
        throw 0;
    }
    return ret;
}
  
void print(){
    int op = c[k++];
    if(op >= 0){
        printf("%d", op);
    }
    else{
        char ch;
        if(op == -1){ ch = '+'; }
        else if(op == -2){ ch = '-'; }
        else{ ch = '*'; }
  
        putchar('(');
        print();
        printf(" %c ", ch);
        print();
        putchar(')');
    }
}

const int bnum = 40;
  
void solve(int i, int S, int oprem, int numrem){
    if(i == 6){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[6] = a[j];
            }
        }
        try{
            k = 0;
            if(calc() == 10 && k == 7){
                k = 0;
for(int j=0;j<bnum;++j)putchar('(');
                print();
for(int j=0;j<=bnum;++j)putchar(')');
                puts("");
                throw "";
            }
        }catch(int){}
        return;
    }
  
    if(oprem > 0){
        for(int op = -1; op >= -3; --op){
            c[i] = op;
            solve(i + 1, S, oprem - 1, numrem + 1);
        }
    }
  
    if(numrem > 0){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[i] = a[j];
                solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
            }
        }
    }
}
  
int main(){
    while(1){
        for(int i = 0; i < 8; ++i){
            c[i] = -9;
        }
        for(int i = 0; i < 4; ++i){
            scanf("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
        try{
            solve(0, 15, 3, 0);
            puts("0");
        }catch(...){}
    }
}

Measured memory_bytes: 1128
#include<iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(){
  ll n,ans=1,tmp;
  string lr;
  string s;
  cin >> n>> s;
  ll lsum[n*2],rsum[2*n];
  fill(lsum,lsum+2*n,0);
  fill(rsum,rsum+2*n,0);
  if(s[0]=='W'||s[2*n-1]=='W'){
    cout << "0\n";
    return 0;
  }
  lsum[0]=1;
  for(int i=1;i<=n*2;i++){
    lsum[i]=lsum[i-1];
    rsum[i]=rsum[i-1];
    if(i%2==0){
      if(s[i]=='W'){
        rsum[i]++;
        lr+="r";
      }else{
        lsum[i]++;
        lr+="l";
      }
    }else{
      if(s[i]=='W'){
        lsum[i]++;
        lr+="l";
      }else{
        rsum[i]++;
        lr+="r";
      }
    }
  }
  if(rsum[n*2-1]!=lsum[n*2-1]){
    cout <<"0\n";
    return 0;
  }
  for(int i=0;i<n*2;i++){
    if(lr[i]=='r'){
      ans *= (lsum[i]-rsum[i]);
      ans %= MOD;
    }
  }
  for(int i=1;i<=n;i++){
    ans *= i;
    ans %= MOD;
  }

  cout << ans<<endl;
}


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

int main() {
  long n,x,y;
  cin >> n >> x >> y;
  vector<int> ans(n-1);

  for(long i=1;i<=n;i++) {
    for(long j=i+1;j<=n;j++) {
      if(i<=x&&j<=x) ans[j-i-1]++;//iがx以下、jがx以下
      else if((i>x&&i<y)&&(j>x&&j<y)) ans[min(j-i,(i-x)+(y-j)+1)-1]++;//x<i<y,x<j<y
      else if(i<=x&&(j>x&&j<y)) ans[min(j-i,(x-i)+(y-j)+1)-1]++;//iがx以下、x<j<y
      else if((i>x&&i<y)&&j>=y) ans[min(j-i,(j-y)+(i-x)+1)-1]++;//x<i<y,jがy以上
      else if(i>=y&&j>=y) ans[j-i-1]++;//iがy以上、jがx以上
      else if(i<=x&&j>=y) ans[j-i-(y-x-1)-1]++;//iがx以下、jがy以上
    }
  }

  for(int i=0;i<n-1;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
function main(input) {
  const tmp = input.trim().split(' ')
  const a = parseInt(tmp[0], 10)
  const b = parseInt(tmp[1], 10)

  let answer = Math.max(a + b, a - b, a * b)
  if (answer == 0) {
    console.log(0)
  } else {
    console.log(answer)
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29612
#include<stdio.h>
int main()
{
  int i, j, tmp;
  int a[1024];

  scanf("%d %d %d", &a[0], &a[1], &a[2]);

 for (i=0; i<3; ++i) { 
    for (j=i+1; j<3; ++j) { 
      if (a[i] > a[j]) { 
        tmp =  a[i]; 
        a[i] = a[j]; 
        a[j] = tmp; 
      } 
    } 
  } 

  printf("%d %d %d\n", a[0], a[1], a[2]);

  return 0;
}

Measured memory_bytes: 1800
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

int a, b;
string s;

int main()
{
    cin >> a >> b;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (i == a) {if (s[i] != '-'){ printf("No\n"); return 0;}}
        else {
            if (s[i] - '0' < 0 || s[i] - '0' > 9) { printf("No\n"); return 0;}
        }
    }
    printf("Yes\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n,k;cin>>n>>k;
  vector<int> x(n);rep(i,n) cin>>x[i];
  int ans = 0;
  rep(i,n) ans += min(x[i]*2, (k-x[i])*2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

int main() {
  ll n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll tmp = 0;
  ll sum = 0;
  for (int i = 1; i < n; i++) {
    // if (i == 1) cout << a[0] << endl;
    // cout << a[i] << " ";
    if (a[i-1] > a[i]) {
      tmp = a[i-1] - a[i];
      a[i] += tmp;
      sum += tmp;
    }
    // cout << "After: " << a[i] << endl;
  }
  ll ans = sum;
  cout << ans << endl;
  return 0;
}

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

int main()
{
	long long n, m = 0;
	long long a, b, c, d, e;

	cin >> n >> a >> b >> c >> d >> e;

	m = min({ a, b, c, d, e });

	cout << (n + m - 1) / m + 4 << endl;

	return 0;
}


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

int rec[55], tmp[55], cur[55];
int n, ans;

void dfs(int i) {
	if (i == n) {
		memcpy(tmp, cur, sizeof tmp);
		sort(tmp, tmp+n);
		int mx = 24;
		for (int i = 0, j = n-1; i < n; j = i++) {
			int t = abs(tmp[i] - tmp[j]);
			mx = min(mx, min(t, 24 - t));
		}
		ans = max(ans, mx);
		return;
	}
	for (int j = -1; j < 2; j += 2) {
		cur[i] = rec[i] * j;
		dfs(i+1);
		if (!rec[i] || rec[i] == 12) {
			break;
		}
	}
}

int main() {
	scanf("%d", &n);
	if (n > 23) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", rec+i);
	}
	n++;
	cur[1] = rec[1];
	dfs(2);
	printf("%d", ans);
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<double> P;

#define EQ(x,y) (abs((x)-(y))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real())&&EQ((a).imag(),(b).imag()))

double cross(P a, P b) {
	return a.real()*b.imag()-a.imag()*b.real();
}

int is_point_on_ls(P a, P b, P c) {
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

int is_intersection_ls(P a1, P a2, P b1, P b2) {
	if((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < -EPS) &&
		(cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < -EPS))
		return true;
	else 
		return false;
}

P intersection_ls(P a1, P a2, P b1, P b2) {
	P b = b2-b1;
	double d1 = abs(cross(b, a1-b1));
	double d2 = abs(cross(b, a2-b1));
	double t = d1/(d1+d2);

	return a1+(a2-a1)*t;
}

typedef vector<P> vp;

int main() {
	int n;
	while(cin >> n, n) {
		vector<vp> ps(n, vp(2));
		double x, y;
		REP(i, n) {
			REP(j, 2) {
				cin >> x >> y;
				ps[i][j] = P(x, y);
			}
		}

		int ans = 1;
		REP(i, n) {
			ans++;
			vp cp;
			REP(j, i) {
				if(is_intersection_ls(ps[i][0], ps[i][1], ps[j][0], ps[j][1])) {
					P p = intersection_ls(ps[i][0], ps[i][1], ps[j][0], ps[j][1]);
					int size = cp.size();
					bool exist = false;
					REP(k, size) {
						if(EQV(p, cp[k])) {
							exist = true;
							break;
						}
					}
					if(!exist) {
						cp.push_back(p);
						ans++;
					}
				}
			}
		}

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

Measured memory_bytes: 1240
#include<iostream>
#define INF 1<<28
using namespace std;

int p[1111111];
int memo[1111111];
int memo2[1111111];

int solve(int n){
  
  if(!n) return 0;
  if(memo[n]) return memo[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(n-p[i] >= 0) ans = min(ans, solve(n-p[i])+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(memo2[n]) return memo2[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(n-p[i] >= 0 && p[i]&1) ans = min(ans, solve2(n-p[i])+1);

  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  for(int i=0;i<200;i++) p[i] = i*(i+1)*(i+2)/6;
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;

}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 674;
int a[template_array_size];
int b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;

ll dp[100005];

void solve(int tc = 0) {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i <= k; ++i) dp[i] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = k - a[i]; j >= 0; --j) {
			dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
		}
	}
	
	ll ans = 0;
	for (int i = 0; i <= k; ++i) ans = max(ans, dp[i]);
	cout << ans << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("cowland");
	#endif
	
	// usaco("cowland");
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  ll ans = 0;

  for (int b = 1; b <= n; b++) {
    ans += (n / b) * max(0,(b-k));
    ans += max(0, (n % b) - k + 1);
  }
  if (k == 0) {
    ans-=n;
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = Long.parseLong(scanner.next());
        long k = Long.parseLong(scanner.next());
        System.out.println(Math.min(n%k, Math.abs(k-n%k)));
    }
}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    L = LI()

    cnt = 0
    for (i, j, k) in comb(range(N), r=3):
        if i == j or j == k or k == i:
            continue
        tmp = sorted([L[i], L[j], L[k]])
        if tmp[0] == tmp[1] or tmp[1] == tmp[2] or tmp[2] == tmp[0]:
            continue
        if tmp[0] + tmp[1] > tmp[2]:
            # print(i, j, k)
            cnt = cnt + 1
    print(cnt)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9272
main = do
    [s, t] <- words <$> getLine :: IO [String]
    [si,ti] <- map read . words <$> getLine  :: IO [Int]
    u <- getLine :: IO String
    putStr $ show $ if u == s then si - 1 else si
    putChar ' '
    putStrLn $ show $ if u == t then ti - 1 else ti

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

int main(){
  int N; cin >> N;
  int d[N]; REP(i,N){cin >> d[i];}
  int r = 0;
  REP(i,N){
    REP(j,i){
      r += d[i]*d[j];
    }
  }
  cout << r << '\n';
}
  

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

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;
    cin >> n;
    vector<ll> arr;
    arr = read(n);

    j = 0;
    i = 1;
    ll ans = 0;
    while (j<n){
        while(j<n && arr[j]!=i){
            ans++;
            j++;
        }
        if(j!=n){
            i++;
            j++;
        }
    }

    if(i==1){
        cout<<-1;
    } else{
        cout<<ans;
    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 4824
def sort(array)
	a = array
	b = []
	c = []
	k = a.max
	
	##all elements of array c equal to 0
	for i in 0..k
		c[i] = 0
	end
	##insert +1 to c[element of array a]
	a.each do |el|
		c[el] = c[el] + 1
	end 
	#array c now contains the number of elements of array a
	##add the number of previous element starting from c[1]
	for i in 1..k
		c[i] = c[i] + c[i-1]
	end

	for j in (a.length-1).downto(0)
		b[c[a[j]]] = a[j]
		c[a[j]] = c[a[j]]-1
	end
	b.shift
	puts b.join(" ")
end

#input
n = gets.chomp
n = gets.chomp
n = n.split().map(&:to_i)

#output
sort(n)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll N, K;
vector<ll> C;
vector<bool> seen; 
ll loop = 0;
ll t_counter = 0;

void dfs(const Graph &G, int v, int counter) {
    seen[v] = true;
    C[v] = counter;
    for (auto next_v : G[v]) { 
        if (seen[next_v]){
            loop = counter+1 - C[next_v];
            t_counter = counter+1;
        }
        else{
            dfs(G, next_v, counter+1); // 再帰的に値を追加していく
        }
    }
}

void dfs2(const Graph &G, int v, int counter, bool check) {
    if(counter == K){
        cout << v + 1 << endl;
        check = false;
    }
    for (auto next_v : G[v]) { 
        if (check){
            dfs2(G, next_v, counter+1, check); // 再帰的に値を追加していく
        }
    }
}
int main()
{
    cout << fixed << setprecision(15);
    cin >> N >> K;

    vector<ll> A(N);

    // グラフ
    Graph G(N);
    seen.assign(N, false);
    C.assign(N, 0);

    REP(i, N){
        // cout << i << endl;
        ll a;
        cin >> a;
        G[i].push_back(a-1);
        // cout << i << endl;
    }
    dfs(G,0,0);

    // cout << "loop: " << loop << endl;
    // cout << "tcounter: " << t_counter << endl;
    ll s = (K-N)/loop;
    if(s > 0){
        K = K - loop*s;
    }
    dfs2(G,0,0,true);

    return 0;
}

Measured memory_bytes: 29796
import sys
import heapq
from collections import defaultdict as dd
input = sys.stdin.readline
W, H = map(int, input().split())
pq = []
for _ in range(W): pq.append((int(input()), 0))
for _ in range(H): pq.append((int(input()), 1))
pq.sort(key = lambda x: -x[0])
a = W + 1
b = H + 1
res = 0
for _ in range(W + H):
  x = pq.pop()
  #print(x)
  if x[1]:
    b -= 1
    res += a * x[0]
  else:
    a -= 1
    res += b * x[0]
  #print(res)
print(res)

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

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i = a; i < b; i++)

#define PB push_back

#define MOD 1000000007LL
typedef long long ll;

	int n;
int a[321][321];
int sm[321][321];

int cnt(int x1, int x2, int y1, int y2){
	return sm[x2][y2]-sm[x1][y2]-sm[x2][y1]+sm[x1][y1];
}

inline int gt(int i, int j, int k, int l){
	int a = cnt(i, j, k, l), b = 0;
	if(j-i>=3 && l-k>=3){
		b = cnt(i+1, j-1, k+1, l-1);
		// printf("*");
	}
	// printf("   gt(%d, %d, %d, %d)=%d-%d=%d\n", i, j, k, l, a, b, a-b);
	return a-b;
}
int solve(){
	int ans = 0;
	REP(i, n+1){
		FOR(j, i+1, n+1){
			REP(k, n+1){
				FOR(l, k+1, n+1){
					int a = cnt(i, k, j, l), b = 0;
					if(j-i>=3 && l-k>=3){
						b = cnt(i+1, k+1, j-1, l-1);
						// printf("*");
					}
					int x = a-b;
					// printf("(%d %d) (%d %d) : %d-%d=%d\n", i, k, j, l, a, b, x);
					if(ans<x) ans=x;
				}
			}
		}
	}
	return ans;
}
#define LAR(a, b) a=max(a, (b))

int main(){
	scanf("%d", &n);
	REP(i, n) REP(j, n) scanf("%d", a[i]+j);
	REP(i, n) sm[i][0]=sm[0][i]=0;
	REP(i, n){
		REP(j, n){
			sm[i+1][j+1]=sm[i][j+1]+sm[i+1][j]-sm[i][j]+a[i][j];
		}
	}
	// REP(i, n+1){
	// 	REP(j, n+1){
	// 		printf("%d ", sm[i][j]);
	// 	}
	// 	printf("\n");
	// }

	int ans = INT_MIN;
	REP(i, n){
		FOR(j, i+1, n+1){
			int nwsm = 0,
					mxsm = 0,
					mxid = 0;
			int mxans = INT_MIN;
			FOR(l, 1, n+1){
				LAR(mxans, gt(i, j, l-1, l));
				if(l>=3){
					nwsm -= cnt(i, j, l-3, l-2);
					// printf("  -(%d,%d,%d,%d)=%d\n", i,j,l-3,l-2, cnt(i, j, l-3, l-2));
					if(j-i >= 3){
						nwsm += cnt(i+1, j-1, l-2, l-1);
						// printf("  +(%d,%d,%d,%d)=%d\n", i+1, j-1, l-2, l-1, 
								// cnt(i+1, j-1, l-2, l-1));
					}
					if(mxsm < nwsm){
						mxsm = nwsm;
						mxid = l-2;
					}
				}
				LAR(mxans, gt(i, j, mxid, l));
				// printf(" %d-%d:%d %d\n", mxid, l, mxans, nwsm);
			}
			LAR(ans, mxans);
			// printf("%d %d : %d\n", i, j, mxans);
		}
	}
	printf("%d\n", ans);
	// printf("%d\n", solve());
}

Measured memory_bytes: 3988
h, w = map(int,input().split())

li = []

for i in range(h):
  wi = input()
  if wi.count('#') > 0:
    li.append(wi)

ans = [[0 for i in range(w)] for j in range(len(li))]
  
for i in range(w):
  line = []
  for j in range(len(li)):
    line.append(li[j][i])
  if line.count('#') != 0:
    for j in range(len(li)):
      ans[j][i] = line[j]

for i in ans:
  a = []
  for j in i:
    if j != 0:
      a.append(j)
  print(''.join(a))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

int b(void);
int c(void);

int main(void) {
	b();
	return 0;
}

int c(void) {
	long long int N;
	std::cin >> N;
	long long int up_b = static_cast<long long int>(std::sqrt(N));
	long long int max_i = 0;
	for (int i = up_b; i > 0; i--) {
		if (N % i == 0) {
			max_i = i;
			break;
		}
	
	}
	std::cout << max_i << std::endl;
	std::cout << N / max_i << std::endl;
	std::cout << max_i + (N / max_i) -2;
	return 0;
}

int b(void) {
	int N;
	std::cin >> N;
	if (N > 81) {
		std::cout << "No";
		return 0;
	}
	else {
		for (int i = 1; i < 10; i++) {
			if (N % i == 0 && N / i < 10) {
				
				std::cout << "Yes";
				return 0;
			}
		}
	}
	std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
    if(ans > 1000000000000000000):
        if 0 in A:
            print("0")
            quit()
        else:
            print("-1")
            quit()
print(ans)

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long all = 1, odd = 1;
  for (int i = 0; i < n; i++) {
    all *= 3;
    int a;
    scanf("%d", &a);
    if ((a & 1) == 0)
      odd *= 2;
  }
  cout << all - odd << endl;
  return 0;
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
typedef long double ld;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}

ll fun(ll n, vector<ll>&v, vector<ll>&arr,ll h,ll i,ll sum,vector< vector<ll> >&dp)
{
    if(sum>=h)
    {
        return 0ll;
    }
    if(i==n)
    {
        return 1e10;
    }
    if(dp[i][sum]!=-1)
    {
        return dp[i][sum];
    }
    ll ans=1e18;
    ans=min(ans,arr[i]+fun(n,v,arr,h,i,sum+v[i],dp));
    //ans=min(ans,arr[i]+fun(n,v,arr,h,i+1,sum+v[i]));
    ans=min(ans,fun(n,v,arr,h,i+1,sum,dp));
    return dp[i][sum]=ans;
}
int main()
{
fast;
ll h;
ll n;
cin>>h>>n;
vector<ll>v;
vector<ll>arr;
for(ll i=0;i<n;i++)
{
    ll a,b;
    cin>>a>>b;
    v.pb(a);
    arr.pb(b);
}
vector< vector<ll> >dp(n, vector<ll>(h+1,-1));
ll ans=fun(n,v,arr,h,0,0,dp);
cout<<ans<<endl;


return 0;
}


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


int main() {
    string a,b;
    cin >> a >> b;

    int n = stoi(a+b);

    bool heho = false;

    for(int i=1;i<1000;i++){
        if(i*i==n) heho=true;
    }

    if(heho) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256