akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string t = "keyence";
    bool flag = false;
    REP(i,n){
        FOR(j,i,n+1){
            string tmp = s.substr(0,i)+s.substr(j);
            if(tmp == t)flag=true;
        }
    }
    
    if(flag)COUT("YES");
    else COUT("NO");
    return 0;
}    

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		int m = t.length();
		for( int i=0 ; i<s.length()-t.length()+1 ; i++ ) {
			int c=0;
			for( int j = 0; j<t.length() ; j++ ) {
				if( s.charAt(i+j) != t.charAt(j)) {
					c++;
				}
			}
			if( m > c ) {
				m = c;
			}
		}
		
		System.out.println(m);
	}
}


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

int main() {
  int n; cin>>n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n-1; i++) {
    int a, b; cin>>a>>b; --a, --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  vector<int> df(n, 1e9), ds(n, 1e9);
  df[0] = 0, ds[n-1] = 0;

  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (auto nx: g[cur]) {
      if (df[cur] + 1 < df[nx] and nx != n-1) {
        df[nx] = df[cur] + 1;
        q.push(nx);
      }
    }
  }
  q.push(n-1);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (auto nx: g[cur]) {
      if (ds[cur] + 1 < ds[nx] and df[nx] > ds[cur] + 1) {
        ds[nx] = ds[cur] + 1;
        df[nx] = 1e9;
        q.push(nx);
      }
    }
  }

  int b = 0, w = 0;
  for (int i = 0; i < n; i++) {
    if (df[i] != 1e9) ++b;
    if (ds[i] != 1e9) ++w;
  }

  if (b > w) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }

  return 0;
}

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

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

    int need_left = 0;
    int pointer = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == '(') ++pointer;
        else {
            if (pointer == 0) ++need_left;
            else --pointer;
        }
    }
    int need_right = pointer;

    string res = "";
    for (int i = 0; i < need_left; ++i) res += '(';
    res += S;
    for (int i = 0; i < need_right; ++i) res += ')';
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
ll LCM(ll x, ll y);

int main() {
    ll N, MAX = 0, k, ans = 0, t, tmp;
    cin >> N;

    vector<ll>A(N);

    rep(i, N) {
        cin >> A[i];
        if (MAX < A[i]) {
            MAX = A[i];
            k = i;
        }
    }

    t = 0;
    while (A[k] != 0) {
        tmp = 0;
        t = 2;
        rep(i, N) {
            if (A[i] > 0) {
                A[i] --;
                if (t == 2) {
                    tmp++;
                    t = 1;
                }
            }
            else {
                if (t == 1) {
                    t = 2;
                }
            }
        }
        ans += tmp;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3180
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        var accum = new int[1 + a.Length];
        var accumBack = new int[1 + a.Length];
        for (int i = 0; i < a.Length; i++)
        {
            accum[i + 1] = Max(accum[i], a[i]);
        }
        for (int i = a.Length - 1; i >= 0; i--)
        {
            accumBack[i] = Max(accumBack[i + 1], a[i]);
        }
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(Max(accum[i], accumBack[i + 1]));
        }
    }
}


Measured memory_bytes: 20692
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        int[] a=new int[5];
        a[0]=s.nextInt();a[1]=s.nextInt();a[2]=s.nextInt();
        a[3]=s.nextInt();a[4]=s.nextInt();
        Arrays.sort(a);
        System.out.printf("%d %d %d %d %d\n",a[4],a[3],a[2],a[1],a[0]);
    }
}

