akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define N 1000001

int dp[N], dp1[N];

void gen()
{
    memset(dp, 37, sizeof(dp));
    memset(dp1, 37, sizeof(dp1));
    dp[0] = dp1[0] = 0;

    for (int n = 1; ; ++n) {
        int p = n * (n + 1) * (n + 2) / 6;
        if (p >= N)
            break;
        for (int i = p; i < N; ++i) {
            dp[i] = min(dp[i], dp[i - p] + 1);
            if (p & 1)
                dp1[i] = min(dp1[i], dp1[i - p] + 1);
        }
    }
}

int main()
{
    gen();

    int t;
    while (cin >> t && t)
        cout << dp[t] << ' ' << dp1[t] << endl;

    return 0;
}

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

int main(){
  int A,B,C,X,comb = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0;i <= A;i++){
    for (int l = 0;l <= B;l++){
      for (int m = 0;m <= C;m++)
        if (500*i + 100*l + 50*m == X) comb++;
    }
  }
  cout << comb << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int n;
int f[110][100];
long long p[110][100];
int main() {
	cin >> n;
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	long long ans = -INF;
	FOR(i, 1, (1 << 10)) {
		long long sum = 0;
		rep(j, n) {
			long long cnt = 0;
			rep(k, 10) {
				if (i&(1 << k) && f[j][k])cnt++;// i&(1 << k) iのk番目のビットが立ってるか　&論理積
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] a = { 1, 2, 4, 8, 16, 32, 64 };
        int p = int.Parse(Console.ReadLine());
        Console.WriteLine(a.TakeWhile(x => p >= x).Last());
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    cout << pow(N,3);
    


}

/*



 */



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

using namespace std;



string s, t;
vector<vector<int>> cc;


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

	cc = vector<vector<int>>(26, vector<int>(0));

	unsigned l = s.size();
	for (unsigned i = 0; i < l; i++) {
		cc.at(s.at(i) - 'a').push_back(i);
	}

	l = t.size();
	bool cont = true;
	unsigned long long loop = 0;
	int index = -1;
	for (unsigned i = 0; i < l && cont; i++) {
		vector<int>& c = cc.at(t.at(i) - 'a');
		unsigned cs = c.size();

		if (cs == 0) {
			cont = false;
			break;
		}
      
		auto it = upper_bound(c.begin(),c.end(),index);

		if (it == c.end()) {
			loop++;
			index = c.at(0);
		}
		else {
			index = *it;
		}
		
	}

	if (!cont) {
		cout << -1 << endl;
	}
	else {
		unsigned long long ans = loop * s.size() + index + 1;
		cout << ans << endl;
	}

	return 0;
}


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

int l[10], v1, v2;

int main(){
    while( scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
                   l,l+1,l+2,l+3,l+4,l+5,l+6,l+7,l+8,l+9,
                   &v1, &v2) != EOF ){
        int sl = 0;
        for(int i = 0; i < 10; i++){
            sl += l[i];
        }
        double p = (double)sl*v1/(v1+v2);
        int i, k = 0;
        for(i = 0; i < 10; i++){
            k += l[i];
            if( p <= k ) break;
        }
        printf("%d\n", i+1);
    }

    return 0;
}

Measured memory_bytes: 1024
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

N, K = map(int, input().split())
print( len(str(Base_10_to_n(N, K)) ))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    if(K==0){
        pr(N*N);
        return 0;
    }
    Rep(i, K+1, N+1){
        ans += (N/i)*(i-K);
        ans += max(0LL,(N%i+1)-K);
    }
    pr(ans);
}

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

