akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vll a(N), u(N-1), v(N-1);
    rep(i, N) cin >> a[i];
    rep(i, N-1) cin >> u[i] >> v[i];
    vector<unordered_set<ll>> path(N);
    rep(i, N-1){
        path[u[i]-1].insert(v[i]-1);
        path[v[i]-1].insert(u[i]-1);
    }

    vll t(N+1, LLONG_MAX);
    vll res(N, 0);
    vll c(N, 0);

    function<void(ll)> solve = [&](ll idx){
        if(c[idx]) return;
        c[idx] = 1;
        auto it = lower_bound(all(t), a[idx]);
        ll tmp = *it;
        *it = min(*it, a[idx]);
        auto it2 = lower_bound(all(t), LLONG_MAX);
        ll nlis = distance(t.begin(), it2);
        res[idx] = nlis;
        for(ll next : path[idx]){
            solve(next);
        }
        *it = tmp;
    };
    solve(0);

    rep(i, N){
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 53428
#include<stdio.h>
#include <cmath>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int N;
	int A[105][2];
	memset(A, 0, sizeof(A));
	scanf("%d", &N);
	for (int i = 0;i < N;i++)
	{
		scanf("%d", &A[i][0]);
		if(i!=0)A[i][0] += A[i - 1][0];
	}
	for (int i = 0;i < N;i++)
		scanf("%d", &A[i][1]);
	for (int i = N - 1;i >= 0;i--)
		A[i][1] += A[i + 1][1];
	int max = 0, sum = 0;
	for (int i = 0;i < N;i++)
	{
		sum = A[i][0] + A[i][1];
		if (sum > max)max = sum;
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
import itertools

K = int(input())

keta_list = [['1', '2', '3', '4', '5', '6', '7', '8', '9']]
keta = 1
count = len(keta_list[0])

def create_lunlun():
    global keta
    global keta_list
    global count

    base_num = keta_list[keta - 1]

    new_keta_list = []

    for num in base_num:
        if num[-1] >= '1' and num[-1] <= '8':
            new_keta_list.append(num + str(int(num[-1])-1))
            new_keta_list.append(num + num[-1])
            new_keta_list.append(num + str(int(num[-1])+1))
        elif num[-1] == '0':
            new_keta_list.append(num + num[-1])
            new_keta_list.append(num + str(int(num[-1])+1))
        else:
            new_keta_list.append(num + str(int(num[-1])-1))
            new_keta_list.append(num + num[-1])

    keta_list.append(new_keta_list)
    keta += 1

    count += len(new_keta_list)
    if count >= 10**5:
        return
    
    create_lunlun()


create_lunlun()

keta_list = list(itertools.chain.from_iterable(keta_list))

print(keta_list[K-1])

Measured memory_bytes: 18932
//#inclde <bits/stdc++.h>
//using namespace std;
#include <iostream>
#include <string>


   // int mokemoke,hogehoge;
   // std::cin >> mokemoke >> hogehoge;
   // std::cout << mokemoke << hogehoge << std::endl;

int main(){

    int N;
    std::cin >> N;
    int S = 0;
    for(int i = 1; i < N + 1; i++){
        S += i;

    }
    std::cout << S << std::endl;


    return 0;
}


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

#define endl '\n'

using namespace std;

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

	int a[ 3 ];
	cin >> a[ 0 ] >> a[ 1 ] >> a[ 2 ];
	sort(a, a + 3);
	cout << a[ 0 ] << ' ' << a[ 1 ] << ' ' << a[ 2 ] << endl;
	return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int n,k,s,t;
long long a[55],ans;
long long c[55][55];
vector<long long> g[22],f[22],one,zero;
long long num[55],ban[55];
long long eval(long long x,long long y)
{
	if (y>x) return 1ll<<x;
	else
	{
		long long res=0;
		for (int i=0;i<=y;i++) res+=c[x][i];
		return res;
	}
}
long long doit(int mask)
{
	map<int,long long> mp;
	for (long long i=1;i<=n;i++)
	{
		if (!ban[i])
		{
			mp[a[i]&mask]++;
		}
	}
	long long res=0;
	for (map<int,long long>::iterator it=mp.begin();it!=mp.end();it++)
	{
		res+=(eval(it->second,k)-1);
	}
	res++;
	return res;
}
int main()
{
	scanf("%d%d%d%d",&n,&k,&s,&t);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		for (int j=0;j<18;j++)
		{
			if (a[i]&(1<<j)) g[j].push_back(i);
			else f[j].push_back(i);
		}
	}
	c[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++)
		{
			c[i][j]=c[i-1][j]+c[i-1][j-1];
		}
	}
	if ((t&s)!=s)
	{
		printf("0\n");
		return 0;
	}
	memset(num,-1,sizeof(num));
	for (int i=0;i<18;i++)
	{
		if (s&(1<<i)) 
		{
			one.push_back(i);
			num[i]=1;
		}
		if ((t&(1<<i))==0) 
		{
			zero.push_back(i);
			num[i]=0;
		}
	}
	for (int i=0;i<18;i++)
	{
		if (num[i]==0)
		{
			for (int j=1;j<=n;j++)
			{
				if (a[j]&(1<<i)) ban[j]=1;
			}
		}
		if (num[i]==1)
		{
			for (int j=1;j<=n;j++)
			{
				if (!(a[j]&(1<<i))) ban[j]=1;
			}
		}
	}
	for (int i=0;i<(1<<18);i++)
	{
		bool fuck=1;
		for (int j=0;j<18;j++)
		{
			if ((i&(1<<j)) && num[j]!=-1) fuck=0;
		}
		if (!fuck) continue;
		if (__builtin_popcount(i)&1) ans-=doit(i);
		else ans+=doit(i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3760
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double v = sc.nextDouble();
        double height = v / (a * a);
        double max = height* 2 - b;
        if(max >= 0){
            double rResult = (Math.PI/ 2) - Math.atan2(a, b-max);
            double result = rResult * 180.0 / Math.PI;
            System.out.println(result);
        }else{
            double p = 2 * v / ( a * b );
            double rResult = Math.atan2(b, p);
            double result = rResult * 180.0 / Math.PI;
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
char A[4];
int flag[4];
int K;
int main()
{
    while(scanf("%s",A)!=EOF)
    {
        K=1;
        memset(flag,0,sizeof(flag));
        for(int i=0;i<3;i++)
        {
            int temp=A[i]-'a';
            if(temp>3||temp<0)
            {
                K=0;
                break;
            }
            else
                flag[temp]=1;
        }
        for(int i=0;i<3;i++)
        {
            if(flag[i]!=1)
            {
                 K=0;
                break;
            }
        }
        if(K) printf("Yes\n");
            else
            printf("No\n");
    }
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main(){
 int X,Y;
 int ans = 0;
  
 cin >> X >> Y;
   
 if(X == 1)ans+=3; 
 if(X == 2)ans+=2;   
 if(X == 3)ans+=1; 
 if(Y == 1)ans+=3; 
 if(Y == 2)ans+=2; 
 if(Y == 3)ans+=1;   
  
 if(X+Y==2)ans+=4;
  
 cout << ans * 100000 ;
return 0;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = Integer.parseInt(sc.next());
		//色の入力
		String c = sc.next();
		char[] C = new char[N];
		for (int i = 0; i < N; i++) {
			C[i] = c.charAt(i);
		}
		//赤だったら1、白だったら0で
		int[] nC = new int[N];
		for(int i=0;i<N;i++) {
		if(C[i]=='R') {
			nC[i]=1;
		}else {
			nC[i]=0;
		}
		}
		//左から白を探す→その白より右側に赤がある場合、一番右側にある赤とその白を入れ替える
		int check = 0;
		for (int j = 0; j < N/2; j++) {
			//白を検索
			int wn = N;//ホワイトナンバー
			for (int i = j; i < N; i++) {
				if (nC[i] == 0) {
					wn = i;
					break;
				}
			}
			//赤を探す
			int rn = N;//レッドナンバー
			for (int i = N - 1 - j; i >= 0; i--) {
				if (nC[i] == 1) {
					rn = i;
					break;
				}
			}
			//白と赤の場所比較して、場所入れ替え
			if (wn < rn && !(wn == 0 && rn == N)) {
				nC[wn] = 1;
				nC[rn] = 0;
				check++;
			}else {
				break;
			}
		}
		//

		System.out.println(check);
	}

}


Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char X, Y;
  cin >> X >> Y;
  int x, y;
  
  if(X == 'A'){
    x = 10;
  }
  if(X == 'B'){
    x = 11;
  }
  if(X == 'C'){
    x = 12;
  }
  if(X == 'D'){
    x = 13;
  }
  if(X == 'E'){
    x = 14;
  }
  if(X == 'F'){
    x = 15;
  }
  
  if(Y == 'A'){
    y = 10;
  }
  if(Y == 'B'){
    y = 11;
  }
  if(Y == 'C'){
    y = 12;
  }
  if(Y == 'D'){
    y = 13;
  }
  if(Y == 'E'){
    y = 14;
  }
  if(Y == 'F'){
    y = 15;
  }
  
  if(x == y){
    cout << '=';
  }
  if(x < y){
    cout << '<';
  }
  if(x > y){
    cout << '>';
  }
}

  
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int r, n, m;

int main(){
	while(cin >> r >> n, r){
		vi hi(100, 0);
		REP(i, n){
			int l, r, h;
			cin >> l >> r >> h;
			for(int j=(l+20)*2+1;j<=(r+20)*2;j++) hi[j] = max(hi[j], h);
		}
		double ans = 1e9;
		REP(i, 100){
			int x = abs((i/2)-20);
			if(x < r) ans = min(ans, r - (sqrt(r*r-x*x) - hi[i]));
		}
		printf("%.11f\n", ans);
	}
}

Measured memory_bytes: 1208
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
   input! {
       mut s: chars,
   }

    s.reverse();
    let d = 1000000007;
   let mut dp = vec![0; 13];

   if s[0] == '?' {
     for i in 0..10 {
         dp[i] = 1;
     } 
   } else {
       let num = s[0].to_digit(10).unwrap() as usize;
       dp[num] = 1;
   }
    let mut mult = 10;
   for i in 1..s.len() {
       let mut next_dp = vec![0; 13];
       if s[i] == '?' {
           for j in 0..13 {
               for k in 0..10 {
                next_dp[(mult*k+j) % 13] =  next_dp[(mult*k+j) % 13] + dp[j];
                next_dp[(mult*k+j) % 13] =  next_dp[(mult*k+j) % 13] % d;
            }
           }
       } else {
           let num = s[i].to_digit(10).unwrap() as usize;
            for j in 0..13 {
                next_dp[(mult*num+j) % 13] =  next_dp[(mult*num+j) % 13] + dp[j];
                next_dp[(mult*num+j) % 13] =  next_dp[(mult*num+j) % 13] % d;
            }
       }
       
       for i in 0..13 {
           dp[i] = next_dp[i];
           dp[i] = dp[i] % d;
       }
       mult = mult * 10 % 13;
   }

   println!("{}", dp[5]);


}



Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d =0; d < 10; d++) {
						if (a + b + c + d == n) {
							ans++;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  priority_queue<P, vector<P>, greater<P>> ls, rs;
  vector<int> cnt(32, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = a; j <= b; j++) cnt[j] = 1;
    ls.push({a, b});
  }

  int y = 0, z = 0;
  for (int i = 1; i <= 31; i++) {
    while (!ls.empty()) {
      auto p = ls.top();
      int l = p.first;
      int r = p.second;
      if (i < l || r < i) break;
      ls.pop();
      rs.push({r, l});
    }
    int ytmp = 0;
    while (!rs.empty()) {
      auto p = rs.top(); rs.pop();
      int r = p.first;
      int l = p.second;
      if (i < l || r < i) continue;
      ytmp++;
      break;
    }
    y += ytmp;
  }
  z = accumulate(begin(cnt), end(cnt), 0);
  cout << 100 * y + 50 * (z - y) << endl;
  return 0;
}



Measured memory_bytes: 3096
/*
  Contest 061
  B - Counting Roads
  Rakesh Kumar --> 28/08/2020
 */

#include <bits/stdc++.h>

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

    int n = 0, m = 0;
    std::cin >> n >> m;
    std::vector<int> praant(n, 0);
    while (m--) {
        int a = 0, b = 0;
        std::cin >> a >> b;
        ++praant[a - 1];
        ++praant[b - 1];
    }
    for (auto sadake : praant)
        std::cout << sadake << std::endl;

    return 0;
}


