akhauriyash/Code-Regression huggingface dataset:
/*Writer : Md. Shafiur Rahman Dipu */

#include <bits/stdc++.h>
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define pi acos(-1.0)
#define INF 2e12

#define ull unsigned long long
#define ll long long
#define ld long double

#define pb push_back

#define mx 5000005
#define mod 1000000007

long long poW(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power & 1) {
            result = (result*base) ;
        }
        base = (base * base);
        power = power / 2;
    }
    return result;
}

int ar[100005];
ll dp[100005];
int n;
int k;
ll func(int pres){
    if(dp[pres]>0){
        return dp[pres];
    }
    if(pres >= n-1){
        return 0;
    }
    if(pres == n-2){
        return dp[pres] = abs(ar[pres]-ar[pres+1]);
    }

    ll a = abs(ar[pres]-ar[pres+1]) + func(pres+1);

    ll b = LONG_LONG_MAX;
    for(int i=2; i<=k; i++){
        if(pres+i < n){
            b = min(b,(abs(ar[pres]-ar[pres+i]) + dp[pres+i]));
        }
        else{break;}
    }

    //cout << a <<  " " << b << endl;
    return dp[pres] = min(a,b);

}


int main()
{
    #ifdef dipu
    //freopen("inp.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    while(1){
    #endif
    FASTER
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> ar[i];
    }
    memset(dp,0,sizeof dp);
    ll res = func(0);

    cout << res << endl;

    #ifdef dipu
    }
    #endif // dipu


    return 0;
}


Measured memory_bytes: 4608
#include<cstdio>
    int N,M;
    char S[100010],T[100010];
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    int main(){
    	scanf("%d%d%s%s",&N,&M,S,T);
    	for(int i=0;i<N;i++){
    		if(1ll*i*M%N==0&&S[i]!=T[1ll*i*M/N])return puts("-1"),0;
    	}
    	printf("%lld\n",1ll*N*M/gcd(N,M));
    }

Measured memory_bytes: 384
import java.util.Arrays;
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());
		int K = Integer.parseInt(sc.next());
		int[] L = new int[N];
		for(int i = 0;i < N;i++) {
			L[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(L);
		int sum = 0;
		for(int i = N-1;i >=N-K;i--) {
			sum += L[i];
		}
		System.out.println(sum);
	}
}

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

int main()
{
  long inf = 10000000000;
  long double n, k;
  cin >> n >> k;
  long double percent = 0.0;
  if (n < k)
  {
    for (int i = 1; i <= n; i++)
    {
      int m = 1;
      while (i * powf(2, m) < k)
      {
        m++;
      }
      percent += inf / (n * powf(2, m));
    }
  }
  else
  {
    for (int i = 1; i < k; i++)
    {
      int m = 1;
      while (i * powf(2, m) < k)
      {
        m++;
      }
      percent += inf / (n * powf(2, m));
    }
    percent += inf * (n - k + 1) / n;
  }
  percent = percent / inf;
  cout << fixed << setprecision(10);
  cout << percent << endl;
  return 0;
}


Measured memory_bytes: 256
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N-1):
    for j in range(N-1-i):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j+i+1][k]) ** 2
        if math.sqrt(tmp).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];


string x = "APPROVED";
string y = "DENIED";


void test_case() {

    
    int n ;
    cin>>n;

    bool check = true;

    rep(i,n) {
        int  j;
        cin>>j;
        if(j%2 == 0) {
            if(j%3 !=0 && j%5 != 0) {
                check = false;
            }
        }
    }

    if(check) {
        cout<<x<<endl;
    } else {
        cout<<y<<endl;
    }





}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());

        String result = x <= 500 * k ? "Yes" : "No";
        System.out.println(result);

        sc.close();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                int n,x;
                int ans=0;
                scanf("%d %d",&n,&x);
                if(!n) break;
                for(int i=1;i<n-1;i++){
                        for(int j=i+1;j<n;j++){
                                for(int k=j+1;k<n+1;k++){
                                        if(i+j+k==x){
                                                ++ans;
                                        }
                                }
                        }
                }
                printf("%d\n",ans);
        }
        return 0;
}

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