int main(){
  long long h;
  int n;
  cin >> h >> n;
  vector<int> a(n);
  for(auto& i : a){
    cin >> i;
  }
  
  string ans = "Yes";
  long long sum = 0;
  for(auto& j : a){
    sum += j;
  }
  if(h-sum > 0){
    ans = "No";
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#define int long long
using namespace std;
int N, x;
signed main(){
    cin >> N;
    int cnt = 0;
    for(int i = 1; i <= N; ++i){
        int x; cin  >> x;
        if(i % 2 == 1 && x % 2 == 1) cnt++;
    }
    cout <<cnt;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);
 

int main()
{
   ll n;
   cin>>n;
   ll m = n*1ll*(n-1);
   m = m/2;
   cout<<m<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1000000007;
//const int N = 1e5+5, M = N;
//=========================================

const int MAXN = 3005;
double dp[MAXN][MAXN], P[MAXN];
int vis[MAXN][MAXN], N;

double solve(int pos, int heads){

    if(heads < 0) return 0.0;

    if(pos == 0)
        return (heads == 0);

    if(vis[pos][heads])
        return dp[pos][heads];

    vis[pos][heads] = 1;
    dp[pos][heads] = P[pos] * solve(pos - 1, heads - 1) + (1 - P[pos]) * solve(pos - 1, heads);

    return dp[pos][heads];
}

int32_t main() {

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

    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> P[i];

    double probability = 0;
    for(int heads = 0; heads <= N; ++heads){
        int tails = N - heads;
        if(heads > tails) probability += solve(N, heads);
    }

    cout << fixed << setprecision(10) << probability << endl;

    return 0;
}


Measured memory_bytes: 140928
package main

import "fmt"

func main() {
	var a, b, c int64

	fmt.Scan(&a, &b, &c)
	if a%c != 0 {
		a += c - a%c
	}
	if b%c != 0 {
		b -= b % c
	}

	if a > b {
		fmt.Print(0)
	} else {
		fmt.Print((b-a)/c + 1)
	}
}


Measured memory_bytes: 512
using System;
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            int a = int.Parse(input[2]);
            //出力
            Console.WriteLine( (b+c < a ? "No" : "Yes" ) );
            Console.ReadLine();
        }
    }

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

int N, M;
int adj[8][8];
int cnt = 0;

void dfs(int state, int place) {
    if (state == int(1<<N)-1) {
        cnt++;
        return;
    }
    REP(i,N) {
        if ( (state>>i&1) != 1 && adj[place][i]) {
            dfs(state+(1<<i),i);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i,M) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        adj[a][b]=1;
        adj[b][a]=1;
    }
    dfs(1,0);
    cout << cnt << endl;
    
    return 0;
}

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

ll n, x;

int main(){
	cin >> n;
	while (n--){
        cin >> x;
        if (x&1){
            cout << "first";
            return 0;
        }
	}
	cout << "second";
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int[] nums;
    int N;
    long[] preSum;

    public Main(int[] nums){
        this.nums=nums;
        N=nums.length;
    }
    long getMaxSum(){
        if(N<4){
            Arrays.sort(nums);
            return nums[N-1];
        }

        long max=0;
//      结尾一定要被取到
        long[] ext0max=new long[N];
        Arrays.fill(ext0max, -1000000000000000L);
        long[] ext1max=new long[N];
        Arrays.fill(ext1max, -1000000000000000L);
        long[] ext2max=new long[N];
        Arrays.fill(ext2max, -1000000000000000L);
        ext0max[0]=nums[0];
        ext0max[2]=nums[0]+nums[2];
        ext1max[1]=nums[1];
        ext1max[3]=nums[3]+Math.max(nums[0],nums[1]);
        ext2max[2]=nums[2];
        for (int i = 4; i <N ; i++) {
            ext0max[i]=ext0max[i-2]+nums[i];
            ext1max[i]=Math.max(ext1max[i-2]+nums[i],ext0max[i-3]+nums[i]);
            ext2max[i]=Math.max(ext2max[i-2]+nums[i],Math.max(ext1max[i-3]+nums[i],ext0max[i-4]+nums[i]));
        }
        if (N%2==0){
            max=Math.max(ext1max[N-1],ext0max[N-2]);
        }else{
            max=Math.max(ext2max[N-1],Math.max(ext1max[N-2],ext0max[N-3]));
        }
        return max;
    }

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int[] nums =new int[N];
        for (int i = 0; i <N ; i++) {
            nums[i]=scan.nextInt();
        }
        Main solve=new Main(nums);
        System.out.println(solve.getMaxSum());
    }
}