Measured memory_bytes: 3624
//AtCoder ABC121 B - Can you solve this?
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,M,C; cin>>N>>M>>C;
    vector<ll> bm(M);
    for(auto&& b:bm){
        cin>>b;
    }
    vector<vector<ll>> anm(N,vector<ll>(M));
    for(auto&& am:anm){
        REP(i,M){
            cin>>am[i];
        }
    }
    ll ans=0;
    REP(n,N){
        ll val=C;
        REP(m,M){
            val+=(anm[n][m]*bm[m]);
        }
        if(val>0)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[101010];
ll n, m;
vector<vector<ll>>to;

ll rec(ll v) {
	if (dp[v] != -1)return dp[v];
	else {
		ll res = 0;
		for (auto nv : to[v]) {
			res = max(res, rec(nv) + 1);
		}
		return dp[v] = res;
	}
}

//long longしか使わない
//素数は1より大きい
int main() {
	cin >> n >> m;
	to.resize(n);
	rep(i, m) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		to[x].push_back(y);
	}
	rep (i, n) {
		dp[i] = -1;
	}
	ll ans = 0;
	rep(i, n) {
		ans = max(ans, rec(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11612
#include<iostream>
using namespace std;
 
int main(){
 	int n,m,p; cin>>n>>m>>p;
  	int a[m]; for(int i=0;i<m;i++) cin>>a[i];
  
  	int j =0;
  	for(int i=0;i<m;i++){
      	if(a[i]<p) j++;
      	else break;
	}
        cout<<min(j,m-j)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int a, b;
    cin >> a >> b;
    cout << ((a <= 9 && b <= 9) ? a * b : -1) << endl;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

div2(x)=div(x,2),mod(x,2)

function main()
    n = parseInt(readline())
    a = parseMap(split(readline()))

    ans = 0
    for i in 1:n
        while true
            a[i], rem = div2(a[i])
            if rem == 1 break end
            ans += 1
        end
    end

    println(ans)
end

main()


Measured memory_bytes: 112120
#include<iostream>
#include<string>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int a[10];
    int ta, tb;
    int c = 0;

    for(int i = A; i <= B; i++){
        ta = i;
        for(int j = 0; j < 5; j++){
            a[j] = ta % 10;
            ta /= 10;
        }
        if(a[0]==a[4] && a[1] == a[3])
            c++;    
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3568
n=int(input())
a=[int(i) for i in input().split()]
chk=sum(a)
k=chk//2
k1=k+1
k2=k+2
k3=k-1
k4=k-2
x=y=z=0
for i,j in enumerate(a):
    z=i
    x+=j
    if x>=k:
        break
if x==k and chk%2==0:
    print(0)
else:
    ans=min(abs(x-k)+abs((chk-x)-k),abs(x-k1)+abs((chk-x)-k1),abs(x-k2)+abs((chk-x)-k2),abs(x-k3)+abs((chk-x)-k3),abs(x-k4)+abs((chk-x)-k4))
    x=y=z=0
    for i,j in enumerate(a):
        z=i
        if x+j>=k:
            break
        x+=j
    ans2=min(abs(x-k)+abs((chk-x)-k),abs(x-k1)+abs((chk-x)-k1),abs(x-k2)+abs((chk-x)-k2),abs(x-k3)+abs((chk-x)-k3),abs(x-k4)+abs((chk-x)-k4))
    print(min(ans,ans2))


Measured memory_bytes: 89596
#include <bits/stdc++.h>
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define MOD 1000000007
    #define pii pair<int,int>
    #define LL long long
     
    using namespace std;
     
    int dp[3005][3005];
    string s,t;
    int solve(int a,int b) {
        if (a==0||b==0) return dp[a][b]=0;
        if (dp[a][b]!=-1) return dp[a][b];
        if (s[a-1]==t[b-1]) return dp[a][b]=solve(a-1,b-1)+1;
        else return dp[a][b]=max(solve(a-1,b),solve(a,b-1));
    }
     
    int main () {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        cin >> s >> t;
        memset (dp,-1,sizeof(dp));
        int len=solve(s.size(),t.size());
        /*for (int i=0;i<=s.size();i++) {
            for (int j=0;j<=t.size();j++) {
                cout << dp[i][j] << " ";
                if (dp[i][j]!=-1) cout << " ";
            }
            cout << endl;
        }*/
        string lcs="";
        int a=s.size(),b=t.size();
        while (lcs.size()!=len) {
            if (s[a-1]==t[b-1]) {
                lcs+=s[a-1];
                a--;
                b--;
            } else if (dp[a-1][b]>dp[a][b-1]) {
                a--;
            } else b--;
            //cout << lcs << endl;
        }
        reverse(lcs.begin(),lcs.end());
        cout << lcs << endl;
        return 0;
    }

Measured memory_bytes: 35968
#include<bits/stdc++.h>
	#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
	#define ll          long long
	#define pb          push_back
	#define	endl		'\n'
	#define pii         pair<ll int,ll int>
	#define vi          vector<ll int>
	#define all(a)      (a).begin(),(a).end()
	#define F           first
	#define S           second
	#define sz(x)       (ll int)x.size()
	#define hell        1000000007
	#define rep(i,a,b)	for(ll int i=a;i<b;i++)
	#define lbnd        lower_bound
	#define ubnd        upper_bound
	#define bs          binary_search
	#define mp          make_pair
	using namespace std;

	#define N  1000005

	int main()
	{
		
		io
		ll n,x;
		cin>>n>>x;
		std::vector<ll> a(n);
		rep(i,0,n)
		cin>>a[i];
		sort(all(a));
		ll c=0,cs=0;
		rep(i,0,n)
		{
			cs+=a[i];
			if(i!=n-1 && cs<=x)
				c++;
			else
			{
				if(cs==x)
					c++;
			}
		}
		cout<<c;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define pb push_back
int main()
{
    bool fg=0;
    ll n,m,k,i,j,sum=0,p=0,c=-1;
    cin>>n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3620
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.fi << ", " << p.se << ']';
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
    cout << "{ ";
    for (const auto &v : c)
        cout << v << ' ';
    cout << '}' << ln;
}

struct dsu
{
    v32 par, sz;
    dsu(int n)
    {
        sz.assign(n + 1, 1);
        par.assign(n + 1, 0);
        iota(par.begin(), par.end(), 0);
    }
    int find(int x)
    {
        if (x != par[x])
            return (par[x] = find(par[x]));
        return par[x];
    }
    bool unite(int x, int y)
    {
        int a = find(x);
        int b = find(y);
        if (a != b)
        {
            if (sz[a] < sz[b])
            {
                par[a] = b;
                sz[b] += sz[a];
            }
            else
            {
                par[b] = a;
                sz[a] += sz[b];
            }
            return true;
        }
        else
            return false;
    }
};

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    v32 deg(n + 1, 0), ans(n + 1, 0);
    int u, v;
    dsu D(n);
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        D.unite(u, v);
        deg[u]++;
        deg[v]++;
    }
    for (int i = 1; i < n + 1; i++)
        ans[i] = D.sz[D.find(i)] - 1 - deg[i];
    for (int i = 0; i < k; i++)
    {
        cin >> u >> v;
        if (D.find(u) == D.find(v))
        {
            ans[u]--;
            ans[v]--;
        }
    }
    for (int i = 1; i < n + 1; i++)
        cout << ans[i] << " ";
    return;
}

int main()
{
    FASTIO;
#ifdef file_input
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    clock_t start, stop;
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
#ifdef measure_time
    start = clock();
#endif
    for (int tc = 1; tc < t + 1; tc++)
        solve();
#ifdef measure_time
    stop = clock();
    cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
    return 0;
}


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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]),N=300000+1;
        st=new int[N*4];
        int a[]=new int[N],b,i;
        for(i=0;i<n;i++)
        {
            b=Integer.parseInt(bu.readLine());
            int l=Math.max(b-k,0),r=Math.min(b+k,N-1);
            int m=max(0,N-1,l,r,0)+1;
            updateValue(a,0,N-1,b,m,0);
        }
        int ans=0;
        for(i=0;i<N;i++)
        ans=Math.max(ans,a[i]);
        System.out.print(ans);
    }

    static int st[];
    static int max(int ss,int se,int l,int r,int i)
    {
        if(l<=ss && r>=se) return st[i];
        if(se<l || ss>r) return -1;
        int mid=ss+(se-ss)/2;
        return Math.max(max(ss,mid,l,r,2*i+1),max(mid+1,se,l,r,2*i+2));
    }

    static void updateValue(int a[],int ss,int se,int i,int v,int n)
    {
        if(ss==se)
        {
            a[i]=v;
            st[n]=v;
        }
        else
        {
            int mid=ss+(se-ss)/2;
            if(i>=ss && i<=mid) updateValue(a,ss,mid,i,v,2*n+1);
            else updateValue(a,mid+1,se,i,v,2*n+2);
            st[n]=Math.max(st[2*n+1],st[2*n+2]);
        }
    }
}


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

string str;

int solve() {
    vector<int> v(str.size());
    vector<int> d(str.size());
    for (int i = 0; i < str.size(); i++) {
        int c = str[i] - '0';
        if (i % 2 == 0) {
            v[i] = c + (i ? v[i-1] : 0);
            d[i] = (i ? d[i-1] : 0);
        } else {
            d[i] = c + (i ? d[i-1] : 0);
            v[i] = (i ? v[i-1] : 0);
        }
    }

    vector<int> sum(str.size());
    for (int i = 0; i < str.size(); i++) {
        sum[i] = (11 + (((v[i] - d[i]) % 11))) % 11;
    }

    int m[11] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};;
    int ans = 0;
    for (int i = 0; i < str.size(); i++) {
        ans += m[sum[i]];
        if (i + 1 < str.size() && (str[i+1] - '0') != 0) {
            m[sum[i]]++;
        }
    }

    return ans;
}