int main() {
  int N,M,i,a,b,x=0,y=N,s=0;
  cin >> N >> M;
  vector<pair<int,int>> B(M);
  for(i=0; i<M; i++)
    cin >> B.at(i).first >> B.at(i).second;
  sort(B.begin(), B.end());
  
  for(i=0; i<M; i++) {
    a = B.at(i).first;
    b = B.at(i).second;
    if(a>x) {
      x = a;
      if(a>=y) {
        s++;
        y=N;
      }
    }
    if(b<y)
      y = b;
  }
  cout << s+1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A==1){
    if(B==1){
      cout<<"Draw"<<endl;
    }
    else{
      cout<<"Alice"<<endl;
    }
  }
  else{
    if(A==B){
      cout<<"Draw"<<endl;
    }
    else if(A<B){
      cout<<"Bob"<<endl;
    }
    else if(B==1){
      cout<<"Bob"<<endl;
    }
    else {
      cout<<"Alice"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 768
package main

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

const (
	MAX_N      = 100
	MAX_WEIGHT = 100000
)

type Edge struct {
	start  int
	end    int
	weight int
}

type ShortestInfo struct {
	edges    []Edge
	shortest int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	shortestList := make([]ShortestInfo, n)
	for i := 1; i < n; i++ {
		shortestList[i] = ShortestInfo{edges: []Edge{}, shortest: MAX_N*MAX_WEIGHT + 1}
	}

	adjacentMatrix, err := createAdjacentMatrix(n, sc)
	if err != nil {
		panic(err)
	}

	sssp([]int{1}, shortestList, adjacentMatrix)
	for _, v := range shortestList {
		fmt.Printf("%d %d\n", v.getEnd()-1, v.shortest)
	}
}

func (si ShortestInfo) getEnd() int {
	if len(si.edges) == 0 {
		return 1
	} else {
		return si.edges[len(si.edges)-1].end
	}
}

func createAdjacentMatrix(n int, sc *bufio.Scanner) ([][]int, error) {
	adjacentMatrix := make([][]int, n)
	for i := 0; i < n; i++ {
		id, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		adjacentMatrix[id] = make([]int, n)
		for j := 0; j < n; j++ {
			adjacentMatrix[id][j] = -1
		}
		vertexNum, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		for j := 0; j < vertexNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				return nil, err
			}
			c, err := nextInt(sc)
			if err != nil {
				return nil, err
			}
			adjacentMatrix[id][v] = c
		}
	}
	return adjacentMatrix, nil
}

func sssp(nodeStack []int, shortestList []ShortestInfo, adjacentMatrix [][]int) {
	for len(nodeStack) > 0 {
		currentNode := nodeStack[0]
		nodeStack = nodeStack[1:]
		currentShortest := getShortest(currentNode, shortestList)
		adjacents := findAdjacents(currentNode, adjacentMatrix)
		for i := 0; i < len(adjacents); i++ {
			adj := adjacents[i]
			if currentShortest.shortest+adj.weight < getShortest(adj.end, shortestList).shortest {
				setShortest(adj.end, adj, currentShortest, shortestList)
				nodeStack = append(nodeStack, adj.end)
			}
		}
	}
}

func getShortest(node int, shortestList []ShortestInfo) ShortestInfo {
	return shortestList[node-1]
}

func setShortest(node int, edge Edge, currentShortest ShortestInfo, shortestList []ShortestInfo) {
	newEdges := make([]Edge, len(currentShortest.edges)+1)
	for i := 0; i < len(newEdges)-1; i++ {
		newEdges[i] = currentShortest.edges[i]
	}
	newEdges[len(newEdges)-1] = edge
	shortestInfo := ShortestInfo{edges: newEdges, shortest: currentShortest.shortest + edge.weight}
	shortestList[node-1] = shortestInfo
}

func findAdjacents(currentNode int, adjacentMatrix [][]int) []Edge {
	adjacents := adjacentMatrix[currentNode-1]
	edges := []Edge{}
	for i, v := range adjacents {
		if v > 0 {
			edges = append(edges, Edge{start: currentNode, end: i + 1, weight: v})
		}
	}
	return edges
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}



Measured memory_bytes: 2800
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1505;
char s[N];int a[N][N],f[N][N],rpos[N][N],mn[2][N][N],mx[2][N][N],n,t;
ll res;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n){
		scanf("%s",s+1);
		fp(j,1,n)a[i][j]=s[j]=='#'?0:s[j]-'0';
	}
	fd(i,n,1){
		fd(j,n,1)if(a[i][j]){
			f[i][j]=f[i+1][j]+f[i][j+1]+a[i][j];
			rpos[i][j]=max({rpos[i+1][j],rpos[i][j+1],i});
			mn[t][j][i]=j;
			fp(k,i+1,rpos[i+1][j])mn[t][j][k]=mn[t^1][j][k];
			fp(k,max(rpos[i+1][j],i)+1,rpos[i][j+1])mn[t][j][k]=mn[t][j+1][k];
			mx[t][j][i]=j;
			fp(k,i,rpos[i][j+1])mx[t][j][k]=mx[t][j+1][k];
			fp(k,max(rpos[i][j+1],i)+1,rpos[i+1][j])mx[t][j][k]=mx[t^1][j][k];
			int d=i+1,r=min(rpos[i+1][j],rpos[i][j+1]);
			while(d<=r){
				if(mx[t^1][j][d]>=mn[t][j+1][d]){
					f[i][j]-=f[d][mn[t][j+1][d]];
					d=rpos[d][mn[t][j+1][d]];
				}
				++d;
			}
			res+=1ll*a[i][j]*(f[i][j]-a[i][j]);
		}
		t^=1;
	}
	printf("%lld\n",res);
	return 0;
}

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

