akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC102 C

N = int(input())
A = list(map(int,input().split()))

B = [A[i]-(i+1) for i in range(N)]
B.sort()
b = B[N//2]
ans = 0
for i in range(N):
    ans += abs(A[i]-(b+i+1))
print(ans)


Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
  ll n,k,ans=0;
  cin >> n >> k;
  ll v[100];
  FOR(i,n){
    cin >> v[i];
    
  }
  
  

  for(int i=0;i<=min(k,n);i++){
    for(int j=0;j<=min(k-i,n-i);j++){
      vector<ll> a;
      for(int l=0;l<n;l++){
        if(l<i || n-j-1<l){
          a.push_back(v[l]);
        }
      }
      sort(a.begin(),a.end());
      ll sum=0;
      FOR(o,min((ll)a.size(),k-i-j)){
        if(a[o]<0){
          sum-=a[o];
        }
      }
      FOR(o,a.size()){
        sum+=a[o];
      }
      chmax(ans,sum);
    }
  }
  
  cout << ans << endl;
  
}


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

int main() {
	int n, counter = 0;
	int d[105][2];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i][0];
		cin >> d[i][1];
	}
	for (int i = 0; i < n; i++) {
		if (d[i][0] == d[i][1]) {
			counter += 1;
		}
		else {
			counter = 0;
		}
		if (counter == 3)break;
	}
	if (counter == 3)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    string s; cin>>s;
    ll n =s.size();
    rep(i,0,n)cout<<'x';
    
    return 0;
}
/*
5 2
. #
# #
# .
# #
. #
*/


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int size = Integer.parseInt(br.readLine());
		Set<String> dictionary = new HashSet<String>();
		String[] commands;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			commands = br.readLine().split(" ");
			if (commands[0].startsWith("i")) {
				dictionary.add(commands[1]);
			} else {
				if (dictionary.contains(commands[1])) {
					sb.append("yes").append("\n");
				} else {
					sb.append("no").append("\n");
				}
			}
		}
		System.out.print(sb);
	}
}

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

const ll int INF = 1e18 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a;
    cin>>b;
    vector<vector<ll int>> dp(a.length()+1, vector<ll int>(b.length()+1,0));
    // vector<pair<ll int, ll int >> dp1(a.length()+1, vector<ll int>(b.length()+1,make_pair(0,0)));
    for(ll int i=1;i<=a.length();i++){
    	for(ll int j=1;j<=b.length();j++){
    		if(a[i-1] == b[j-1]){
    			dp[i][j] = max(dp[i-1][j-1]+1,dp[i][j]);
    			// if(dp[i][j] == (dp[i-1][j-1]+1))
    			// 	dp1[i][j] = make_pair(i-1,j-1);
    			// cout<<"dp: "<<dp[i][j];
    		}
    		// else
    		dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
    		// cout<<dp[i][j]<<endl;
    	}
    }
    // cout<<dp[a.length()][b.length()]<<endl;
    ll int i = a.length();
    ll int j = b.length();
    // pair<ll int, ll int > cur = {a.length(),b.length()};
    string c;
    while(i>0 && j>0 && dp[i][j]>0){
    	if(dp[i][j] == (dp[i-1][j-1]+1) && a[i-1]==b[j-1]){
    		// cout<<dp[i][j]<<" "<<dp[i-1][j-1]<<" "<<a[i-1]<<" "<<b[j-1]<<" "<<c<<endl;
    		assert(a[i-1]==b[j-1]);
    		c += a[i-1];
    		i-=1;j-=1;	
    	}
    	else if(dp[i][j] == (dp[i-1][j])){
    		i-=1;
    	}
    	else{
    		j-=1;
    	}
    }
    reverse(c.begin(),c.end());
    if(dp[a.length()][b.length()] != 0)
    cout<<c;
	else
		cout<<"";
	return 0;
}