int main() {
    while (cin >> str, str != "0") cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 4004
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;
struct Point{
	Point():x(0),y(0){}
	Point(int x,int y):x(x),y(y){}
	int x,y;
};
struct Circle{
	Point p;
	int r;
};
/* _a,b©ç£ÌñæðÔ·Ö */
int DistanceSquared( Point a, Point b ){
	return ( a.x - b.x ) * ( a.x - b.x ) + ( a.y - b.y ) * ( a.y - b.y );
}
/* ¾YASA éÇÌîñ©çA»êçÌÊuÖWªSafe©Danger©²×éÖ */
bool IsSafePlace( Circle c, Point taro, Point dem ){
	double vx1, vy1, vx2, vy2, alpha1, alpha2;
	int seki = ( (taro.x - c.p.x) * ( dem.x - taro.x ) + (taro.y - c.p.y) * (dem.y - taro.y ) );
	int D = seki * seki - DistanceSquared(taro,dem) * ( DistanceSquared(c.p,taro) - c.r * c.r );

	if( D < 0 )
		return false;

	alpha1 = ( -seki - sqrt((double)D) ) / DistanceSquared(taro, dem);
	alpha2 = ( -seki + sqrt((double)D) ) / DistanceSquared(taro, dem);

	vx1 = (taro.x - c.p.x) + alpha1 * ( dem.x - taro.x );
	vy1 = (taro.y - c.p.y) + alpha1 * ( dem.y - taro.y );
	vx2 = (taro.x - c.p.x) + alpha2 * ( dem.x - taro.x );
	vy2 = (taro.y - c.p.y) + alpha2 * ( dem.y - taro.y );

	if( taro.x == c.p.x && taro.y == c.p.y ){
		if( DistanceSquared( taro, dem ) > c.r * c.r )
			return true;
		else
			return false;
	}else if( ( ( vx1 * (taro.y - c.p.y) - vy1 * (taro.x - c.p.x) ) * ( vx1 * (dem.y  - c.p.y) - vy1 * (dem.x - c.p.x) ) > 0 ) &&
		( ( vx2 * (taro.y - c.p.y) - (taro.x - c.p.x) * vy2 ) * ( vx2 * (dem.y  - c.p.y) - (dem.x - c.p.x) * vy2 ) > 0 ) )
		return false;
	else
		return true;
}
int main(void){
	while(true){
		int n, m;
		vector<Circle> vWall;

		cin >> n;
		
		if( n == 0 )
			break;

		for(int i = 0; i < n; ++i){
			Circle tc;
			cin >> tc.p.x >> tc.p.y >> tc.r;
			vWall.push_back( tc );
		}

		cin >> m;

		for(int i = 0; i < m; ++i){
			bool safe = false;
			Point p_taro, p_daemon;
			cin >> p_taro.x >> p_taro.y >> p_daemon.x >> p_daemon.y;

			for( unsigned int j = 0; j < vWall.size(); ++j ){
				if( IsSafePlace( vWall[j], p_taro, p_daemon ) ){
					safe = true;
					cout << "Safe\n";
					break;
				}
			}
			if( !safe ){
				cout << "Danger\n";
			}
		}
	}
}

Measured memory_bytes: 0
building_num = 4
floor_num = 3

m = []
for i in range(building_num):
    building = []
    for j in range(floor_num):
        floor = [0] * 10
        building.append(floor)
    m.append(building)

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    m[b-1][f-1][r-1] += v

delimiter = '#' * 20
for i in range(building_num):
    building = m[i]
    for floor in building:
        for room in floor:
            print(f' {room}', end='')
        print()

    if i != building_num - 1:
        print(delimiter)



Measured memory_bytes: 5632
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define RANDOM srand(time(NULL));

#define MOD 1000000007
#define NAX 1000005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN



int main()
{
    FAST;
    
    ll n;
    cin>>n;

    string str;
    cin>>str;

    ll cnt = 0;
    FOR(i,0,n)
    if(str[i]=='R')
    	cnt++;

    if(cnt>n-cnt)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    int out = 0, score = 0, runner = 0;
    while(out<3){
      string s;
      cin >> s;
      if(s == "HIT"){
    runner++;
    if(runner == 4){
      score++; runner--;
    }
      }else if(s == "HOMERUN"){
    score += runner+1;
    runner = 0;
      }else{
    out++;
      }
    }
    cout << score << endl;
  }
}


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