int main() {

	ll n; cin >> n;
	const ll p = 5;
	ll minCapa = 9223372036854775807LL;
	vector<ll> capacity(p);
	for (ll i = 0; i < p; i++) {
		cin >> capacity[i];
		minCapa = min(minCapa, capacity[i]);
	}

	ll tmp;
	if (n % minCapa == 0) tmp = n / minCapa;
	else tmp = n / minCapa + 1;

	cout << tmp + p - 1 << endl;
	return 0;
}

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

int main(){
    long N;
    cin>>N;
    long X[N];
    long Y[N];
    rep(i, N){
        cin>>X[i];
        Y[i] = X[i];
    }

    long middle = N/2-1;
    sort(Y, Y+N);
    rep(i, N){
        if(X[i] <= Y[middle]) cout << Y[middle+1] << endl;
        else cout << Y[middle] << endl;
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

  int ab = 0, a = 0, b = 0, d = 0;
  string s;

  REP(i, n)
  {
    cin >> s;
    REP(j, s.size() - 1)
    {
      if (s[j] == 'A' && s[j + 1] == 'B')
      {
        ab++;
      }
    }
    if (s[0] == 'B')
    {
      b++;
      if (s[s.size() - 1] == 'A')
      {
        d++;
      }
    }

    if (s[s.size() - 1] == 'A')
    {
      a++;
    }
  }

  if (d > 1 && a == d && b == d)
  {
    ab--;
  }

  cout << ab + min(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
char s[103];int i,k;cin>>k;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cin.getline(s,103);

i=strlen(s);
if(i<=k)
{
cout<<s<<"\n";
}
else
{
s[k]='.';s[k+1]='.';s[k+2]='.';s[k+3]='\0';cout<<s<<"\n";

}
return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1005,mod=1e9+7;
int n,m;
LL k;
char s[N][N];
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int Pow(int x,LL y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1LL)
			ans=1LL*ans*x%mod;
	return ans;
}
int f1=0,f2=0;
int check(){
	for (int i=1;i<=n;i++)
		if (s[i][1]=='#'&&s[i][m]=='#')
			f1++;
	for (int i=1;i<=m;i++)
		if (s[1][i]=='#'&&s[n][i]=='#')
			f2++;
	return (bool)f1+(bool)f2;
}
int cntjing(){
	int cnt=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]=='#')
				cnt++;
	return cnt;
}
struct Mat{
	int v[3][3];
	Mat(){}
	Mat(int x){
		memset(v,0,sizeof v);
		for (int i=0;i<3;i++)
			v[i][i]=x;
	}
	void set(int c0,int c1,int c2,int c3){
		v[0][0]=c0	,v[0][1]=0	,v[0][2]=0		;
		v[1][0]=0	,v[1][1]=c3	,v[1][2]=mod-c1	;
		v[2][0]=0	,v[2][1]=0	,v[2][2]=c0		;
	}
}M;
Mat operator * (Mat A,Mat B){
	Mat C(0);
	for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
			for (int k=0;k<3;k++)
				C.v[i][j]=(1LL*A.v[i][k]*B.v[k][j]+C.v[i][j])%mod;
	return C;
}
Mat Pow(Mat x,LL y){
	Mat ans(1);
	for (;y;y>>=1,x=x*x)
		if (y&1LL)
			ans=ans*x;
	return ans;
}
int main(){
	n=read(),m=read(),k=read();
	if (k==0)
		return puts("1"),0;
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	int v=check(),c0=cntjing();
	if (v==0)
		return printf("%d\n",Pow(c0,k-1)),0;
	if (v==2)
		return puts("1"),0;
	int c1=0,c2=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			if (j<m&&s[i][j]=='#'&&s[i][j+1]=='#')
				c1++;
			if (i<n&&s[i][j]=='#'&&s[i+1][j]=='#')
				c2++;
		}
	if (f2)
		swap(c1,c2),swap(f1,f2);
	int c3=f1;