Measured memory_bytes: 61568
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	string S;
	cin >> S;

	//calculation
	int len = S.size();
	for (int i = 0; i < len; i += 2) {
		if (S[i] == 'h' && S[i + 1] == 'i') {
			continue;
		} else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

n = int(input())
points = []
for i in range(n):
    x, y = map(int, input().split())
    points.append([x, y, i])

edge = []
points.sort()
for i in range(1, n):
    dist = points[i][0] - points[i-1][0]
    edge.append((points[i][2], points[i-1][2], dist))
    edge.append((points[i-1][2], points[i][2], dist))

points.sort(key=lambda x: x[1])
for i in range(1, n):
    dist = points[i][1] - points[i-1][1]
    edge.append((points[i][2], points[i-1][2], dist))
    edge.append((points[i-1][2], points[i][2], dist))

# print(edge)
edge.sort(key=lambda x: x[2])
uf = UnionFind(n)
ans = 0
for u, v, cost in edge:
    if not uf.same(u, v):
        ans += cost
        uf.unite(u, v)
print(ans)


Measured memory_bytes: 67820
#include "iostream"
#include "string"

using namespace std;

int main() {
	int a, b, c;
	int n, y;
	bool flag = false;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++) {
		if (!flag) {
			a = i;
			for (int k = 0; k <= (y - 10000 * a) / 5000; k++) {
				b = k;
				c = (y - 10000 * a - 5000 * b) / 1000;
				if (a + b + c == n) {
					cout << a << " " << b << " " << c << endl;
					flag = true;
				}
			}
		}
	}
	if(!flag) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#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>

using namespace std;

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

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

ll sum(ll n) {
    if (n % 2) {
        return n % 4 == 1;
    } else {
        return n ^ (n % 4 == 2);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << (sum(a - 1) ^ sum(b)) << endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
dp = [10010] * N
dp[0] = 0
for i in range(1, N):
    if i == 1:
        dp[i] = abs(h[i] - h[0])
    else:
        c1 = dp[i-1] + abs(h[i] - h[i-1])
        c2 = dp[i-2] + abs(h[i] - h[i-2])
        dp[i] = min(c1, c2)
print(dp[-1])


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t, u;

int main() {
	cin >> s;
	inc(i, s.size()) { if(s[i] != 'x') { t += s[i]; } }
	
	u = t;
	reverse(ALL(u));
	if(u != t) { cout << -1 << endl; return 0; }
	
	s = "@" + s + "@";
	
	int i = 0, j = s.size() - 1, ans = 0;
	while(true) {
		int ic = 0, jc = 0;
		while(s[i] == 'x') { i++; ic++; }
		while(s[j] == 'x') { j--; jc++; }
		if(i <= j) { } else { break; }
		i++; j--;
		ans += abs(ic - jc);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
d=[]
for i in range(m):
  d.append(list(map(int,input().split())))
  d[i].append(1)
s=sorted(d)
k=1
if m>1:
  for i in range(m-1):
    if s[i][0]==s[i+1][0]:
      s[i][2]=k
      s[i+1][2]=k+1
      k=k+1
    else:
      k=1
      s[i+1][2]=k
      
for i in range(m):
  ans=1000000000000+d[i][0]*1000000+d[i][2]
  print(str(ans)[1:])



Measured memory_bytes: 32788
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  int ans = (n+1)*n/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
struct Card{
  char mark;
  char num;
};

void Bubble(struct Card B[], int N){
  int i, j;
 struct Card swap;
  for(i = 0; i < N; i++){
    for(j = (N - 1); j > i; j--){
      if(B[j].num < B[j - 1].num){
	swap = B[j - 1];
	B[j - 1] = B[j];
	B[j] = swap;
      } 
    }
  }
  for(i = 0; i < N; i++){
    printf("%c%c", B[i].mark, B[i].num);
    if(i < (N - 1))printf(" ");
  }
  printf("\n");
}
void Selection(struct Card S[], int N){
  struct Card swap;
  int i, j, mini, han;
  for(i = 0; i < N - 1; i++){
    han = 0;
    mini = i;
    for(j = i; j < N; j++){
      if(S[j].num < S[mini].num){
	mini = j;
	han = 1;
      }
    }
    if(han == 1){ 
      swap = S[i];
      S[i] = S[mini];
      S[mini] = swap;
    }
  }
  for(i = 0; i < N; i++){
    printf("%c%c", S[i].mark, S[i].num);
    if(i < (N - 1))printf(" ");
  }
  printf("\n");
}

int main(){
  struct Card trump[36], trump2[36];
  int N, i, han = 0;
  char ch;
  scanf("%d%c", &N, &ch); 
  for(i = 0; i < N; i++){
    scanf("%c%c%c", &trump[i].mark, &trump[i].num, &ch);
    trump2[i] = trump[i];
  }
  Bubble(trump, N);
  printf("Stable\n");
  Selection(trump2, N);
  for(i = 0; i < N; i++){
    if(trump2[i].mark != trump[i].mark){
      printf("Not stable\n");
      han = 1;
      break;
    }
  }
  if(han == 0)printf("Stable\n");
  return 0;
}

Measured memory_bytes: 612
<?php
$input = trim(fgets(STDIN));
$input = explode(' ',$input);;

if ($input[0] < $input[1]) {
    echo  "a < b". PHP_EOL;
} elseif ($input[0] > $input[1]) {
    echo "a > b". PHP_EOL;;
} else {
     echo "a == b". PHP_EOL;;
}
exit;
?>

Measured memory_bytes: 15256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<sstream>
using namespace std;
int n,m,k; 
int main()
{
	while(cin >> n){
		if(n>=30) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String str1 = s.substring(0, n / 2);
        String str2 = s.substring(n / 2);
        if (str1.equals(str2)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

//for binomial coefficients
const int MAX=510000;
vector<modint> fac(MAX,0);
vector<modint> finv(MAX,0);
vector<modint> inv(MAX,0);
void COMinit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(int i=2;i<MAX;i++){
    fac.at(i)=fac.at(i-1)*i;
    inv.at(i)=-inv.at(MOD%i)*(MOD/i);
    finv.at(i)=finv.at(i-1)*inv.at(i);
  }
}
modint COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac.at(n)*finv.at(k)*finv.at(n-k);
}


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

  COMinit();
  modint ans = 0;
  rep(i,S/3){
    int tmp = S-(i+1)*3;
    ans += COM(i+tmp,i);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 14988
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)なるxを返す
def modinv(a):
    m=MOD
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

MOD=10**9+7
N,M,K=map(int,input().split())

b=1
for i in range(N*M-2,N*M-K,-1):
    b=(b*i)%MOD

for i in range(1,K-1):
    b=(b*modinv(i))%MOD

x=0
for i in range(1,N):
   x=x+i*(N-i)

x=(x*M*M)%MOD

y=0
for j in range(1,M):
    y=y+j*(M-j)
y=(y*N*N)%MOD
    
ans=b*(x+y)%MOD
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(q),player(n,k),cnt(n);
    rep(i,0,q){
        int a; cin >> a; a--;
        cnt[a]++;
    }
    rep(i,0,n){
        player[i] += cnt[i]-q;
        if(player[i] < 1){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main() {
	int n,ans=0;
	cin>>n;
	int a[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(i==a[a[i]]){
			ans++;
		}
	}
	cout<<ans/2;
}



Measured memory_bytes: 3952
import java.util.*;

public class Main {
  public static boolean prime(int num) {
    boolean res = true;
    for (int i=2; i < num; i++) {
      if (num % i == 0) {
        res = false;
        break;
      }
    }

    return res;
  }

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] ans = new int[n];
    int point = 0;

    for (int i=6; i < 55555; i+=5) {
      if (prime(i) == true) {
        ans[point] = i;
        point++;
      }

      if (point == n) {
        break;
      }
    }

    for (int i=0; i < n; i++) {
      System.out.println(ans[i] + " ");
    }
  }
}


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

int main() {
    int n;
    cin>>n;
    int A[n+1]{0};
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        A[a]++;
    }
    for(int i=1;i<=n;i++){
        cout<<A[i]<<endl;
    }
}

Measured memory_bytes: 4360
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n, q := scanInt(),scanInt()
	t := make([][]int, n)

	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1, scanInt()-1
		t[a] = append(t[a], b)
		t[b] = append(t[b], a)
	}

	op := make([]int, n)

	for i := 0; i < q; i++ {
		p,x := scanInt()-1, scanInt()
		op[p] += x
	}

	ans := make([]int, n)

	for i := 0; i < n; i++ {
		ans[i] = -1
	}

	dfs(0, 0, t, op, ans)

	printInts(ans...)

}

func dfs(now, c int, t [][]int, op, ans []int)  {
	c += op[now]
	ans[now] = c
	for _, e := range t[now] {
		if ans[e] != -1 {
			continue
		}
		dfs(e, c, t, op, ans)
	}
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wtr, e)
		if i != len(a)-1 {
			fmt.Fprint(wtr, " ")
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++)
    cin >> d.at(i);
  int rec = 0;
  for(int i = 0; i < N; i++)
    for(int j = i + 1; j < N; j++)
      rec += d.at(i) * d.at(j);
  cout << rec << endl;
}

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

using namespace std;

int main() {
  int A[3][3];
  for (int y = 0; y < 3; y++) {
    for (int x = 0; x < 3; x++) {
      cin >> A[y][x];
    }
  }

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    for (int y = 0; y < 3; y++) {
      for (int x = 0; x < 3; x++) {
	if (A[y][x] == b) A[y][x] = -1;
      }
    }
  }

  bool found = false;
  for (int y = 0; y < 3; y++) {
    bool ok = true; 
    for (int x = 0; x < 3; x++) {
      if (A[y][x] != -1) ok = false;
    }
    if (ok) {
      found = true;
    }
  }
  for (int x = 0; x < 3; x++) {
    bool ok = true; 
    for (int y = 0; y < 3; y++) {
      if (A[y][x] != -1) ok = false;
    }
    if (ok) {
      found = true;
    }
  }
  {
    bool ok = true;
    for (int y = 0; y < 3; y++) {
      int x = y;
      if (A[y][x] != -1) ok = false;
    }
    if (ok) {
      found = true;
    }
  }
  {
    bool ok = true;
    for (int y = 0; y < 3; y++) {
      int x = 2 - y;
      if (A[y][x] != -1) ok = false;
    }
    if (ok) {
      found = true;
    }
  }

  if (found) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    ll l, r, d;
    cin >> l >> r >> d;
    ll cnt = 0;
    Fori(i, l, r+1) {
        if(i % d == 0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <algorithm>

#define MAX_ 17
#define IF 16000000

#define lengthof(x) (sizeof(x) / sizeof(*(x)))

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	unsigned int data[MAX_][MAX_];
	unsigned int dp[1<<(MAX_-1)];
	unsigned int min_;

	while(1){
		cin>>n;
		if(n==0) break;

		fill((unsigned int*)data,(unsigned int*)(data+lengthof(data)),0);
		fill((unsigned int*)dp,(unsigned int*)(dp+lengthof(dp)),IF);


		for(int i1=0;i1<n;i1++){
			for(int i2=0;i2<n+1;i2++){
				cin>>data[i1][i2];
			}
		}


		for(int i1=0;i1<n;i1++){
			dp[1<<i1]=data[i1][0];
		}


		for(int i2=0;i2<(1<<n);i2++){
			for(int i3=0;i3<n;i3++){
				int i4=i2|(1<<i3);
				if(i2!=i4){
							
					min_=data[i3][0];
					for(int i5=0;i5<n;i5++){
								
						if((i2&(1<<i5))!=0) {
							min_=min(min_,data[i3][i5+1]);
						}
					}
					dp[i4]=min(dp[i4],dp[i2]+min_);	
				}
			}
		}

		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1416
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    long long int a=0;
    for(int i=0;i<S.size();i++){
        a+=(int)(S[i]-'0');
    }

    if(a%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3380
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a,b,c,d,e,h[100];
vector<int> f,g;
int main() {
cin>>a;
for(int j=0;j<a;j++)f.push_back(0);
for(int i=0;i<a*(a-1)/2;i++){
cin>>b>>c>>d>>e;
if(d>e)f[b-1]+=3;else 
if(d<e)f[c-1]+=3;else{
f[b-1]++;f[c-1]++; }

}
g=f;
sort(g.begin(),g.end());
for(int k=0;k<a;k++){
for(int l=0;l<a;l++){
if(f[l]==g[k]){h[l]=a-k;}}
}
for(int m=0;m<a;m++){
cout<<h[m]<<endl;}
	return 0;
}


Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            ulong N = ulong.Parse(Console.ReadLine());
            ulong s = 0;
            for(ulong i=1;i<=N;++i){
              if(i%3!=0&&i%5!=0)
                s+=i;
            }
          Console.WriteLine(s);
        }
    }
}

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

int main() {
    int H, N;    
    cin >> H >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
	cin >> a[i];
	H-=a[i];
	if(H<=0){
	    cout << "Yes" << endl;
	    return 0;
	}
	
    }
    
    cout << "No"<<endl;
}



Measured memory_bytes: 640
from collections import defaultdict
N = int(input())
Ss = [input() for i in range(N)]
d = defaultdict(int)

for s in Ss:
    d[s] += 1
mx = max([d[k] for k in d.keys()])
ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
for a in sorted(ans):
    print(a) 

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

#define N 26
#define MAX_T 1.9
#define TRIAL 5
#define K 16

const long INF = 1L << 60;

int c[N];
int s[365][N];
// vector<int> sorted[365];

std::chrono::time_point<std::chrono::steady_clock> start, endt;

random_device rd;
mt19937 generator(rd());
uniform_real_distribution<> dist_real(0.0, 1.0);
uniform_int_distribution<> dist_int(0, RAND_MAX);
uniform_int_distribution<> dist_int_k(0, K);

struct ContestInfo {
	int D;
	long score;
	long best_score;
	vector<int> t;
	vector<int> best_t;
	set<int> held[N];
	ContestInfo(int dd) : D(dd), score(0) {
		t.resize(D, -1);
		for (int i = 0; i < N; i++) {
			held[i].insert(-1);
			held[i].insert(D);
			score -= c[i] * D * (D + 1) / 2;
		}
	}

	void add(int dd, int qq) {
		if (t[dd] != -1) {
			cout << "Add faild!" << endl;
			exit(1);
		}

		t[dd] = qq;
		score += s[dd][qq];
		auto itr = held[qq].insert(dd).first;
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score -= c[qq] * range(*litr, *ritr);
		score += c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
	}

	void erase(int dd) {
		if (t[dd] == -1) {
			cout << "Erase faild!" << endl;
			exit(1);
		}
		int qq = t[dd];
		t[dd] = -1;
		score -= s[dd][qq];
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score += c[qq] * range(*litr, *ritr);
		score -= c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
		held[qq].erase(itr);
	}

	void change(int dd, int qq) {
		erase(dd);
		add(dd, qq);
	}

	void swap(int d1, int q1, int d2, int q2) {
		change(d1, q2);
		change(d2, q1);
	}

	void save() {
		best_t = t;
		best_score = score;
	}

	void output(bool show = false) {
		for (int i = 0; i < D; i++)
			cout << best_t[i] + 1 << endl;
		if (show) cout << best_score << endl;
	}
};

double dice() {
	return dist_real(generator);
}

double prob(double rem) {
	return 1.0 - 1e-3;
	// return 1.0 / exp(rem);
	// return 1.0 / pow(8, rem);
	// return dist_real(generator);
}

void tic() {
	start = std::chrono::steady_clock::now();
}

double toc() {
	endt = std::chrono::steady_clock::now();
	std::chrono::duration<double> elapsed_seconds = endt - start;
	return elapsed_seconds.count();
}

int main() {
	int d;
	cin >> d;
	for (int i = 0; i < N; i++)
		cin >> c[i];
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < N; j++) {
			cin >> s[i][j];
		}
	}

	tic();
	ContestInfo ci(d);
	for (int i = 0; i < d; i++) {
		long max_score = -INF;
		int best_q = 0;
		for (int j = 0; j < N; j++) {
			ci.add(i, j);
			if (max_score < ci.score) {
				max_score = ci.score;
				best_q = j;
			}
			ci.erase(i);
		}
		ci.add(i, best_q);
	}
	ci.save();
	ci.output(false);
}

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