int main(){
  int N, M;cin>>N>>M;
  int ans=0;
  for (int i=1;i*i<=M;++i){
    if(M%i==0&&i<=M/N) ans=max(ans, i);
    if(M%i==0&&M/i<=M/N) ans=max(ans, M/i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	num, _ := strconv.Atoi(next())
	return num
}

func nextInts(n int) [][]int {
	ints := make([][]int, n)
	for i := range ints {
		ints[i] = make([]int, 2)
	}
	for i := 0; i < n; i++ {
		ints[i][0], ints[i][1] = nextInt(), nextInt()
	}
	return ints
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {

	scanner.Split(bufio.ScanWords)
	n, w := nextInt(), nextInt()
	a := nextInts(n)

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, w+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= w; j++ {
			weight := a[i-1][0]
			value := a[i-1][1]
			dontChoose := dp[i-1][j]
			choose := 0
			if j-weight >= 0 {
				choose = value + dp[i-1][j-weight]
			}
			dp[i][j] = max(dontChoose, choose)
		}
	}

	fmt.Println(dp[n][w])
}


Measured memory_bytes: 81792
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n,x=map(int, input().split())
    ans = 1
    s = 0
    for i in map(int, input().split()):
        s += i
        if s <= x:
            ans += 1
        else:
            break
    print(ans)


main()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	rep(i,s.size()){
		if(s[i]!=t[i])ans++;
	}
	puts(ans);
}


Measured memory_bytes: 3848
import sys

N,M,X,Y = map(int,input().split())
ter_x = list(map(int,input().split()))
ter_y = list(map(int,input().split()))

boarder_of_x = max(ter_x)
boarder_of_y = min(ter_y)

for i in range(X+1,Y+1):
    if boarder_of_x < i <= boarder_of_y:
        print("No War")
        sys.exit()

print("War")

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    for(int i=0; i<n; i++) cout << s1[i] << s2[i];
    cout << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

int main() {
	int n, a[100];

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	int ans = INF;
	for (int i = -100; i <= 100; ++i) {
		int sum = 0;
		for (int j = 0; j < n; ++j) {
			sum += pow(a[j] - i, 2);
		}
		ans = min(ans, sum);
	}
	
	cout << ans << endl;

	return 0;
}

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

int main(){
  int n, m, l;
  cin>>n>>m>>l;
  
  int a[100][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) cin>>a[i][j];

  int b[100][100];
  for(int i=0;i<m;i++)
    for(int j=0;j<l;j++) cin>>b[i][j];

  
  long long c[100][100] = {};
  for(int i=0;i<n;i++)
    for(int j=0;j<l;j++)
      for(int k=0;k<m;k++) c[i][j] += a[i][k] * b[k][j];

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j) cout<<" ";
      cout<<c[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  for(int j=0;j<N;j++){
      cout << v[j];
      if(j!=N-1)  cout << " ";
  }
  cout << endl;

  for(int i=1;i<N;i++){
    int key = v[i];
    int j = i - 1;
    while(j >= 0 && v[j] > key){
      v[j+1] = v[j];
      j--;
    }
    v[j+1] = key;
    for(int j=0;j<N;j++){
      cout << v[j];
      if(j!=N-1)  cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
abcd = input().split()

hp1 = int(abcd[0])
at1 = int(abcd[1])
hp2 = int(abcd[2])
at2 = int(abcd[3])

while hp1 > 0 and hp2 > 0:
    hp2 -= at1
    if hp2 <= 0:
        print("Yes")
        break

    hp1 -= at2
    if hp1 <= 0:
        print("No")
        break

Measured memory_bytes: 9128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b)printf("safe");
	else printf("unsafe");
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<stdlib.h>
int main(void)
{ int n,i;
 double j,money;
 char c;
 double num[10]={0};
 char ch[10][4]={0};
 scanf("%d\n",&n);
 money=j=0;
 for(i=0;i<n;i++)
 { scanf("%lf %s\n",&j,ch[i]);
   num[i]=j;
  //printf("%.8f %.8f\n",num[i],j);
 }
 for(i=0;i<n;i++)
 { j=num[i];
  // printf("%s\n",ch[i]);
   if(ch[i][0]=='J'){money+=j;}
   if(ch[i][0]=='B'){money+=j*380000.0;}
 }
printf("%lf",money);
 return 0;  
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
LL ans = 1;
map<LL, LL> mp;
/**********************************************/

bool isprime(LL x){
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;
    LL i = 3;
    LL sqrtx = sqrt(x);
    while(i <= sqrtx){
        if(x % i == 0) return false;
        i += 2;
    }
    return true;
}
// maxまでの素数をvectorに入れて返す
vector<LL> eratos(LL max){
    vector<LL> primeVec;
    vector<bool> isprime;
    double sqrtmax = sqrt(max);
    isprime.resize(max + 1);
    isprime[0] = false; isprime[1] = false;
    FOR(i, 2, max + 1){
        isprime[i] = true;
    }
    FOR(i, 2, sqrtmax){
        if(isprime[i]){
            for(int j = 0; i * (j + 2) < max + 1; ++j){
                isprime[i * (j + 2)] = false;
            }
        }
    }
    REP(i, max + 1){
        if(isprime[i])  primeVec.pb(i);
    }
    return primeVec;
}

void make_soinnsuu_list(LL num){
    vector<LL> ret;
    vector<LL> sosuu_list = eratos(num);
    
    int i = 0;
    while(num > 1){
        if(num % sosuu_list[i] == 0){
            num /= sosuu_list[i];
            ret.pb(sosuu_list[i]);
        }else{
            i++;
        }
    }
    REP(i, ret.size()){
        mp[ret[i]]++;
    }
}

int main(){
    cin >> n;
    
    REP(i, n){
        make_soinnsuu_list(i+1);
    }

    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        ans = ans * (itr->second + 1) % MOD;
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i <= 3; i++){
        if (s[i] == '+'){
            ans++;
        } else {
            ans--;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h> 

int main(){
	int x;
	scanf("%d",&x);
	if (x % 7 == 2) {
		printf("sat\n");
	}
	if (x % 7 == 3) {
		printf("sun\n");
	}
	if (x % 7 == 4) {
		printf("mon\n");
	}
	if (x % 7 == 5) {
		printf("tue\n");
	}
	if (x % 7 == 6) {
		printf("wed\n");
	}
	if (x % 7 == 0) {
		printf("thu\n");
	}
	if (x % 7 == 1) {
		printf("fri\n");
	}
	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <stack>
#include <stdio.h>
#include <cmath>
#include <utility>
using namespace std;
int main()
{
    int n;
	while(cin>>n&&n){
		int a[5000]={},sum[5000]={},m=-1000000;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum[i+1]=sum[i]+a[i];
		}
		for(int i=0;i<n;i++){//start
			for(int j=i;j<n;j++){//end
				int tmp=sum[j+1]-sum[i];
				m=max(m,tmp);
				if(tmp<=0){i=j;break;}
				//printf("%d-%d:%d\n",i,j,tmp);
			}
		}
		cout<<m<<endl;
	}
    return 0;
}

Measured memory_bytes: 1204
import sys
sys.setrecursionlimit(1000000000)

def main():
    N,M = map(int,input().split())
    e = [[] for i in range(N)]
    t = 0
    a = []
    for i in range(M):
        r,l,d = map(int,input().split())
        e[r-1].append((l-1,d))
        e[l-1].append((r-1,-d))
        a.append(r-1)
        a.append(l-1)
        t = r-1

    col = [ float("inf") for i in range(N) ]
    def dfs(i,c):
        for node in e[i]:
            if col[node[0]] == float("inf"):
                col[node[0]] = c + node[1]
                dfs(node[0],c+node[1])
            elif col[node[0]] != c + node[1]:
                print("No")
                exit()
    dfs(t,0)
    a = list(set(a))
    for i in a:
        if col[i] == float("inf"):
            dfs(i,0)
    print("Yes")


if __name__ == '__main__':
    main()


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

struct Card{
    ll b;
    ll c;
    Card(ll b = 0, ll c = 0){
        this->b = b;
        this->c = c;
    }
    bool operator < (const Card &a) const{
        return this->c < a.c;
    }
    void print(){
        printf("b:%2ld c:%2ld\n", this->b, this->c);
    }
};

int main(){
    int n,m;    cin>>n>>m;
    vector<ll>a(n);
    rep(i, n)   cin>>a[i];
    vector<Card>dic(m);
    rep(i, m){
        ll b,c;    cin>>b>>c;
        dic[i].b = b;
        dic[i].c = c;
    }
    sort(a.begin(), a.end());
    sort(dic.rbegin(), dic.rend());
    vector<ll>d;
    int count = 0;
    rep(i, m){
        rep(j, dic[i].b){
            count++;
            d.push_back(dic[i].c);
            if(count>n) break;
        }
        if(count>n) break;
    }
    int ptr = 0;
    for(; ptr < d.size(); ptr++){
        if(ptr >= n)    break;
        if(a[ptr] > d[ptr]) break;
    }
    ll ans = 0;
    if(ptr >= n){
        rep(i, ptr) ans += d[i];
    }else{
        rep(i, ptr) ans += d[i];
        for(int i = ptr; i < n; i++)    ans += a[i];
    }
    cout << ans << endl;
}


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

int main(void)
{
  int a, b, c, temp;
  cin >> a >> b >> c;

  if(a > b){ 
    temp = a;
    a = b;
    b = temp;
  }
  if(a > c){
    temp = c;
    c = a;
    a = temp;
  }
  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }

  cout << a << " " << b <<  " " << c << endl;
  

  return 0;
}

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

int main() {
    string s;
    cin >> s;

    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3584
/*
author:Manson
date:7.7.2018
theme:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int n;
vector<int>g[N*2];
int d1[N],d2[N];

void dfs(int rt,int fa,int d,int dict[]){
	dict[rt] = d;
	for(int x :g[rt]){
		if(x != fa){
			dfs(x,rt,d+1,dict);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int u,v;
	while(cin>>n){
		for(int i = 0;i < n;i++){
			g[i].clear();
		}
		for(int i = 0;i < n-1;i++){
			cin>>u>>v;
			u--;
			v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		dfs(0,-1,0,d1);
		dfs(n-1,-1,0,d2);
		int ans = 0;
		for(int i = 0;i < n;i++){
			if(d1[i] <= d2[i]){
				ans++;
			}
			else{
				ans--;
			}
		}
		if(ans > 0){
			cout<<"Fennec"<<endl;
		}
		else{
			cout<<"Snuke"<<endl;
		}
	}
	
	return 0;
}


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

int n;
string str;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> str;
    for(int i = 0; i < (int)str.length(); i++)
    	str[i] = (str[i] - 65 + n) % 26 + 65;
    cout << str << "\n";
    return 0;
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int n,k;
int a[202020],b[202020];

bool chk(int x){
	int res = 0;
	for(int i=1;i<=n;i++){
		res+= max(0LL, a[i] - (x/b[i]) );
	}
	return res<=k;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}     
	for(int i=1;i<=n;i++){
		cin >> b[i];
	}
	sort(b+1,b+n+1);
	sort(a+1,a+n+1);
	reverse(b+1,b+n+1);
  int ans = 0;
  int l = 0, r = 1000000000000000;
  while(r-l>1){
  	int mid = (l+r)/2;
  	if(chk(mid)){
  		r = mid;
  	}
  	else l = mid;
  }
  if(chk(l)){
  	cout << l << endl;
  }
  else cout << r << endl;


return 0;
}
///....


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

int main(){
    int64_t n, ans = INT64_MAX;
    cin >> n;
    for(int64_t a=1;a*a<=n;++a){
        if(n%a > 0) continue;
        int64_t b = n/a;
        ans = min(ans, a+b-2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int person[128][128];
int num[128];
int flag[128];

int main(void)
{
    int m, n;
    int i, j, k;

    scanf("%d %d", &m, &n);
    for (i = 0; i < n; i++){
        int x, y;

        scanf("%d %d", &x, &y);
        person[y][x] = 1;
    }

    for (i = 1; i <= m; i++){
        for (j = 1; j <= m; j++){
            if (flag[j]) continue;
            for (k = 1; k <= m && !person[j][k]; k++);
            if (k == m + 1){
                printf("%d\n", j);
                flag[j] = 1;
                for (k = 1; k <= m; k++) person[k][j] = 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 612