//	有 x 个方块，y 个横向连通，当前总共 t 个连通块。
//	x' = x * c0
//	y' = y * c3
//	t' = t * c0 - y
/*		x'	y'	t'
	x	c0	0	0
	y	0	c3	-c1
	t	0	0	c0
*/
	M.set(c0,c1,c2,c3);
	M=Pow(M,k-1);
	LL ans=1LL*c0*M.v[0][2]+M.v[1][2]+M.v[2][2];
	ans=(ans%mod+mod)%mod;
	printf("%d",(int)ans);
	return 0;
}

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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

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

  long n;
  cin >> n;



  cout << (n-1)/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<ll>A(N);
	rep(i, 0, N) {
		cin >> A[i];
		A[i] = A[i] - i - 1;
	}
	sort(all(A));
	ll cnt = A[N / 2];
	ll ans = 0;
	rep(i, 0, N) {
		ans += abs(A[i] - cnt);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  s+='#';
  vector<int> v;
  int c=0;
  char h='1';
  for(int i=0;i<n+1;i++){
    if(h!=s.at(i)){
      v.push_back(c);
      h=s.at(i);
      c=0;
    }
    c++;
  }
  if(v.size()%2==0)
    v.push_back(0);
  int a=0;
  for(int i=0;i<k*2+1&&i<v.size();i++)
    a+=v.at(i);
  int m=a;
  for(int i=k*2+2;i<v.size();i+=2){
    a+=v.at(i-1)+v.at(i)-v.at(i-k*2-2)-v.at(i-k*2-1);
    m=max(m,a);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 1020
import math
a, b, h, m = map(int, input().split())
# m: b, h: a

mrad = math.radians(360 * (m / 60))
hrad = math.radians(360 * (h * 60 + m) / (12 * 60))

mx = math.cos(mrad) * b
my = math.sin(mrad) * b
hx = math.cos(hrad) * a
hy = math.sin(hrad) * a

d = ((hx - mx) ** 2 + (hy - my) ** 2) ** 0.5
print(d)


Measured memory_bytes: 9516
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;

/*
解法
最初のk個の和→acumurate
その後の値の求め方は、今の和の値のもとになる値を配列に保管。
新たに値を求めるたびに、一番古い値を上書きしていく。
和から一番古い値を減じ、新たな値を加算する。

*/

int main() {
	int n, k;
	while (true) {
		
		int sum;
		int sum_max;
		cin >> n >> k;
		if (0 == n && 0 == k) {
			break;
		}

		vector<int> temp(k);

		for (int& a : temp) {
			cin >> a;
		}
		sum_max = sum = accumulate(temp.begin(), temp.end(), 0);
		auto it = temp.begin();
		for (int i = k; i < n; ++i) {
			int ai;
			cin >> ai;
			sum -= *it;
			sum += ai;
			*it = ai;
			if (++it == temp.end()) {
				it = temp.begin();
			}
			sum_max = max(sum, sum_max);
		}
		cout << sum_max << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

dived = A.map { |i| 1.0 / i }
sorted = dived.sort

res = 1.0 / (sorted.inject(&:+))

# p dived
# p sorted
p res


Measured memory_bytes: 1788
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cctype>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;


int main() {
    string s, t, u;
    cin >> s >> t >> u;
    cout << 'A' << (char)toupper(t[0]) << 'C' << endl;
    return 0;
}



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

int main(){
  int r,g,b,i;
  cin >> r >> g >> b;
  i = r*100 + g*10 + b;
  if(i % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout <<"NO" << endl;
  }
  return 0;
}

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

typedef long long int llint;

int main()
{
  int n, m, x;
  cin>> n >> m >> x;

  int a[200] = {};

  for(int i = 1; i <= m; i++) {
    int tmp;
    cin>> tmp;
    a[tmp] = 1;
  }

  int l = 0, r = 0;

  for(int i = x; i < n; i++) {
    r += a[i + 1];
  }

  for(int i = x; i > 0; i--) {
    l += a[i - 1];
  }

  cout<< min(l, r) <<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 5;
ll f[N], n, ans;
int main()
{
    ios::sync_with_stdio(false);
    for (int i = 1; i < N; i++)
        for (int j = i; j < N; j += i)
            f[j]++;
    cin >> n;
    for (int i = 1; i <= n; i++)
        ans += f[i] * i;
    cout << ans << endl;
    return 0;
}

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

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

  if ( N / 10 == 111 || N / 10 == 222 || N / 10 == 333 || N / 10 == 444 || N / 10 == 555 || N / 10 == 666 || N / 10 == 777 || N / 10 == 888 || N / 10 == 999) {
    cout << "Yes" << endl;
  }
  else if ( N % 1000 == 0 || N % 1000 == 111 || N % 1000 == 222 || N % 1000 == 333 || N % 1000 == 444 || N % 1000 == 555 || N % 1000 == 666 || N % 1000 == 777 || N % 1000 == 888 || N % 1000 == 999) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include<chrono>
     
    using namespace std;
    using namespace std::chrono;
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define F first
    #define S second
    #define PB push_back
    #define EB emplace_back
    #define MP make_pair
    #define REP(i,a,b) for(i=a;i<=b;i++)
    #define RAP(i,a,b) for(i=a;i>=b;i--)
    ll mod=1000000007;
    const int MX=0x3f3f3f;
  
    int main(){
        IOS;
        string s,t;
        cin>>s>>t;
        int n=s.size(),m=t.size(),i,j;
        int table[n+1][m+1];
        REP(i,0,n) table[i][0]=0;
        REP(i,0,m) table[0][i]=0;
        REP(i,1,n){
            REP(j,1,m){
                if(s[i-1]==t[j-1]) table[i][j]=table[i-1][j-1]+1;
                else table[i][j]=max(table[i][j-1],table[i-1][j]);
            }
        }
        i=n,j=m;
        string lcs;
        while(i>0&&j>0){
            if(s[i-1]==t[j-1]) lcs+=s[i-1],i--,j--;
            else if(table[i-1][j]>table[i][j-1]) i--;
            else j--;
        }
        reverse(lcs.begin(),lcs.end());
        cout<<lcs;
        return 0;
    }

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int od = 0, ev = 0;
    for(int i=0; i<n; i++){
         cin >> a[i];
         if(a[i] %2 == 1) od++;
         else ev++;
    }
    int ans = 0;
    if(od > 0&&ev>0){
        od--;
        ans += od/2;
        ans += ev+od/2;
    }
    cout << ans << endl;
}




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

int main() {
    int N, L;
    cin >> N >> L;
    string S[N];
    
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    
    sort(S, S+N);

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

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        int table[] = new int[128];
 
        for(int i = 0; i < table.length; i++){
            table[i] = 0;
        }
 
        StringBuilder sb = new StringBuilder();
 
        while(scanner.hasNext()){
            sb.append(scanner.nextLine());
        }
 
        String line = sb.toString();
 
        for(int i = 0; i < line.length(); i++){
            table[line.charAt(i)]++;
        }
 
        for(int i = 0; i < 26; i++){
            System.out.printf("%c : %d\n", 'a'+i,table['a'+i]+table['a'+i-32]);
        }
    }
}
	




Measured memory_bytes: 26352
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vvd mul(vvd A,vvd B){
	vvd C(A.size(),vd(B[0].size()));
	for(int i=0;i<A.size();i++) for(int j=0;j<B[0].size();j++) for(int k=0;k<B.size();k++) C[i][j]+=A[i][k]*B[k][j];
	return C;
}

vvd pow(vvd A,ll n){
	vvd B(A.size(),vd(A.size()));
	for(int i=0;i<A.size();i++) B[i][i]=1;
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

vd Gauss(vvd A,vd b){
	int n=A.size();
	vvd B=A;
	for(int i=0;i<n;i++) B[i].push_back(b[i]);
	for(int i=0;i<n;i++){
		int I=i;
		for(int j=i;j<n;j++){
			if(fabs(B[j][i])>fabs(B[I][i])) I=j;
		}
		swap(B[i],B[I]);
		if(abs(B[i][i])<eps) return vd();
		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		for(int j=0;j<n;j++) if(i!=j){
			for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
		}
	}
	vd x(n);
	for(int i=0;i<n;i++) x[i]=B[i][n];
	return x;
}

int s,n,k;

int main(){
	cin>>s>>n>>k;
	s=abs(s);
	if(n==1){
		cout<<(s%k==0?s/k:-1)<<endl;
		return 0;
	}
	int N=n*k;
	vvd A,dp;
	vd a(N+1),b(N+1,1);
	A=dp=vvd(N+1,vd(N+1));
	a[0]=1;
	for(int i=0;i<k;i++) for(int j=N;j>=0;j--){
		a[j]=0;
		for(int k=1;k<=min(j,n);k++) a[j]+=a[j-k]/n;
	}
	A[0][0]=1;
	b[0]=0;
	for(int i=1;i<=N;i++){
		A[i][i]=1;
		for(int j=k;j<=N;j++) A[i][abs(i-j)]-=a[j];
	}
	vd x=Gauss(A,b);
	vvd tmp(N+1,vd(1));
	for(int i=0;i<=N;i++) tmp[i][0]=x[i];
	vvd y=mul(A,tmp);
	if(s<=N){
		cout<<syosu(8)<<x[s]<<endl;
		return 0;
	}
	dp[0][N]=dp[N][N]=1;
	for(int i=0;i<N;i++) dp[0][i]=a[i+1];
	for(int i=1;i<N;i++) dp[i][i-1]=1;
	dp=pow(dp,s-N);
	double res=dp[0][N];
	for(int i=0;i<N;i++) res+=dp[0][i]*x[N-i];
	cout<<syosu(8)<<res<<endl;
}

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

//分布にすることが本質である
//前から決め打つ
//個数の分布管理に帰着させてみよ
//複数おける場合があるとき, 分布にすることで本質が見えるかも？

int N, A[1<<18], C[3];
long long sum = 1;
long long mod = 1e9 + 7;
int main(){
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    
    for (int i = 1; i <= N; i++){
        long long cnt = 0, id = -1;
        
        if (A[i] == C[0]){cnt++, id = 0;}
        if (A[i] == C[1]){cnt++, id = 1;}
        if (A[i] == C[2]){cnt++, id = 2;}
        
        if (id == -1){
            cout << 0 << endl;
            return 0;
        }
        sum *= cnt;
        C[id]++;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}
 

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

int main() {
  
  string S;
  
  cin >> S;
  
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll sum=0;
  priority_queue<ll, vector<ll>, greater<ll>> q;
  rep(i,n){
    ll s; cin>>s;
    sum+=s;
    q.push(s);
  }
  if(sum%10){
    cout<<sum<<endl;
    return 0;
  }
  ll ans=0;
  while(!q.empty()){
    ll v=q.top(); q.pop();
    if(v%10){
      cout<<sum-v<<endl;
      return 0;
    }
  }
  
  cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	string p, r;
	int ans = 0;
	cin >> p >> r;
	for (int i = 0; i < p.length(); i++) {
		if (p.substr(i, 1) == r.substr(i, 1))++ans;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
ifstream in("in.txt");
int a[35]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int k;
    cin>>k;
    cout<<a[k];
    return 0;
}

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

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

        bool is_strong = true;
        int n = s.length();
        for (int i = 0; i < n / 2; i++) is_strong &= (s[i] == s[n - i - 1]);

        for (int i = 0, j = (n / 2) - 1; i < j; i++, j--)
                is_strong &= (s[i] == s[j]);

        for (int i = ((n + 3) / 2) - 1, j = n - 1; i < j; i++, j--)
                is_strong &= (s[i] == s[j]);

        if (is_strong)
                cout << "Yes\n";
        else
                cout << "No\n";
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
suma = sum(a)
suma2 = suma // 2
mod = 998244353

dp1 = [3] + [0] * suma2
dp2 = [3] + [0] * suma2
for ai in a:
    for j in range(suma2, ai - 1, -1):
        dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
        dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
half = dp2[suma2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)


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

#define MX 100005
#define ll long long

int A[MX][4];
ll dp[MX][4];

int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 3; j++){
            scanf("%d", &A[i][j]);
        }
    }

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 3; j++){
            if (i == 1){ dp[i][j] = A[i][j]; continue; }

            ll  mx = 0;
            for (int x = 1; x <= 3; x++){
                if (x != j) mx = max(mx, dp[i-1][x]);
            }
            dp[i][j] = A[i][j] + mx;
        }
    }

    ll ans = 0;
    for (int j = 1; j <= 3; j++)
        ans = max(ans, dp[n][j]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4992
//#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int maxn=10000, inf=0x7ffffff;

int min(int a, int b) {
	return a< b? a : b;
}

class Net {
	public:
		static const int maxm=10*maxn+3;
		int n, m=1, ind[2*maxn+7], link[2*maxm+1], to[2*maxm+1], val[2*maxm+1], cur[2*maxn+7];
		ll cost[2*maxm+1], dis[2*maxn+7], sumcost;

		void addSide(int x, int y, int u, ll v) {
			m++;
			to[m] = y;
			val[m] = u;
			cost[m] = v;
			link[m] = ind[x];
			ind[x] = m;
		}

		void add(int x, int y, int u, ll v) {
			addSide(x, y, u, v);
			addSide(y, x, 0, -v);
		}

		void spfa(int s) {
			static bool book[2*maxn+7];
			static int que[2*maxn+7];
			memset(dis, 200, sizeof dis);
			dis[s] = 0;
			book[1] = true;
			que[1] = s;
			for (int h=0, t=1; h!=t; ) {
				h = h%n+1;
				int x=que[h];
				book[x] = false;
				for (int i=ind[x]; i; i=link[i]) {
					if (val[i]) {
						int y=to[i];
						ll z=dis[x]+cost[i];
						if (z>dis[y]) {
							dis[y] = z;
							if (!book[y]) {
								book[y] = true;
								t = t%n+1;
								que[t] = y;
							}
						}
					}
				}
			}
		}

		int run(int o, int t, int flow) {
			static bool vis[2*maxn+7];
			if (o==t) {
				return flow;
			}
			vis[o] = true;
			int have=0;
			for (int i=cur[o]; i; i=link[i]) {
				if (!vis[to[i]] && val[i] && dis[to[i]]==dis[o]+cost[i]) {
					cur[o] = i;
					int temp=run(to[i], t, min(flow-have, val[i]));
					val[i]-=temp, val[i^1]+=temp, have+=temp, sumcost+=temp*cost[i];
					if (flow==have) break;
				}
			}
			vis[o] = false;
			return have;
		}

		bool init(int s, int t) {
			for (int i=1; i<=n; i++) {
				cur[i] = ind[i];
			}
			spfa(s);
			return dis[t]>0;
		}
};

int main() {
#ifdef DEBUG
	freopen("src.in", "r", stdin);
	freopen("src.out", "w", stdout);
#endif

	static Net g;
	int n;
	scanf("%d", &n);
	g.n = 2*n+6;
	for (int i=1; i<=n; i++) {
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		g.add(1, i+6, c, 0);
		g.add(i+6, 3, inf, -x-y);
		g.add(i+6, 4, inf, -x+y);
		g.add(i+6, 5, inf, x-y);
		g.add(i+6, 6, inf, x+y);
	}
	for (int i=1; i<=n; i++) {
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		g.add(n+i+6, 2, c, 0);
		g.add(3, n+i+6, inf, x+y);
		g.add(4, n+i+6, inf, x-y);
		g.add(5, n+i+6, inf, -x+y);
		g.add(6, n+i+6, inf, -x-y);
	}

	for (; g.init(1, 2); g.run(1, 2, inf));
	printf("%lld\n", g.sumcost);

	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 3820
s = input()
if (s.count("N")>0 and s.count("S")==0)\
    or (s.count("S")>0 and s.count("N")==0)\
    or (s.count("W")>0 and s.count("E")==0)\
    or (s.count("E")>0 and s.count("W")==0):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
gets
h=(1..12).to_a.map{[0]*10}
while l=gets
  b,f,r,v=l.split(' ').map(&:to_i)
  h[(b-1)*3+(f-1)][r-1]+=v
end
puts (h.each_slice(3).map do |hs|
  hs.map{|h| (['']+h).join(' ')}.join("\n")
end.join("\n"+'#'*20+"\n"))

Measured memory_bytes: 8868
#include<bits/stdc++.h>
using namespace std;
#define int long long
//typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back
const int N=5002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}void dec(int &x,int y){x-=y;if(x<0)x+=M;}
void Max(int &x,int y){if(y>x)x=y;}void Min(int &x,int y){if(y<x)x=y;}
//struct node{int to,ne;}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
int n,i,a[N],sum[N],j,ans;
signed main(){
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]),sum[a[i]]++;
	sort(a+1,a+n+1);
	for (i=1;i<N;i++) sum[i]+=sum[i-1];
	for (i=1;i<=n;i++)
		for (j=i+1;j<=n;j++) ans+=sum[a[i]+a[j]-1]-j;
	printf("%lld",ans);
}

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

using namespace std;
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define rep(i, a, b) for(int i = (a), _b = (b); i < _b; ++i)
#define fd(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define SZ(x) ((int)(x).size())
#define db(x) cout << #x << " == " << x << endl
#define _ << ", " << 
#define X first
#define Y second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define endl '\n'
#define pc putchar
#define gc getchar 
#define bit(i) (1<<(i))

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

const int maxn=(int)2e5+5,INF=1e9;
int n;
string s;

void enter(){
	cin>>s;
	n=SZ(s);
	s=' '+s+' ';
}

int lst[(1<<26)+123];

int adj[maxn][28],d[maxn];

void process(){
	int sum=0;

	ff(i,0,n+1) d[i]=INF;

	lst[0]=n+1;

	fd(i,n,1){	
		sum^=bit(s[i]-'a');
		adj[i][0]=lst[sum];
		ff(j,1,26) {
			adj[i][j]=lst[sum^bit(j-1)]; 
		}
		// ff(j,0,26) if (adj[i][j]) db(i _ j _ adj[i][j]);
		lst[sum]=i;
	}
	
	d[1]=0;

	ff(i,1,n) if (d[i]!=INF){
		ff(j,0,26) if (adj[i][j]){
			d[adj[i][j]]=min(d[adj[i][j]],d[i]+((adj[i][j]-i)%2==1));
		}
	}
	// ff(i,1,n+1) cout<<d[i]<<' ';cout<<endl;
	if (d[n+1]==0) d[n+1]=1;
	cout<<d[n+1]<<endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	// freopen("test.inp","r",stdin);
	// freopen("test.out","w",stdout);

	enter();
	process();	

	return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll x;
    cin >> x;
    for(ll i = -255; i <= 255; ++i){
        for(ll j = - 255; j < 255; ++j)
        if(i * i * i * i * i == (j * j * j * j * j) + x){
            cout << i << " " << j;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll d, t, s;
    cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes";
    else cout << "No";
    return 0;
}

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

typedef unsigned long ul;

int getGCD(ul a, ul b) {

    ul r = a % b;

    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(void) {

    ul a, b;
    cin >> a >> b;

    if (a < b) swap(a, b);
    ul gcd = getGCD(a, b);
    ul lcm = a * b / gcd;

    cout << lcm << endl;

    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n, q; string s; cin >> n >> q >> s;
    vector<int> S(n+1); S[0] = 0;
    rep(i, n){
        S[i+1] = S[i];
        if(i<n-1 && s[i] == 'A' && s[i+1] == 'C')S[i+1]++;
    }
    rep(i, q){
        int l, r; cin >> l >> r; l--, r--;
        cout << S[r] - S[l] << ln;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{ll s,t,d;};
typedef vector<vector<Edge>> Graph;


int main(){
  ll V,E,r; cin>>V>>E>>r;
  vector<Edge> edges(E);
  REP(i,E) cin>>edges[i].s>>edges[i].t>>edges[i].d;
  Graph graph(V);
  for(Edge edge:edges) graph[edge.s].PB(edge);
  vi dist(V,INF);
  dist[r]=0;
  for(int cnt=0;;cnt++){
    REP(i,V) for(Edge e:graph[i]){
      if(dist[e.s]==INF) continue;
      if(dist[e.t]>dist[e.s]+e.d){
        dist[e.t]=dist[e.s]+e.d;
        if(cnt>V){
          cout<<"NEGATIVE CYCLE"<<endl;
          return 0;
        }
      }
    }
    if(cnt>V) break;
  }
  for(ll d:dist) if(d==INF) cout<<"INF"<<endl; else cout<<d<<endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll a(N);
  REP(i,N) IN(a[i]);

  ll xor_all = 0;
  REP(i,N){
    xor_all ^= a[i];
  }

  REP(i,N){
    printf("%lld ", xor_all^a[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
    
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
    
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (int i = 0; i != v.size(); i++) cout << v[i] << ' '
#define vin(v)  for (auto &i: v)    cin >> i
    
ll M = 1e9 + 7;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

void traverse(ListNode* root) {
    while (root) {
        cout << root->val << ' ';
        root = root->next;
    }
    cout << '\n';
}
     
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t, n, m, k, q;
    string s;
    
    cin >> n;

    int ac = 0, wa = 0, tle = 0, re = 0;

    FOR (i, 0, n) {
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "WA") {
            wa++;
        } else if (s == "TLE") {
            tle++;
        } else if (s == "RE") {
            re++;
        }
    }

    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    
    return 0;
}

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

int main () {
  int  x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2; 
  int dx = x2 - x1;
  int dy = y2 - y1;
  
  cout << x2 - dy << endl;
  cout << y2 + dx << endl;
  cout << x1 - dy << endl;
  cout << y1 + dx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto result = "Good";
	for (auto i = 1; i < S.length(); ++i)
	{
		if (S[i] == S[i - 1])
		{
			result = "Bad";
			break;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

b = sorted(a[::])
for i in range(n):
    if b[i] == b[i+1]:
        d = b[i]

l, r = -1, -1
for i in range(n+1):
    if l < 0:
        if a[i] == d:
            l = i
    else:
        if a[i] == d:
            r = i

f = [1 for _ in range(n+2)]
f_inv = [1 for _ in range(n+2)]
mod = 10 ** 9 + 7
for i in range(1, n+2):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)

def comb(n, k):
    return f[n] * f_inv[k] * f_inv[n-k] % mod


for k in range(1, n+2):
    ans = 0

    if k >= 2:
        ans += comb(n-1, k-2)
        ans %= mod

    if n - 1 >= k:
        ans += comb(n-1, k)
        ans %= mod

    if n >= k:
        ans += 2 * comb(n-1, k-1)
        ans %= mod

    if n + l - r >= k - 1:
        ans -= comb(n+l-r, k-1)
        ans %= mod

    print(ans)


Measured memory_bytes: 17300
package main

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

func main() {
	n := readi()

	fmt.Println(n/500*1000 + (n%500)/5*5)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640