fn main(){
    let (a,b) = (read::<usize>(),read::<usize>());
    let s = read::<String>();
    let ss : Vec<&str> = s.split("-").collect();
    println!("{}", if ss.len()==2 && ss[0].chars().count()==a && ss[1].chars().count()==b {"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
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> L(N * 2);
	for (int i = 0; i < N * 2; ++i) { cin >> L[i]; }

	sort(L.begin(), L.end());

	int res = 0;
	for (int i = 0; i < L.size(); i += 2) {
		res += L[i];
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	static int x;
	static int minI;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		boolean isHome = s.contains("N") == s.contains("S")
						&& s.contains("W") == s.contains("E");
		System.out.println(isHome ? "Yes" : "No");

		sc.close();
	}

}


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

int main(){
	int n, cnt1 = 0, cnt2 = 0;
	cin >> n;


	if(n % 2 == 0){
		for(int i = 2; i <= n; i+=2){
		cnt1++;
	     }
       // cout << cnt*cnt;

	}
    else{
    	for(int i = 1; i <= n; i+=2){
		cnt2++;
	     }
    	//cout << cnt*(cnt-1);
    }

    if(n % 2 == 0){
    	cout << cnt1 * cnt1;
    }
    else{
    	cout << cnt2 * (cnt2-1);
    }

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	VE b(n); rep(i, n)b[i] = a[i] - (i + 1);
	sort(ALL(b));
	int tmp = b[n / 2];
	int ans = 0;
	rep(i, n) {
		ans += abs(a[i] - (tmp + i + 1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 3005

struct LOC{
	LOC(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
ll num_O[NUM][NUM],num_I[NUM][NUM];
char table[NUM][NUM];
vector<LOC> V;


int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);

		for(int col = 0; col < W; col++){

			if(table[row][col] == 'J'){
				V.push_back(LOC(row,col));
			}
		}

		//右→左にOの数を数える
		if(table[row][W-1] == 'O'){

			num_O[row][W-1] = 1;

		}else{

			num_O[row][W-1] = 0;
		}

		for(int col = W-2; col >= 0; col--){

			if(table[row][col] == 'O'){

				num_O[row][col] = num_O[row][col+1]+1;

			}else{

				num_O[row][col] = num_O[row][col+1];
			}
		}
	}

	//下→上にIの数を数える
	for(int col = 0; col <= W-1; col++){

		if(table[H-1][col] == 'I'){

			num_I[H-1][col] = 1;
		}else{

			num_I[H-1][col] = 0;
		}

		for(int row = H-2; row >= 0; row--){

			if(table[row][col] == 'I'){

				num_I[row][col] = num_I[row+1][col]+1;
			}else{

				num_I[row][col] = num_I[row+1][col];
			}
		}
	}

	ll ans = 0;

	for(int i = 0; i < V.size(); i++){

		ans += num_O[V[i].row][V[i].col]*num_I[V[i].row][V[i].col];
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 180672
module Main where

import Data.List
--import Data.Array
import Data.Array.Unboxed as U --Immutable
import Data.Array.ST
import Data.Array.MArray
import Control.Monad
import Control.Monad.ST

--k>=1
dp ::  UArray Int Int -> STUArray s Int Int -> Int -> Int -> ST s Int
dp hs starr 1 k = return 0
dp hs starr i k = do
  let nowh = hs!i
  nexts <- forM [max 1 (i-k)..i-1] $ \j -> do
    dp_j <- readArray starr j
    return $ dp_j+abs(nowh-hs!j)
  return $ minimum $ nexts

--dpをどう動かすか
solve :: UArray Int Int -> Int -> Int -> Int
solve hs n k = runST $ do
  starr <- newArray (1,n) 0 :: ST s (STUArray s Int Int)
  forM_ [1..n] $ \i -> dp hs starr i k >>= writeArray starr i
  readArray starr n

main :: IO ()
main = do
  [n,k] <- map read. words <$> getLine
  hs <- map read. words <$> getLine
  print $ solve (listArray (1,n) hs) n k


Measured memory_bytes: 30972
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <complex>
using namespace std;

typedef long long ll;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  double a;

  while(cin>>a,a!=-1){
    int left = (int)(a);
    double right = a - left;

    string s = "";
    while(left != 0){
      s = (char)(left % 2 + '0') + s;
      left /= 2;
      if(s.length() > 8) break;
    }

    string ss = "";
    while(right != 0){
      int tmp = (int)(right * 2);
      ss += (char)(tmp + '0');
      right = right * 2 - tmp;
      if(ss.length() > 4) break;
    }

    if(s.length() > 8 || ss.length() > 4){
      cout<<"NA\n";
    }
    else{
      while(s.length() != 8) s = '0' + s;
      while(ss.length() != 4) ss += '0';
      cout<<s<<"."<<ss<<endl;
    }
  }
}

Measured memory_bytes: 0
n,a,b = map(int,input().split())

if ((b-a) % 2 == 0):
  print((b-a)//2)
elif (a-1 <= n-b):
  tmp = a-1
  b -= a-1
  a = 1
  print(tmp+((b-a)//2)+1)

else:
  tmp = n-b
  a += n-b
  b = n
  print(tmp+((b-a)//2)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void solve(){
    vector<vector<int>> A(3, vector<int>(3));
    int a[3];
    int n;
    for(int i=0; i<3; i++){
        cin >> a[0] >> a[1] >> a[2];
        for(int j=0; j<3; j++){
            A[i][j] = a[j];
        }
    }
    cin >> n;
    vector<int> b(n);
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(b[i] == A[j][k]){
                    A[j][k] = -1; 
                }
            }
        }
    }
    if(A[0][0] == -1 && A[0][1] == -1 && A[0][2] == -1 || A[1][0] == -1 && A[1][1] == -1 && A[1][2] == -1 || A[2][0] == -1 && A[2][1] == -1 && A[2][2] == -1 ||
    A[0][0] == -1 && A[1][0] == -1 && A[2][0] == -1 || A[0][1] == -1 && A[1][1] == -1 && A[2][1] == -1 || A[0][2] == -1 && A[1][2] == -1 && A[2][2] == -1 ||
    A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1 || A[2][0] == -1 && A[1][1] ==-1 && A[0][2] == -1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

int main(){
	int n,m;cin>>n>>m;
	int ac=0,pin=0;
	map<int,pair<int,int> >mp;
	for(int i=0;i<m;i++){
		int p;string s;cin>>p>>s;
		if(s=="AC")mp[p].first++;
		else if(mp[p].first==0) mp[p].second++;
	}
	for(auto u:mp){
		if(u.second.first){
			ac++;pin+=u.second.second;
		}
	}
	cout<<ac<<' '<<pin;
	return 0;
}

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

int N;
vector<int> w;
vector<vector<int> > dp;

int rec(int left = 0, int right = N - 1) {
    if (left == right) {
        return dp.at(left).at(right) = 0;
    }
    if (right - left == 1) {
        return dp.at(left).at(right) = (abs(w.at(left) - w.at(right)) <= 1) ? 2 : 0;
    }
    int &ret = dp.at(left).at(right);
    if (ret != -1) {
        return ret;
    }
    if (rec(left + 1, right - 1) == right - left - 1 && abs(w.at(left) - w.at(right)) <= 1) {
        return ret = right - left + 1;
    }
    for (int i = left; i < right; ++i) {
        ret = max(ret, rec(left, i) + rec(i + 1, right));
    }
    return ret;
}

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

    while (true) {
        cin >> N;
        if (N == 0) break;
        w.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> w.at(i);
        }

        dp.assign(N, vector<int>(N, -1));

        cout << rec() << endl;
    }

    return 0;
}


Measured memory_bytes: 3424