Measured memory_bytes: 12000
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $x = 0;
  $max = 0;
  for($i=0; $i<$n; $i++){
      if($s[$i] == "I") $x++;
      else $x--;
      $max = max($max, $x);
  }
  echo $max;

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PB push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
ll n;
vector<vector<ll>> a;
vector<vector<ll>> dp(3,vector<ll>());
ll fun(ll i,ll prev)
{
    if(i>=n)
       return 0;
    if(i==0)
    {
        return max(a[i][0]+fun(i+1,0),max(a[i][1]+fun(i+1,1),a[i][2]+fun(i+1,2)));
    }
    else
    {
        if(dp[prev][i]!=-1)   return dp[prev][i];
        if(prev==0)
            return dp[prev][i]=max(a[i][1]+fun(i+1,1),a[i][2]+fun(i+1,2));
        if(prev==1)
           return dp[prev][i]=max(a[i][0]+fun(i+1,0),a[i][2]+fun(i+1,2));
        if(prev==2)
             return dp[prev][i]=max(a[i][1]+fun(i+1,1),a[i][0]+fun(i+1,0));
    }
}
int main() {
    SPEED;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        a.PB({x,y,z});
    }
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<n;j++)
        {
            dp[i].PB(-1);
        }
    }
    cout<<fun(0,4)<<endl;
    return 0;
}

Measured memory_bytes: 14512
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var K = input[2];

            if (K <= A)
            {
                Console.WriteLine($"{A - K} {B}");
            }
            else if (K <= A + B)
            {
                Console.WriteLine($"0 {B - (K - A)}");
            }
            else
            {
                Console.WriteLine("0 0");
            }
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
	int x=0,f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
const int N=2e5;
int ans,n,a[N],t,f[1<<20],q[N],d[N];
int main()
{
	n=read();
	int x,y,v;
	for(int i=1;i<n;++i)x=read()+1,y=read()+1,v=read(),a[x]^=v,a[y]^=v;
	sort(a+1,a+n+1);//for(int i=1;i<=n;++i)printf("%d ",a[i]);printf("\n");
	for(int i=1;i<=n;++i)
	if(i<n&&a[i]==a[i+1]) a[i]!=0?ans++:0,i++;
	else q[++t]=a[i];
	for(int i=2;i<(1<<t);++i)f[i]=f[i>>1]+(i&1);
	for(int i=1;i<(1<<t);++i)
	for(int j=1;j<=t;++j)
	if(i&(1<<(j-1)))
	d[i]^=q[j];
	for(int i=1;i<(1<<t);++i)
	if(!d[i])
	for(int j=(i-1)&i;j;j=(j-1)&i)
	if(!d[j])
	f[i]=min(f[i],f[j]+f[i^j]);
	printf("%d\n",f[(1<<t)-1]+ans);
}

Measured memory_bytes: 2816
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 long X=sc.nextLong();
	 long Y=sc.nextLong();
	 long Z=0;
     long result = 0;
     while(true) {
    	 
    	 Z=(long) (X*Math.pow(2, result));
    	if(Z>Y) {
    		
    		break;    	}
    	result++;
    	 
     }
     System.out.println(result);
     
	 
	 
 }
	


}



Measured memory_bytes: 21972
S = input()
Q = int(input())
F,B = "",""
k = 1
for i in range(Q):
    q = list(input().split())
    if int(q[0])==1:k = abs(k-1)
    else:
        if int(q[1])==1:
            if k:F+=q[2]
            else:B+=q[2]
        else:
            if k:B+=q[2]
            else:F+=q[2]
if k:print(F[::-1]+S+B)
else:print(B[::-1]+S[::-1]+F)

Measured memory_bytes: 4468
n = input().split()
n = [int(n[i]) for i in range(len(n))]
n.sort()
n = n[::-1]

total = ''
for i in range(len(n)):
    if i == 0 or i == 1:
        total += str(n[i])
    else:
        total += '+'
        total += str(n[i])
print(eval(total))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a % 2 != b % 2) {
		printf("IMPOSSIBLE\n");//AとBの偶奇が異なる場合Kは存在しない
	}
	else {
		printf("%d\n", (a + b) / 2);//偶奇が同じ場合、Kは(A+B)/2で表される
	}

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n m
a1
...
an
b1
...
bn

Yes,No
 */
int n,m;
char a[50][51],b[50][51];