Measured memory_bytes: 70784
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	if (d == 1) {
		int t = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				t++;
			}
		}

		cout << t << endl;
		return 0;
	}

	vector<vector<int>> tb(n, vector<int>(d));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> tb[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {

			int tmp = 0;
			for (int k = 0; k < d; k++) {

				int val = abs(tb[i][k] - tb[j][k]);

				tmp += (val*val);

			}

			bool f = false;
			for (int k = 0; k < 300; k++) {
				int val2 = k * k;
				if (tmp==val2) {
					f = true;
				}
			}

			if (f==true) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,s[1000];
void push(int x)
{
	s[++top]=x;
}
int pop()
{
	top--;
	return s[top+1];
}
int main()
{
	int a,b,result;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
		{
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-')
		{
			b=pop();
			a=pop();
			push(a-b);
		}
		else if(s[0]=='*')
		{
			a=pop();
			b=pop();
			push(a*b);
		}
		else
		{
			result=atoi(s);
			push(result);
		}
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2764
import heapq

def main():
    n,m = map(int, input().split())
    A = list(map(lambda x: -int(x), input().split()))

    heapq.heapify(A)
    for i in range(m):
        temp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-temp_min//2))
    print(-sum(A))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int imax = INT_MAX;
int imin = INT_MIN;
ll llmax = LLONG_MAX;
ll llmin = LLONG_MIN;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int k(0); bool f = false;
	while (!f) {
		f = true;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] == i + 1 && a[i + 1] == i + 2)
			{
				f = false;
				k++;
				int t = a[i + 1];
				a[i + 1] = a[i];
				a[i] = t;
				i++;
			}
		}
	}
	f = false;
	while (!f) {
		f = true;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] == i + 1 || a[i + 1] == i + 2)
			{
				f = false;
				k++;
				int t = a[i + 1];
				a[i + 1] = a[i];
				a[i] = t;
				i++;
			}
		}
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;

class Program {
    static void Main (string[] args) {
        int K = int.Parse (Console.ReadLine ());
        string[] S = Console.ReadLine ().Split (' ');
        int A = int.Parse (S[0]);
        int B = int.Parse (S[1]);

        int temp1 = (int) Math.Ceiling ((double) A / (double) K);
        int temp2 = (int) Math.Floor ((double) B / (double) K);

        if (temp1 <= temp2) {
            Console.WriteLine ("OK");
        } else {
            Console.WriteLine ("NG");
        }
    }
}

Measured memory_bytes: 27548
import scala.io.{ StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val a = Iterator.continually(in.readLine.toCharArray)
    .take(n)
    .toArray
  val b = Iterator.continually(in.readLine.toCharArray)
    .take(m)
    .toArray
  val ans = {
    var isExsit = false
    for {
      i <- 0 to n-m
      if !isExsit
      j <- 0 to n-m
      if !isExsit
      } {
        var isCont = true
        val res0 = for {
          k <- 0 until m
          if isCont
          l <- 0 until m
          if isCont
        } {
          isCont = a(i+k)(j+l) == b(k)(l)
        }
        isExsit = isCont
      }

    if(isExsit) "Yes" else "No"
  }
  println(ans)
}

Measured memory_bytes: 25524
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll StringToNumber(string s)
{
    stringstream geek(s);
    ll x=0;
    geek>>x;
    return x;
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
ll ans=0;
void calc(string s,ll sum)
{
    int n=s.length();
    int i;
    if(n==0)
    return ;
    else if(n==1){
        ans+=sum+s[0]-'0';
        return ;
    }
    f(i,1,n){
        ll x=StringToNumber(s.substr(0,i));
        calc(s.substr(i),sum+x);
    }
    ans+=sum+StringToNumber(s);
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,k,l,temp=0;
    string s;
    cin>>s;
    calc(s,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int [] in = new int [a];
		int max = 0;
        int point = -1;
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                             if(max<=in[i]){max = in[i];point=i;}
                            }
        Arrays.sort(in);        		
        for(int i=0;i<a;i++){if(in[a-2]<in[a-1] && i==point)
                            {System.out.println(in[a-2]);}
                            else{System.out.println(in[a-1]);}}        
	}
}


Measured memory_bytes: 103308
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def M(n): return ModInt(n)
def MI(): return M(I())

class ModInt():
    def __init__(self, n):
        self.n = n

    def __add__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n+x) % mod)

    def __sub__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n-x) % mod)

    def __mul__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n*x) % mod)

    def __truediv__(self, x):
        x = ModInt.xn(x)
        return ModInt(self.n * pow(x, mod-2, mod) % mod)

    @classmethod
    def xn(cls, x):
        if isinstance(x, ModInt):
            return x.n
        return x

    def __str__(self):
        return str(self.n)