int main(){
  cin>>n>>m;
  REP(i,n){
    cin>>a[i];
  }
  REP(j,m){
    cin>>b[j];
  }

  REP(i,n-m+1){
    REP(j,n-m+1){
      bool f1 = true;
      REP(k,m){
        REP(l,m){
          if(a[i+k][j+l]!=b[k][l]){
            f1 = false;
            break;
          }
        }
        if(!f1)
          break;
      }
      if(f1){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";

  return 0;
}


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

using namespace std;

int main(void){

    int n, count = 0, tmp = 0;
    vector<int> h;

    cin >> n;

    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        h.push_back(x);
    }

    for(int i = 0;i < n - 1;i++){
        if(h[i] >= h[i+1] && n-i >= count){
            for(int j = i;;j++){
                if(h[j] >= h[j+1] && j + 1 != n){
                    tmp++;
                }else{
                    if(count < tmp) count = tmp;
                    tmp = 0;
                    break;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include<atcoder/all>

using namespace std;

using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }



void solve() {
	int N, D; cin >> N >> D;
	two_sat ts(N);
	vector<vector<int>>v(N, vector<int>(2));
	REP(i, N) {
		cin >> v[i][0] >> v[i][1];
		VSORT(v[i]);
	}
	REP(i, N) {
		FOR(j, i + 1, N) {
			REP(k, 2)REP(l, 2) {
				if (abs(v[i][k] - v[j][l]) < D)ts.add_clause(i, 1^k, j, 1^l);
			}
		}
	}
	bool ok = ts.satisfiable();
	if (!ok) {
		print("No");
	}
	else {
		vector<bool>ans = ts.answer();
		print("Yes");
		REP(i, N) {
			print(v[i][ans[i]]);
		}
	}
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



Measured memory_bytes: 3788
#include<stdio.h>

int main(void)
{
 	int kazu_N,kazu_M;
	int cut_i,cut_j;
	int ans[7];
	int num[10][7]={
		{0,1,1,1,1,1,1},
		{0,0,0,0,1,1,0},
		{1,0,1,1,0,1,1},
		{1,0,0,1,1,1,1},
		{1,1,0,0,1,1,0},
		{1,1,0,1,1,0,1},
		{1,1,1,1,1,0,1},
		{0,1,0,0,1,1,1},
		{1,1,1,1,1,1,1},
		{1,1,0,1,1,1,1}};

	while(1){
		scanf("%d",&kazu_N);
		int now[7]={0,0,0,0,0,0,0};		
		
		if(kazu_N==-1){
			break;
		}
		
		for(cut_i=0;cut_i<kazu_N;cut_i++){
			scanf("%d",&kazu_M);
			for(cut_j=0;cut_j<7;cut_j++){
				if(num[kazu_M][cut_j]!=now[cut_j]){
					ans[cut_j]=1;
				}
				else {
					ans[cut_j]=0;
				}
				now[cut_j]=num[kazu_M][cut_j];
			}
			for(cut_j=0;cut_j<7;cut_j++){
				printf("%d",ans[cut_j]);
				if(cut_j==6){
					printf("\n");
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<sstream>
#include<string>
using namespace std;
 
int main(){
    while(1){
        string s1,s2;
        cin>>s1;
        if(s1==".")return 0;
        cin>>s2;
        string s11[201],s22[201];
        for(int i=0;i<201;i++){
            s11[i]=".";s22[i]=".";
        }
        s11[0]="";s22[0]="";
        int now1=0,now2=0;
        for(int i=0;i<(int)s1.length();i++){
            if(s1[i]=='"'){
                now1++;
                s11[now1]="";
            }else s11[now1]+=s1[i];
        }
        for(int i=0;i<(int)s2.length();i++){
            if(s2[i]=='"'){
                now2++;
                s22[now2]="";
            }else s22[now2]+=s2[i];
        }
        int d=0;
        for(int i=0;i<201;i++){
            if(s11[i]!=s22[i]){
                if(i&1){
                    d++;
                }else d+=2;
            }
        }
        if(d==0)cout<<"IDENTICAL";
        else if(d==1)cout<<"CLOSE";
        else cout<<"DIFFERENT";
        cout<<"\n";
    }
}


Measured memory_bytes: 3224
import java.util.Scanner;

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

        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26172
#include<stdio.h>

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while (1) {
		if (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) == EOF)break;
		if ((((y2 - y1)*(x3 - x1) - (x2 - x1)*(y3 - y1))*((y2 - y1)*(xp - x1) - (x2 - x1)*(yp - y1)) > 0) && (((y3 - y2)*(x1 - x2) - (x3 - x2)*(y1 - y2))*((y3 - y2)*(xp - x2) - (x3 - x2)*(yp - y2)) > 0) && (((y1 - y3)*(x2 - x3) - (x1 - x3)*(y2 - y3))*((y1 - y3)*(xp - x3) - (x1 - x3)*(yp - y3)) > 0))
			printf("YES\n");
		else printf("NO\n");
	}


	return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>

int isprime(long int n){
  long int i;
  for(i=2; i*i<=n; i++)
    if(n%i==0)
      return 0;
  return 1;
}

int main(){
  long int n;
  scanf("%ld",&n);
  printf("%ld: ",n);

  if(isprime(n))
    printf("%ld",n);
  else{
    while(1){
      if(n<=1)
	break;
      else{
	long int i;
	for(i=2; i<=n; i++){
	  if(i==n){
	    printf("%ld",n);
	    n=1;
	  }
	  else if(n%i==0){
	    printf("%ld ",i);
	    n/=i;
	    break;
	  }
	}
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = lr()
    edges[a].append(b)
    edges[b].append(a)

counter = [0] * (N+1)
for _ in range(Q):
    p, x = lr()
    counter[p] += x

parents = [0] * (N+1)

def bfs(x):
    p = parents[x]
    c = counter[x]
    for y in edges[x]:
        if y == p:
            continue
        counter[y] += c
        parents[y] = x
        bfs(y)

bfs(1)
print(*counter[1:])
# 09

Measured memory_bytes: 238868
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = S{x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
}


Measured memory_bytes: 19352
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define pll pair<long,long>
#define INF 10000000000000000
typedef long long ll;
#define PI 3.14159265



int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	ll n;
	cin>>n;
	if(n==3)
	{
		cout<<"2 5 63";
		
	}
	else
	{
		cout<<"3 9 ";
		ll val=6;
		n-=2;
		for(ll i=2;i<=30000;i+=6)
		{
			cout<<i<<" "<<i+2<<" ";
			n-=2;
			if(n<=1)
				break;
			
		}
		if(n>1)
		{
			for(ll i=15;i<=30000;i+=12)
			{
				cout<<i<<" "<<i+6<<" ";
				n-=2;
				if(n<=1)
					break;
			}
		}
		while(n)
		{
			cout<<val<<" ";
			val+=6;
			n--;
		}
		
	}
	
}				
					
					


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int n,a[N],k1,k2;
bool cmp(int x,int y){
	return x>y;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
		if(i+1>a[i+1]){
			k1=a[i]-i,k2=0;
			for(int j=i+1;j<=n;j++)
				if(a[j]==i) k2++;
			break;
		}
	if(k1&1||k2&1) puts("First");
	else puts("Second");
	return 0;
}

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

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i;
	string a;
	cin>>a;
	for (i=0;i<a.size();i+=2){
		cout<<a[i];
	}
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair
ll mod = 1000000000000000001;
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    ll res = 1;
    For(i, 0, n)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    For(i, 0, n)
    {
        long double x = (long double)res / mod;
        x *= a[i];
        if (x < 1)
        {
            res *= a[i];
        }
        else
        {
            res = -1;
            break;
        }
    }

    cout << res << endl;
    // your code goes here
    return 0;
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>

int main(){
    using namespace std;
    constexpr unsigned long shosubu = 200;
    constexpr unsigned long tore = 10000000;
    using bigint = boost::multiprecision::cpp_int;
    bigint p10{string(shosubu, '9')}, eps{p10 / tore};
    ++p10;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> t(N);
    for(auto& i : t)cin >> i.first >> i.second;
    const auto& norm = [](const pair<long, long>& x, const pair<long, long>& y) -> unsigned long {
        unsigned long xd{static_cast<unsigned long>(max(x.first, y.first) - min(x.first, y.first))}, yd{static_cast<unsigned long>(max(x.second, y.second) - min(x.second, y.second))};
        return xd * xd + yd * yd;
    };
    bigint ans_lower{0}, ans_upper{0};
    for(const auto& i : t)for(const auto& j : t){
        bigint t{p10 * p10 * norm(i, j)};
        bigint c{boost::multiprecision::sqrt(t)}, d{c * c == t ? c : c + 1};
        ans_lower += c;
        ans_upper += d;
    }
    const auto& println_bigint_as_decimal = [](const bigint& x) -> void {
        string s = x.str();
        copy(s.begin(), s.end() - shosubu, ostream_iterator<char>(cout));
        cout << '.';
        copy(s.end() - shosubu, s.end(), ostream_iterator<char>(cout));
        cout << endl;
    };
    println_bigint_as_decimal(max<bigint>(ans_lower / N + eps, ans_lower * (tore + 1) / (N * tore)));
    //println_bigint_as_decimal(min<bigint>((ans_upper + N - 1) / N - eps, (ans_upper * (tore - 1) + N * tore - 1) / (N * tore)));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val s = sc.next

    val k = s.length

    val res = if( (15 - k) + s.count(_ == 'o') >= 8) "YES" else "NO"

    println(res)

  }
}


Measured memory_bytes: 26044
#include <stdio.h>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

int main(){
    int n = 0;
    char s[200001] = {'\0'};
    scanf("%s", s);

    int bc = 0;
    long long m = 0;
    for(int i = 0; i < 200001; i++){
        if(s[i] == 'W'){
            m += bc;
        }else if(s[i] == 'B'){
            bc++;
        }else{
            break;
        }
    }
    printf("%lld\n", m);

    return 0;
}

Measured memory_bytes: 384
toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y

appleToPeace apple = apple * 3

main = do
  xs <- getInts
  let apple = xs !! 0
      peace = xs !! 1
  print ((peace + (appleToPeace apple)) `div` 2)


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,long double> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

string s,t="CODEFESTIVAL2016";

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

	cin>>s;
	int ans=0;
	REP(i,s.size()) if(s[i]!=t[i]) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,K;
vi p[11];
int sum[11][2010],dp[11][2010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>K;
	int C,G;
	rep(i,N){
		cin>>C>>G;
		p[G-1].pb(C);
	}
	rep(i,10){
		sort(p[i].begin(),p[i].end(),greater<int>());
	}
	rep(i,10){
		rep(j,sz(p[i]))sum[i][j+1]=sum[i][j]+p[i][j];
	}
	rep(i,10)rep(j,K+1)rep(k,min(j,sz(p[i]))+1){
		dp[i+1][j]=max(dp[i+1][j],dp[i][j-k]+sum[i][k]+k*(k-1));
	}
	cout<<dp[10][K]<<endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int sum = accumulate(a.begin(), a.end(), 0);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] * (4 * m) >= sum) {
      ++cnt;
    }
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	
	static String rev(String S) {
		if(S.equals("1,0"))
			return "0,1";
		else if(S.equals("0,1"))
			return "1,0";
		String[] s = S.split(",");
		if(s[0].charAt(0) == '-')
			return s[1] + "," + s[0].substring(1);
		else
			return "-" + s[1] + "," + s[0];
	}
	
	public static void main(String[] args) {
		int MOD = 1000000007;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String C;
		Map<String, Integer> m1 = new HashMap<>();
		Map<String, Integer> m2 = new HashMap<>();
		int zero = 0;
		for(int i = 0; i  < N; i++) {
			long A = sc.nextLong();
			long B = sc.nextLong();
			if(A == 0 && B == 0) {
				zero++;
				continue;
			}
			long gcd = gcd(A, B);
			A /= gcd;
			B /= gcd;
			if(B < 0) {
				A = -A;
				B = -B;
			}
			if(B == 0)
				C = "1,0";
			else if(A == 0)
				C = "0,1";
			else
				C = A + "," + B;
			if(A >= 0 && B != 0)
				m1.put(C, m1.getOrDefault(C, 0)+1);
			else 
				m2.put(C, m2.getOrDefault(C, 0)+1);		
		}
		long ans = 1;
		long[] pow2 = new long[N+1];
		pow2[0] = 1;
		for(int i = 1; i <= N; i++)
			pow2[i] = pow2[i-1] * 2 % MOD;
		for(String s : m1.keySet()) {
			int a = m1.get(s), b = m2.getOrDefault(rev(s), 0);
			ans = ans * (pow2[a] + pow2[b] - 1) % MOD;
		}
		for(String s : m2.keySet())
			if(!m1.containsKey(rev(s)))
				ans = ans * pow2[m2.get(s)] % MOD;
		System.out.println((ans + zero - 1 + MOD) % MOD);
	}

}

Measured memory_bytes: 95196
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, l[1001], r[1001], ans=0;

  cin >> N;
  for(int i = 0; i < N; i++) cin >> l[i] >> r[i];

  for(int i = 0; i < N; i++) ans += r[i] - l[i] + 1;

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

ans = 10000
for i in range(len(s)-len(t)+1):
    bubun = s[i:i+len(t)]
    okikae = 0
    for j in range(len(t)):
        if bubun[j] != t[j]:
            okikae += 1
    if okikae <= ans:
        ans = okikae
print(ans)


Measured memory_bytes: 67772
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    string s;
    cin>>n>>s;
    int ans = inf;
    int f = 0, r = 0;
    for(int i=0;i<n;i++){
        if(s[i] == 'R' && f == 0);
        else if(s[i] == 'W' && f == 0) f = 1;
        else if(s[i] == 'R' && f == 1) r++;
    }
    ans = min(ans,r);
    f = 0, r = 0;
    for(int i=n-1;i>=0;i--){
        if(s[i] == 'W' && f == 0);
        else if(s[i] == 'R' && f == 0) f = 1;
        else if(s[i] == 'W' && f == 1) r++;
    }
    ans = min(ans,r);
    int i=0, j=n-1;
    int cnt = 0;
    while(i < j){
        if(s[i] == 'W'){
            while(i < j && s[j] == 'W') j--;
            if(i >= j) break;
            swap(s[i],s[j]);
            cnt++;
        }
        i++;
    }
    ans = min(ans,cnt);
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

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

	int c;
	if(b+W < a || a+W < b){
		c = min(abs(a-b+W), abs(b-a+W));
	}else c = 0;

	cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=500010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans, sum;
string N;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>N;
	reverse(all(N));
	N+="00";
	n=N.size();
	int car=0;
	for (int i=0; i<n; i++){
		int x=(N[i]-'0')*9 + car;
		N[i]='0'+(x%10);
		sum+=(x%10);
		car=x/10;
	}
//	debug(N)
//	debug(sum)
	while (1){
		ans++;
		car=9;
		for (int i=0; i<n && car; i++){
			int x=(N[i]-'0') + car;
			sum=sum - (N[i]-'0')+ (x%10);
			N[i]='0'+(x%10);
			car=x/10;
		}
//		debug(N)
//		debug(sum)
		if (sum<=9*ans) break ;
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vi v(3);
    rep(i,3) {
        cin>>v[i];
    }
    sort(all(v));
    if(v[0]+v[1]==v[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  ll H;
  in(H);
  ll cnt = 0;
  while (H) {
    cnt++;
    H /= 2;
  }
  print((ll)pow(2, cnt) - 1);
}


Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int N, A, B, C, L[100000];
int dfs(int pos, int a, int b, int c) {
  if (pos == N) {
    return (min({a,b,c}) > 0) ?
      abs(a-A)+abs(b-B)+abs(c-C)-30 : INF;
  } else {
    int p = dfs(pos+1, a, b, c);
    int q = dfs(pos+1, a, b, c+L[pos]) + 10;
    int r = dfs(pos+1, a, b+L[pos], c) + 10;
    int s = dfs(pos+1, a+L[pos], b, c) + 10;
    return min({p,q,r,s});
  }
}

signed main() {
  cin>>N>>A>>B>>C;
  for (int i = 0; i < N; i++) cin>>L[i];
  int ans = dfs(0, 0, 0, 0);
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;

  ll ans = 0LL;
  for (ll i = 0; i <= N / 4; i++) {
    if ((N - 4 * i) % 7 == 0) ans++;
  }

  if (ans > 0) print("Yes");
  else print("No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <list>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <climits>
#include <string>
#include <vector>

using namespace std;

#define endl '\n'
#define int long long
#define mod 1000000007

#define forn(i,n) for(int i=0;i<n;i++)

int32_t main() {

		int n; cin>>n;

		vector<int> stones(n+1, INT_MIN);
		for(int i=1;i<=n;i++) {
			cin>>stones[i];
		}

		vector<long long> cost(n+1, 0);

		for(int i=2;i<=n;i++) {
			cost[i] = min(cost[i-1] + abs(stones[i] - stones[i-1]), cost[i-2] + abs(stones[i]-stones[i-2]));
		}

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

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main()
{
    int i=0,j=0,n,s,b;
    char O[50];
    char E[50];
    scanf("%s",O);
    scanf("%s",E);
    s=strlen(O);
    b=strlen(E);
    if(strlen(O)-strlen(E)==0||strlen(O)-strlen(E)==1)
    {
        while(i<s)
        {
            printf("%c",O[i]);
            if(b>i)
                printf("%c",E[i]);
            i=i+1;
        }
    }
    return 0;
}







Measured memory_bytes: 128
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>m;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  ---------------------------------MAIN-------------------------------------------*/


int main()
{
	pan;
	ll n;
	cin>>n;
	for (ll i = -2000; i <= 2000; i++) {
		for (ll j = -2000; j <= 2000; j++) {
			if (i*i*i*i*i - j * j*j*j*j == n) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

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

using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  int a2,b2;
  a2=a-1;
  b2=b-1;
  
  int ans1=a+a2;
  int ans2=a+b;
  int ans3=b+b2;
  cout << max({ans1,ans2,ans3}) << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    vector<int> time(5);
    rep(i, 5) {
        int t; cin >> t;
        time[i] = t;
    }
    vector<int> amari(5);
    rep(i, 5) {
        amari[i] = 10-time[i]%10;
        if (amari[i] == 10) amari[i] = 0;
    }
    sort(all(amari));
    int ans = 0;
    rep(i, 5) ans += time[i];
    rep(i, 4) ans += amari[i];
    cout << ans << endl;
}

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

int main(){
  int n, k, i, j, temp;
  cin >> n >> k;
  int l[n];
  for(i = 0; i < n; i++) cin >> l[i];
  for(i = 0; i < n; i++){
    for(j = i + 1; j < n; j++){
      if(l[i] < l[j]){
	temp = l[i];
	l[i] = l[j];
	l[j] = temp;
      }
    }
  }
  temp = 0;
  for(i = 0; i < k; i++) temp += l[i];
  cout << temp << endl;
  return 0;
}


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

int main() {
	int x, y, s;
	char a, b;
	vector<int> X, Y, S, m;
	vector<int> L1 = { -1,1 }, L2 = { -1,0,1 }, L3 = { -2,2 };
	while (cin >> x >> a >> y >> b >> s) {
		X.push_back(x);
		Y.push_back(y);
		S.push_back(s);
	}
	vector<vector<int>> matrix;
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 30; j++) {
			m.push_back(0);
		}
		matrix.push_back(m);
	}
	for (int i = 0; i < X.size(); i++) {
		if (S[i] == 1) {
			matrix[X[i] + 10][Y[i] + 10] += 1;
			for (int j = 0; j < L1.size(); j++) {
				matrix[X[i] + 10 + L1[j]][Y[i] + 10] += 1;
				matrix[X[i] + 10][Y[i] + 10 + L1[j]] += 1;
			}
		}
		else if (S[i] == 2) {
			for (int j = 0; j < L2.size(); j++) {
				for (int k = 0; k < L2.size(); k++) {
					matrix[X[i] + 10 + L2[j]][Y[i] + 10 + L2[k]] += 1;
				}
			}
		}
		else {
			for (int k = 0; k < L2.size(); k++) {
				for (int j = 0; j < L2.size(); j++) {
					matrix[X[i] + 10 + L2[k]][Y[i] + 10 + L2[j]] += 1;
				}
			}
			for (int j = 0; j < L3.size(); j++) {
				matrix[X[i] + 10 + L3[j]][Y[i] + 10] += 1;
				matrix[X[i] + 10][Y[i] + 10 + L3[j]] += 1;
			}
		}
	}
	int ctr1 = 0, max = INT_MIN;
	for (int i = 10; i < 20; i++) {
		for (int j = 10; j < 20; j++) {
			if (matrix[i][j] == 0) {
				ctr1++;
			}
			else {
				if (max < matrix[i][j])max = matrix[i][j];
			}
		}
	}
	cout << ctr1 << endl;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define vvl vector<vector<ll>>
#define in(a) insert(a)
#define M 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,sum=0;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    sort(a.rbegin(),a.rend());
    int c=0;
    double x=(double)sum/(double)(4*m);
    for(int i=0;i<n;i++){
        if((double)a[i]>=x)c++;
    }
    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b; cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
P = list(map(int, input().split()))
P = np.array(P)

# 自分より左にいるやつが、全員自分以上であるような要素の数
counter = 0
lowest = P[0]
for i in range(N):
    if P[i] <= lowest:
        lowest = P[i]
        counter += 1

print(counter)

Measured memory_bytes: 34140
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

int main() {
    vector<vector<int> > v;
    vector<vector<int> > dp;
    string s;
    while(cin >> s) {
        vector<string> ret = split(s,',');
        vector<int> res(ret.size());

        rep(i,ret.size()) {
            stringstream ss;
            ss << ret[i];
            ss >> res[i];
        }

        v.push_back(res);
        dp.push_back(res);
    }

    int mid = v.size()/2;
    rep(i,mid) {
        rep(j,v[i].size()) {
            dp[i+1][j] = max(dp[i+1][j],dp[i][j] + v[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + v[i+1][j+1]);
        }
    }

    REP(i,mid,v.size()-1) {
        rep(j,v[i].size()) {
            if(j == 0) {
                dp[i+1][j] = max(dp[i+1][j],dp[i][j] + v[i+1][j]);
            } else if(j == v[i].size()-1) {
                dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + v[i+1][j-1]);
            } else {
                dp[i+1][j] = max(dp[i+1][j],dp[i][j] + v[i+1][j]);
                dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + v[i+1][j-1]);
            }
        }
    }

    cout << dp[v.size()-1][0] << endl;

    return 0;
}

Measured memory_bytes: 1288
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int[,] map=new int[14,14];
            string str;
            while((str=Console.ReadLine())!=null){
                string[] strArray=str.Split(',');
                int x=int.Parse(strArray[0])+2;
                int y=int.Parse(strArray[1])+2;
                int s=int.Parse(strArray[2]);
                if(s==1){
                    map[y-1,x]++;
                    map[y,x-1]++;
                    map[y,x]++;
                    map[y,x+1]++;
                    map[y+1,x]++;
                }
                if(s==2){
                    for(int i=y-1;i<=y+1;i++){
                        for(int j=x-1;j<=x+1;j++){
                            map[i,j]++;
                        }
                    }
                }
                if(s==3){
                    for(int i=y-1;i<=y+1;i++){
                        for(int j=x-1;j<=x+1;j++){
                            map[i,j]++;
                        }
                    }
                    map[y-2,x]++;
                    map[y,x-2]++;
                    map[y,x+2]++;
                    map[y+2,x]++;
                }
            }
            int count=0;
            int max=0;
            for(int i=2;i<12;i++){
                for(int j=2;j<12;j++){
                    if(map[j,i]==0){
                        count++;
                    }
                    if(map[j,i]>max){
                        max=map[j,i];
                    }
                }
            }
            Console.WriteLine(count);
            Console.WriteLine(max);
        }
    }
}

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

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define endl '\n'
#define sorted(s)  sort(s.begin(),s.end())
#define reversed(s) reverse(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
#define ison(n,j) (n&(1LL<<j))
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
   ll a,b,x,y,res;
   cin>>a>>b;
   if(a%2)
    x=a+1;
   else
    x=a;
   if(b%2)
    y=b;
   else
    y=b-1;
   if(((y-x+1)/2)%2)
    res=1;
   else
    res=0;
   if(a%2)
    res=res^a;
   if(b%2==0)
    res=res^b;
   cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3612