def main():
    n,m = LI()
    a = LI_()
    b = [0] * (m*2)
    c = [[] for _ in range(m*2)]
    r = 0
    for i in range(1,n):
        d = a[i-1]
        e = a[i]
        if e < d:
            e += m
        b[d+2] += 1
        c[e].append(e-d-1)
        r += e-d

    f = [0] * (m*2)
    t = 0
    tt = 0
    for i in range(1,m*2):
        t += b[i]
        tt += t
        f[i] += tt
        for g in c[i]:
            t -= 1
            tt -= g
    for i in range(m):
        f[i] += f[i+m]

    return r - max(f)

print(main())





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

int main(){
	while(1){
		long z;
	
		scanf(" %ld", &z);
		if(z==0) break;
		
		long cube=z*z*z;
		long ans=cube;
		
		//x,yの組を探す(x>y)
		for(long x=z-1; x>0; --x){
			long c1=x*x*x;
			
			for(long y=x; y>0; --y){
				long c2=y*y*y;	
				long t=cube-c1-c2;
				if(0<t && t<ans) ans=t;
			}
		}
		
		printf("%ld\n", ans);
	}
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	init();
	set<int> s;
	int a;
	lp(i, 3){
		cin >> a;
		s.insert(a);
	}
	cout << ((s.size() == 2)?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] b = new int[N];
		for(int i=0; i<N; i++)
			b[i] = sc.nextInt();

		int[] ans = new int[N];
		for(int i=N; i>=1; i--) {
			int j=i-1;
			while(j>=0) {
				if(b[j]==j+1) {
					ans[i-1] = j+1;
					for(int k=j; k<i-1; k++) {
						b[k] = b[k+1];
					}
					break;
				}
				j--;
			}
			if(j<0) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}

		for(int i=0; i<N; i++)
			System.out.println(ans[i]);
		sc.close();
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1}, INF = 1e9;

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int main(){
  int R, C, M;
  cin >> R >> C >> M;
  vector<string> S(R);
  for(int i = 0; i < R; ++i) cin >> S[i];
  map<int,int> mp;
  int n = 0;
  for(int i = 0; i < R; ++i){
    for(int j = 0; j < C; ++j){
      if(S[i][j] == '.'){
        mp[i*C+j] = n;
        ++n;
      }
    }
  }
  vector< vector<int> > D(n, vector<int>(n,INF));
  for(int x = 0; x < R; ++x){
    for(int y = 0; y < C; ++y){
      if(S[x][y] == '.'){
        for(int j = 0; j < 4; ++j){
          int x_ = x + dx[j], y_ = y + dy[j], i = mp[x*C+y];
          if(in_range(x_,R) && in_range(y_,C) && S[x_][y_] == '.'){
            int v = mp[x_*C+y_];
            D[i][v] = 1;
          }
        }
      }
    }
  }
  for(int i = 0; i < n; ++i) D[i][i] = 0;
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        D[i][j] = min(D[i][j],D[i][k] + D[k][j]);
      }
    }
  }

  vector< vector<int> > G(n, vector<int>(n,-1));
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(i == j) continue;
      for(int k = 0; k < n; ++k){
        if(D[i][k] == 1 && D[i][j] == D[i][k] + D[k][j]){
          G[i][j] = k;
          break;
        }
      }
    }
  }
  

  vector<int> P(n), OnOff = P;
  int t;
  for(int i = 0; i < R; ++i){
    for(int j = 0; j < C; ++j){
      cin >> t;
      if(t > 0) P[mp[i*C+j]] = t;
    }
  }
  for(int i = 0; i < R; ++i){
    for(int j = 0; j < C; ++j){
      cin >> t;
      if(t > 0) OnOff[mp[i*C+j]] = t;
    }
  }
  for(int i = 0; i < R; ++i){
    for(int j = 0; j < C; ++j){
      cin >> t;
      if(t > 0) OnOff[mp[i*C+j]] += t;
    }
  }
  int x, y;
  cin >> x >> y;
  vector<int> T(n,-1);
  T[mp[x*C+y]] = 0;
  t = 0;
  int v = mp[x*C+y];
  long long int ans = OnOff[v];
  for(int i = 1; i < M; ++i){
    cin >> x >> y;
    int v_ = mp[x*C+y];
    while(v != v_){
      v = G[v][v_];
      ++t;
      if(T[v] < 0){
        T[v] = t;
        ans += OnOff[v];
      }else{
        ans += min((long long int)OnOff[v], (long long int)(P[v]*(t-T[v])));
        T[v] = t;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
  int N;
  scanf("%d", &N);
  
  vector<int64_t> L(87);
  L.at(0) = 2LL, L.at(1) = 1LL;
  
  for (int i = 2; i <= N ; i++) {
  L.at(i) = L.at(i - 2) + L.at(i - 1);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <deque>

using namespace std;

typedef long long ll;

int N, A, B, C, D;
int main() {
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	for (int i = 0; i <= N - 1; i++) {
		ll minVal = (ll)i * C - (ll)(N - i - 1) * D + A;
		ll maxVal = (ll)i * D - (ll)(N - i - 1) * C + A;
		if (B >= minVal && B <= maxVal) {	
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    long double l;
    cin >> l;
    long double len = l / 3;
    cout << fixed << setprecision(8);
    cout << (l / 3) * (l / 3) * (l / 3) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])

Measured memory_bytes: 68004
use std::io::*;
use std::str::FromStr;

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();

    let mut s = false;
    for i in 1..b+1 {
        if (a * i) % b == c {
            s = true;
            break;
        }
    }

    println!("{}", if s { "YES" } else { "NO" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextInt();
    int n = sc.nextInt();
    int a[] = new int[n];
    int total = 0;
    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n ; i++){
      total = total + a[i];
    }
    if(h<=total){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 50644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		long ans = 1;
		for (int i = 1; i <= N; i++) {
			ans = (i * ans) % (1000000000 + 7);
		}

		System.out.print(ans);
	}
}

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

using namespace std;
const long mod = 1000000007;
typedef unsigned long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
const lint hosii = 5000000000000000;
lint ctoli(char c){
  return c-'0';
}
int main() {
  str(s);
  lint k;cin>>k;
  k-=1;
  lint ans = 0;
  rep(i,length(s)){
    lint keta = ctoli(s.at(i));
    
    if(hosii>=log(k)/log(keta)){
      ans = keta;
      break;
    }else{
      k-=pow(keta,hosii);
    }
  }
  prln(ans);
  
}


Measured memory_bytes: 512
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {

    let mut ss : Vec<Vec<char> > = vec![];

    for _ in 0..3 {
        ss.push(read_line().chars().collect());
    }


    for i in 0..3 {
        print!("{}", ss[i][i])
    }
    println!("");
    
}


Measured memory_bytes: 4352
def cmb(n, k, mod, fac, ifac):    
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

n,m,k = map(int,input().split())
f=[0 for _ in range(n)]
mod=998244353
for i in range(n):
    if i == 0:
        f[i]=m
    else:
        f[i]=(f[i-1]*(m-1))%mod
c=1
ans=0
if k==0:
    print(f[n-1])
    exit()
fac, ifac = make_tables(mod, n)
for i in range(k+1):
    ans+=f[n-1-i]*c
    ans%=mod
    #print(f[n-1-i],c)
    
    c=cmb(n-1,i+1,mod,fac,ifac)

print(ans%mod)

Measured memory_bytes: 40728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef pair<int,int> P;
const int INF = 1e9+7;

int main(){
    int N,K;
    cin >> N >> K;
    if(N%K){
        cout << "1";
    }else{
        cout << "0";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r=0,i;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(s[i]=='+')
            r++;
        else if(s[i]=='-')
            r--;
    }
    cout<< r << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

Measured memory_bytes: 13680
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
using namespace std;

bool serch(int S[], int n, int key) {
	S[n] = key;
	int i = 0;
	while (S[i] != key) {
		i++;
	}
	return i != n;
}

int main() {
	int n, q;
	int S[10010];
	scanf("%d", &n);
	for (int i=0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	int key;
	int count = 0;
	for (int i=0; i < q; i++) {
		scanf("%d", &key);
		if (serch(S, n, key)) {
			count++;
		}
	}
	
	printf("%d\n", count);
	
	
	return 0;
}


Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

struct M {
	ll l, r;
	bool f;
};

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

	vector<vector<M>> m(100, vector<M>());
	m[1].pb({ 1,2,true });
	m[1].pb({ 1,3,false });
	bool br = false;
	for (int i = 1; i < 99; i++) {
		for (M j : m[i]) {
			if (j.f) {
				m[i + 1].pb({ j.r,j.l + j.r,true });
				m[i + 1].pb({ j.r,j.l + 2 * j.r,false });
			}
			else m[i + 1].pb({ j.r,j.l + j.r,false });
			if (j.l + j.r > INF * 4) br = true;
		}
		if (br) break;
	}
	m[1].pb({ 1,1,true });
	vector<ll> fib(91);
	fib[0] = 1, fib[1] = 2;
	rep(i, 89) fib[i + 2] = fib[i + 1] + fib[i];
	int q;
	cin >> q;
	while (q--) {
		ll x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		if (x == 1) cout << 1 << ' ' << y % mod << '\n';
		else {
			int px = upper_bound(all(fib), x) - fib.begin(); px--;
			int py = upper_bound(all(fib), y) - fib.begin(); py--;
			if (px == py) {
				int cnt = 0;
				for (M i : m[px]) {
					if (i.l <= x && i.r <= y) cnt++;
					if (i.r <= x && i.l <= y) cnt++;
				}
				cout << px << ' ' << cnt << '\n';
			}
			else {
				px++;
				ll ans = 0;
				for (M i : m[px]) {
					if (i.l == fib[px - 1] && i.r == fib[px + 1]) continue;
					if (i.l > x) continue;
					if (y >= i.r) ans += (y - i.r) / i.l + 1;
					ans %= mod;
				}
				cout << px << ' ' << ans << '\n';
			}
		}
	}
}

Measured memory_bytes: 4224
def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()


def main():
    N = iRaw()
    Xs = isRaw()
    nowCost = INF
    nowC = -1
    for c in range(1,101):
        cost =sum([(x-c)**2 for x in Xs])
        if nowCost > cost:
            nowCost = cost
            nowC = c

    return nowCost
    


if __name__ == "__main__":
    print(main())


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(a==c) cout<<b<<endl;
    else cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::vector<int> v;
    for(int i = 0;i < S.size(); i++){
        char ch = S[i];
        if(ch == 'A'|| ch == 'C' || ch == 'G' || ch == 'T'){
            v.push_back(i);
        }
    }

    std::cout << std::endl;
    int len = 0;
    for(int i = 0; i < v.size(); i++){
        int j;
        for(j = i + 1; j < v.size(); j++){
            int k = (j == i + 1) ? v[i] : v[j - 1];
            if(v[j] == k + 1){
                continue;
            }else{
                len = std::max(len, j - i);
                break;
            }
        }
        if(j == v.size()){
            len = std::max(len, j - i);
        }
    }
    std::cout << len << std::endl;
    return 0;
}


Measured memory_bytes: 256
#input one int
#a = int(input())

#input some val
#a, b, c = (int(i) for i in input().split())
#val = [[int(i) for i in input().split()] for i in range(N)]

#input matrix
#a = [input().split() for i in range()]

S = input()
cnt = 0

for i in range(4):
    if(S[i] == '+'):
        cnt = cnt + 1
    else:
        cnt = cnt - 1

print(cnt)

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    auto n = std::size_t();

    std::cin >> n;

    auto x = std::vector<int>(n);
    auto l = std::vector<int>(n);

    for (std::size_t i = 0; i < n; ++i) std::cin >> x[i] >> l[i];

    auto section = std::vector<std::pair<int, int>>();
    for (std::size_t i = 0; i < n; ++i) section.emplace_back(x[i] + l[i], x[i] - l[i]);

    auto comp = [](auto a, auto b) { return a.first < b.first; };
    std::sort(section.begin(), section.end(), comp);

    auto result = std::size_t(n);
    auto t = section[0].first;
    for (std::size_t i = 1; i < n; ++i)
    {
        if (section[i].second < t)
            --result;
        else
            t = section[i].first;
    }

    std::cout << result << std::endl;

    return 0;
}

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

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

  map<int,vector<pair<int,int>>> mp;
  
  vector<int> pv,yv;
  for(int i=0; i<m; i++){
    int p, y;
    cin >> p >> y;
    mp[p].push_back(make_pair(y,i));
    pv.push_back(p);
    yv.push_back(y);
  }
  
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    sort((itr->second).begin(), (itr->second).end());
    int a = 0;
    for(auto itr2 = (itr->second).begin(); itr2 != (itr->second).end(); itr2++){
      itr2->second = a;
      a++;
    }
  }

  map<int, int> q;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    for(auto itr2 = (itr->second).begin(); itr2 != (itr->second).end(); itr2++){
      q[(itr2->first)] = (itr2->second);
    }
  }

  for(int i=0; i<m; i++){
    printf("%06d%06d", pv[i], q[yv[i]]+1);
    cout << endl;
  }
}

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

int main()
{
    int x[4], y[4];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    x[2] = x[1] + y[0] - y[1];
    y[2] = y[1] + x[1] - x[0];
    x[3] = x[0] + y[0] - y[1];
    y[3] = y[0] + x[1] - x[0];
    cout << x[2] << " " <<  y[2] << " " <<  x[3] << " " << y[3] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+10,p=1e9+7;
int n,f[N],fp,fz,g[N],gp,gz;
long long A,B,s[N];
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	for (int i=1;i<=n;++i) scanf("%lld",s+i);
	s[0]=-2e18;
	f[0]=1;g[0]=1;
	for (int i=2;i<=n;++i){
		while (fp<i-2&&s[i]-s[fp+1]>=A) ++fp;
		f[i-1]=g[fp];
		while (gp<i-2&&s[i]-s[gp+1]>=B) ++gp;
		g[i-1]=f[gp];
		if (s[i]-s[i-1]<A){
			while (fz<i-1) f[fz++]=0;
		}else (f[i-1]+=f[i-2])%=p;
		if (s[i]-s[i-1]<B){
			while (gz<i-1) g[gz++]=0;
		}else (g[i-1]+=g[i-2])%=p;
	}
	printf("%d",(f[n-1]+g[n-1])%p);
	return 0;
}

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


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N;
    cin>>N;
    map<ll,ll> m;
    v lis;
    rep(i,2,1000001){
        while(N%i == 0){
            m[i]++;
            N /= i;
            if(m[i] == 1)lis.PB(i);
        }
    }
    if(N != 1){
        m[N]++;lis.PB(N);
    }
    ll ans  =0 ;
    for(ll elem : lis){
        rep(i,1,50){
            if(m[elem] >= i){
                m[elem]-=i;
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::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 rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  int n, k;

  cin >> n >> k;

  vector<int> h(n);
  fillInt(h, n);

  int cnt = 0;
  rep(i, n) {
    if(h[i] >= k) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};


int n, m, k, l;

vector<vector<int>> g;

bool vis[200010];

void dfs(int v) {
    vis[v] = true;
    for (auto &c : g[v]) {
        if (!vis[c]) dfs(c);
    }
}

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

    cin >> n >> m;
    g.resize(n + m);
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> l;
            l = l - 1 + n;
            g[i].emplace_back(l);
            g[l].emplace_back(i);
        }
    }
    dfs(0);
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  for (int i = 0; i < N; i++) {
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  
  bool ans = true;
  
  for (int i = 0; i < N-1; i++) {
    if (num.at(i) == num.at(i + 1)) {
      ans = false;
    }
  }
  
  if (ans) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3,mod=1e9+7;
ll n,m,k,f[maxn][maxn],g[maxn]={1},match[maxn],vis[maxn],pre[maxn],ans,u,v;
signed main(){
	scanf("%lld%lld",&n,&m),n<<=1;
	for(ll i=1;i<=m;++i){
		scanf("%lld%lld",&u,&v);
		vis[match[u]=v]=vis[match[v]=u]=1;
	}
	for(ll i=1;i<=n;++i)pre[i]=pre[i-1]+(!vis[i]);
	for(ll i=2;i<=n;i+=2)g[i]=g[i-2]*(i-1)%mod;
	for(ll i=2;i<=n;i+=2)for(ll l=1;l<=n-i+1;++l){
		ll r=l+i-1;
		for(ll j=l;j<=r;++j)if(match[j]&&(match[j]<l||match[j]>r))goto end;
		f[l][r]=g[pre[r]-pre[l-1]];
		for(ll j=l+1;j<r;j+=2)(f[l][r]+=(mod-f[l][j]*g[pre[r]-pre[j]]%mod))%=mod;
		(ans+=g[(pre[n]-pre[r]+pre[l-1])]*f[l][r]%mod)%=mod;
		end:;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    bool ans = true;
    if(N % 2 == 0) {
        for(int i = 0; i < N / 2; ++i) {
            if(S[i] != S[i + N / 2])
                ans = false;
        }
        cout << (ans ? "Yes" : "No") << endl;
    } else
        cout << "No" << endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        a[i] -= i;
    }

    sort(ALL(a));
    ll ans = 0;
    int m = n / 2;

    rep(i, n)
        ans += abs(a[i] - a[m]);

    OP(ans);

    return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<pi, null_type, less<pi>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>n>>k;
    forn(i,1,n)
    {
        cin>>arr[i];
        arr[i]-=k;
    }

    int sum = 0;
    int ans = 0;
  //  if(sum>=0)ans++;
    int c = 50;
    oset dc;
    dc.insert({0,c++});
    forn(i,1,n)
    {
     //   cout<<arr[i]<<" ";

        sum+=arr[i];
        ans+=dc.order_of_key({sum+1,-1});
        dc.insert({sum,c++});
    }
    //if(sum>=0)ans++;
    cout<<ans;

}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

using namespace std;

#define rep(x,a,b)         for(int x = a; x < b; x++)
#define per(x,a,b)         for(int x = a; x >= b; x--)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
const int maxn = 1100;
char s1[maxn], s2[maxn];

int main(void)
{
    scanf("%s%s", s1, s2);
    int n = strlen(s1), m = strlen(s2);
    int ans = INT_MAX;
    for(int i = 0; i + m - 1 < n; i++) {
        int cnt = 0;
        rep(j, 0, m) if(s2[j] != s1[i + j]) ++cnt;
        smin(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=5005;
const int INF=0x3f3f3f3f;
vi G[maxn];
int x[maxn];
int dp[maxn];
bool ok=1;
void dfs(int u,int fa=-1)
{
    vi f(maxn,INF);
    f[0]=0;
    for(auto v:G[u])
    {
        dfs(v,u);
        vi g(maxn,INF),h(maxn,INF);
        for(int i=x[v];i<maxn;i++) g[i]=min(g[i],f[i-x[v]]+dp[v]);
        for(int i=dp[v];i<maxn;i++) h[i]=min(h[i],f[i-dp[v]]+x[v]);
        for(int i=0;i<maxn;i++) f[i]=min(g[i],h[i]);
    }
    dp[u]=f[0];
    for(int i=1;i<=x[u];i++) dp[u]=min(dp[u],f[i]);
    if(dp[u]==INF) ok=0;
    //dbg(u,dp[u]);
    //dbg(f);
}
int main()
{
    int n;
    cin>>n;
    for(int i=2,p;i<=n;i++)
    {
        cin>>p;
        G[p].push_back(i);
    }
    for(int i=1;i<=n;i++) cin>>x[i];
    dfs(1);
    if(!ok) cout<<"IMPOSSIBLE\n";
    else cout<<"POSSIBLE\n";
}

Measured memory_bytes: 8888
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main(){
    int n;cin>>n;
    int flag=1;
    int idx=0;
    int now=0;
    vector<int> b(n);
    vector<int> ans(n);
    for(int i=0;i<n;i++) cin>>b[i];

    while(flag==1&&b.size()>0){
        now=b[0];
        if(b.size()==1){
            if(now==1) ans[idx]=1;
            else flag=0;
            break;
        }
        for(int j=b.size()-1;j>0;j--){
            int c=b[j];
            if(c==j+1){
                ans[idx]=c;
                auto it=b.begin() + j;
                b.erase(it);
                break;
            }
            if(j==1&&now==1){
                ans[idx]=1;
                b.erase(b.begin());
            }
            else if(j==1&&now!=1) flag=0;
        }
        idx++;
    }

    if(flag==1){
        for(int i=n-1;i>=0;i--) cout<<ans[i]<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}
 



Measured memory_bytes: 256