akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;

int main() {
	int a,x = 0, y = 0;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		if (i % 2 == 0)x++;
		else y++;
	}
	cout << x * y << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        if(h % a == 0){
            System.out.println(h/a);
        }else{
            System.out.println(h/a+1);
        }
    }
}

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

// 1s = 10 ^ 8 loop

int main() {
  int D;
  cin >> D;
  
  string str = "Christmas";
  for (int i = 0; i < 25 - D; i++) {
    str += " Eve";
  }
  cout << str << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000+5;
const ll mod = 1e9+7;
ll n, m;
ll fac[maxn];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  fac[0] = 1;
  for(int i = 1; i < maxn; i++) fac[i] = i * fac[i-1] % mod;
  cin >> n >> m;
  if(n == m){
    cout << ((fac[n] * fac[n] )%mod * 2) % mod;
  }
  else if(n-m == 1 || n-m == -1){
    cout << fac[n] * fac[m] % mod;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
  	cin>>a>>b;
  	if(a>b){
    	for(int i=0;i<a;i++){
      		cout<<b;
      }
    }else{
    	for(int i=0;i<b;i++){
        	cout<<a;
        }
    }
  	return 0;
}

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

using namespace std;

typedef long long LL;

const int maxn = 2e5 + 5;
const int P = 1e9 + 7;

int n, m, fac[maxn], A, B, ans;

inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){u = u * 10 + ch - 48; ch = getchar();} return u * f; 
}

inline int pls(int x, int y) {x += y; return x >= P ? x - P : x;}

inline int mul(int x, int y) {LL rnt = 1ll * x * y; return (int)(rnt >= P ? rnt % P : rnt);}

inline int ksm(int x, int k) {
	int cnt = 1;
	while(k) {
		if(k & 1) cnt = mul(cnt, x);
		x = mul(x, x); k >>= 1;
	} return cnt;
}

inline int C(int x, int y) {
	int n = x + y - 2, m = x - 1;
	if(m > n) return 0;
	return mul(mul(ksm(fac[n - m], P - 2), ksm(fac[m], P - 2)), fac[n]);
}

int main(){
	n = read(); m = read(); fac[0] = 1;
	for(register int i = 1; i <= n + m; i++)
		fac[i] = mul(fac[i - 1], i);
	A = read(); B = read();
	for(register int i = B + 1; i <= m; i++) {
		//cerr << (n - A) << " " << i << " " << B << " " << m - i + 1 << endl;
		ans = pls(ans, mul(C(n - A, i), C(A, m - i + 1)));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

vector<ll> G[100002];
vector<ll> p,dep;
bool did[100002];

void dfs(ll from){
	for(auto to:G[from]){
		if(!did[to]){
			did[to] = true;
			p[to] = from;
			dep[to] = dep[from] + 1;
			dfs(to);
		}
	}
}

int main () {
	ll n,k,c,id;
	cin >> n;
	if(n==1){
		cout << "node 0: parent = -1, depth = 0, root, []" << endl;
		return 0;
	}
	FOR(i,0,n){
		cin >> id;
		cin >> k;
		FOR(j,0,k){
			cin >> c;
			G[id].push_back(c);
		}
	}

	ll root = -1;
	FOR(i,0,n){
		for(auto ch:G[i]){
			did[ch] = true;
		}
	}
	FOR(i,0,n)if(!did[i])root = i;
	
	memset(did,0,sizeof(did));
	p.resize(n,-1);
	dep.resize(n,0);

	did[root] = true;
	dfs(root);

	FOR(i,0,n){
		cout<<"node "<<i<<": parent = "<<p[i]<<", depth = "<<dep[i]<<", ";
		if(i == root){
			cout << "root, [";
		}else if(G[i].size()){
			cout << "internal node, [";
		}else{
			cout << "leaf, []\n";
			continue;
		}
		k = G[i].size();
		FOR(j,0,k-1){
			cout << G[i][j] <<", ";
		}
		cout << G[i][k-1] << "]\n";
	}
	


}


Measured memory_bytes: 8420
import java.util.*;

public class Main {

    static long mod = 1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        List<P> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            list.add(new P(i, a[i]));
        }
        Collections.sort(list);
        long[][] memo = new long[n+1][n+1];
        for(int i=0 ;i<n; i++) {
            P p = list.get(i);
            for(int j=0; j<=i; j++) {
                int lpos = j;
                int rpos = n-1-(i-j);
                memo[i+1][j] = Math.max(memo[i+1][j], memo[i][j] + Math.abs(rpos-p.pos) * p.num);
                memo[i+1][j+1] = Math.max(memo[i+1][j+1], memo[i][j] + Math.abs(lpos-p.pos) * p.num);
            }
        }
        long res = 0;
        for(int i=0 ;i<=n; i++) {
            res = Math.max(res, memo[n][i]);
        }

        System.out.println(res);
    }

    static class P implements Comparable<P>{
        int pos;
        long num;
        P(int pos, long num) {
            this.pos = pos;
            this.num = num;
        }
        public int compareTo(P p) {
            return Long.compare(p.num, num);
        }


    }


}

Measured memory_bytes: 85948
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int MAX_V = 50;

int main(void){
    int N;
    int V[MAX_V];
    int answer = 0;

    cin >> N;

    rep(i, N){
        cin >> V[i];
    }

    rep(i, N){
        int C;
        cin >> C;
        int diff = V[i] - C;

        if (diff > 0){
            answer += diff;
        }
        
    }
    
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k, x;
    cin >> k >> x;
    cout << x - k + 1;
    eFOR(i, x - k + 2, x + k - 1)cout << " " << i;
    cout << "\n";
}

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

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

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

    ll ans = 0;
    ll total = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            total += a[i];
            if (total <= 0) {
                ans += labs(total) + 1;
                total = 1;
            }
        } else {
            total += a[i];
            if (total >= 0) {
                ans += labs(total) + 1;
                total = -1;
            }
        }
    }
    ll cost = ans;
    ans = 0;
    total = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            total += a[i];
            if (total <= 0) {
                ans += labs(total) + 1;
                total = 1;
            }
        } else {
            total += a[i];
            if (total >= 0) {
                ans += labs(total) + 1;
                total = -1;
            }
        }
    }

    cout << min(cost, ans) << endl;
}


Measured memory_bytes: 1024
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	cnt := 0
	for a := 1; a < N; a++ {
		for b := 1; a*b < N; b++ {
			cnt++
		}
	}

	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 0; i < n - 1; i++)
  {
    int temp;
    cin >> temp;
    data[temp - 1]++;
  }
  for (int i = 0; i < n; i++)
  {
    cout << data[i] << endl;
  }
}

Measured memory_bytes: 4052
# 2019/12/27

from heapq import heapify,heappop,heappush
import sys

input=sys.stdin.readline
n,m=map(int,input().split())
ab=[[] for _ in range(m+1)]

for i in range(n):
    a,b=map(int,input().split())
    if a>m:continue
    ab[a].append(-b)

que=[]
heapify(que)
ans=0
for i in range(1,m+1):
    if ab[i]:
        for e in ab[i]:
            heappush(que,e)
    if que:
        ans+=heappop(que)

print(-ans)


Measured memory_bytes: 17732
//
// Created by yamunaku on 2020/02/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = 0;
		int y;
		for(int i = 0;i < N; i++){
			x = x + 800;
		}
		y = (N/15)*200;
		System.out.print(""+(x-y));
	}

}


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

using namespace std;

int a[1234567];

int main() {
  int n;
  scanf("%d", &n);
  int k = 0;
  int sum = 0;
  while (sum + (k + 1) <= n) {
    sum += k + 1;
    a[k] = k + 1;
    k++;
  }
  for (int i = k - 1; i >= 0; i--) {
    if (sum < n) {
      a[i]++;
      sum++;
    }
  }
  for (int i = 0; i < k; i++) {
    printf("%d\n", a[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD=1e9+7;
int main()
{
    string s; cin>>s;
    int c[100010];
    int n=s.size();
    c[0]=0;
    bool dame=1;
    for(int i=0; i<n; i++){
        if(s[i]=='a') c[i+1]=(c[i]+1)%3;
        else c[i+1]=(c[i]+2)%3;
        if(i<n-1 && s[i]==s[i+1]) dame=0;
    }
    if(dame){
        cout<<1<<endl; return 0;
    }
    int nx[100010];
    int p[3];
    for(int j=0; j<3; j++) p[j]=n+1;
    p[c[n]]=n;
    for(int i=n-1; i>=0; i--){
        p[c[i]]=i;
        if(s[i]=='a') nx[i]=p[(c[i]+2)%3];
        else nx[i]=p[(c[i]+1)%3];
    }
    int dp[100010]={};
    dp[0]=1;
    int ans=0;
    for(int i=0; i<n; i++){
        (dp[i+1]+=dp[i])%=MOD;
        (dp[nx[i]]+=dp[i])%=MOD;
        int x=(c[n]-c[i+1]+3)%3;
        if(x==0) (ans+=dp[i+1])%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n,k;
  cin >> k >> n;
  vector<int>kyo(n);
  int b,no,c;
  cin >> b;
  c=b;
  for(int i=0;i<n-1;i++){
    no=b;
    cin >> b;
    kyo.at(i)=b-no;
  }
  kyo.at(n-1)=k-b+c;
  sort(kyo.begin(),kyo.end(),greater());
  cout << k-kyo.at(0) << endl;
  return 0;
}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int a[1010100];

int main(){
	int n=read(),d=read();
	for(int i=1;i<=n;i++){
		int k=read();
		a[i]=abs(k-d);
	}
	int ans=a[1];
	for(int i=2;i<=n;i++){
		ans=__gcd(ans,a[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
N,T=list(map(int,input().split()))
ct=[list(map(int,input().split())) for i in range(N)]
tmp=[]
for i in range(len(ct)):
    if ct[i][1]<=T:
        tmp.append(ct[i][0])
if len(tmp)==0:
    print('TLE')
else:
    print(min(tmp))

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

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

    string S; cin >> S;
    int c[2] = {0, 0};
    for (int i = 0; i < S.size(); i++) c[S[i]-'0']++;
    cout << min(c[0], c[1]) * 2 << "\n";
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    long long Ans = 0;
    for (int d = 1; d <= N; d++) {
        long long x = N / d;
        Ans += x * (x+1) / 2 * d;
    }
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 3660
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define pb push_back
using namespace std;

namespace Header_Template {
  typedef long long li;
  template<class T>inline void read(T &x) {
    x = 0;
    T tmp = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') tmp = -1, c = getchar();
    while (c >= '0' && c <= '9')
      x = (x << 1) + (x << 3) + c - '0', c = getchar();
    x *= tmp;
  }
  template<class T>inline void Max(T &x, T y) {
    if (y > x) x = y;
  }
  template<class T>inline void Min(T &x, T y) {
    if (y < x) x = y;
  }
}
using namespace Header_Template;

const int N = 2e5 + 10;
int n, a[N];

int main(void) {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) a[i] -= i;
  sort(a + 1, a + 1 + n);
  int val = a[(n + 1) >> 1];
  li ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += abs(val - a[i]);
  printf("%lld\n", ans);
  
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<ll>>;

ll dp[100100][2];//dp[v][color]
vector<ll> dist;

ll rec(int v, int color, const Graph &G){
    if(dp[v][color]!=-1) return dp[v][color];
    ll res = 1;
    for(auto nv : G[v]){
        ll tmp = 0;
        if(dist[nv]==dist[v]+1){
            if(!color) (tmp += rec(nv,1,G)) %= MOD;
            (tmp += rec(nv,0,G)) %= MOD;
            tmp %= MOD;
            if(tmp!=0) (res *= tmp) %= MOD;
        }
    }
    // if(res==1){
    //     //端点
    //     return dp[v][color] = 1;
    // }
    res %= MOD;
    return dp[v][color] = res;
}

int main(){
    int N; cin>>N;
    dist.resize(N,-1);
    Graph G(N);
    rep(i,N-1){
        int x,y; cin>>x>>y;
        x--;y--;
        G[x].push_back(y); G[y].push_back(x);
    }
    queue<int> Q;
    dist[0] = 0;
    Q.push(0);
    while(!Q.empty()){
        ll v = Q.front(); Q.pop();
        for(auto nv: G[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v] + 1;
            Q.push(nv);
        }
    }
    rep(i,100100)rep(j,2)dp[i][j] = -1;
    ll res = rec(0,0,G);
    res += rec(0,1,G);
    res %= MOD;
    cout<<res<<endl;
}



Measured memory_bytes: 19148
x = int(input())
if x == 1:
    print(1)
    exit()
li = list(range(2,x+1))
ans = [1]
n = 2
while li[0]**n < x:
    for i in range(x-1):
        if li[i]**n > x:
            ans.append(li[i-1]**n)
            break
    n += 1
print(max(ans))

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = gcd(a[0], a[1]);
    for (int i = 2; i < n; ++i) {
        ans = gcd(ans, a[i]);
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/



Measured memory_bytes: 3692
implicit none
integer:: n, i, j, a, b, ans, t
integer,allocatable,dimension(:):: p

read(5,*) n, a, b
allocate(p(n))
read(5,*) (p(i),i=1,n)

ans = 1
t = abs( (1000 * b) - (1000 * a) + (6 * p(1)) )

do i = 1, n
    if ( t > abs( (1000 * b) - (1000 * a) + (6 * p(i)) ) ) then
        ans = i
        t = abs( (1000 * b) - (1000 * a) + (6 * p(i)) )
    endif
enddo
    
write(6, *) ans

end

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

signed main(void)
{
	int m;
	cin >> m;
	rep(loop, m) {
		set<string> s;
		string source_s;
		cin >> source_s;
		int n = source_s.size();
		REP(i, 1, n) {
			string str[2];
			str[0] = source_s.substr(0, i);
			str[1] = source_s.substr(i);
			rep(j, 4) {
				if (j / 2) reverse(ALL(str[0]));
				if (j % 2) reverse(ALL(str[1]));
				s.insert(str[0] + str[1]);
				s.insert(str[1] + str[0]);
				if (j / 2) reverse(ALL(str[0]));
				if (j % 2) reverse(ALL(str[1]));
			}
		}

		cout << s.size() << endl;
		/*
		auto itr = s.begin();
		for (; itr != s.end(); itr++) {
			cout << *itr << endl;
		}*/
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int a,b,k,ans;
    cin>>a>>b>>k;
    int cnt=0;
    for(int i = 100; i > 0; i--)
    {
        if(a%i==0 && b%i==0)
        {
            cnt++;
            if(cnt==k)
            {
                ans=i;
                break;
            }
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

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

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] =1

for i in range(n):
  for j in range(n):
    dp[i+1][j+1] += dp[i][j] * pp[i]
    dp[i+1][j] += dp[i][j] * (1-pp[i])
    
print(sum(dp[-1][(n+1)//2:]))

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

int main(){
  int n, y; cin >> n >> y;
  bool ok = false;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n - i; j++){
      int tmp = 10000*i + 5000*j + 1000*(n-i-j);
      if(tmp == y){
        ok = true;
        cout << i << " " << j << " " << n-i-j << endl;
        break;
      }
    }
    if(ok) break;
  }
  if(!ok) cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
import math
def gcd(a,b):
  if a<b:
    a,b = b,a
  if b == 0:
    return a
  else:
    a,b = b,a%b
    return(gcd(a,b))

""" return a list of the prime factors for a nutural numbers"""
def prime_factorization(k):
  if k < 2:
    return []
  r = math.ceil(math.sqrt(k))
  ans = []
  i = 2
  while i <= r:
    if k % i == 0:
      ans.append(i)
      k //= i
    else:
      i += 1
  if k > 1:
    ans.append(k) 
  return ans

if __name__ == "__main__":
  n,k = map(int,input().split())
  #print(gcd(n,k))
  l = prime_factorization(gcd(n,k))
  print(len(set(l))+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    ll a[n];
    ll c_sum[n+1]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        c_sum[i+1]=c_sum[i]+a[i];
        c_sum[i+1]%=MOD;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=(c_sum[n]-c_sum[i+1])*a[i];
        ans%=MOD;
    }
    while(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 6736
n, p = map(int, input().split())
A = list(map(int, input().split()))

even = 0
odd = 0

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

ans = 0

if odd == 0:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
else:
    ans = 2 ** (n - 1)

print(ans)


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int m,d,m2,d2;
    scanf("%d%d%d%d",&m,&d,&m2,&d2);
    if(m!=m2)printf("1\n");
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

ll modinv(ll a,ll m) {
    ll b=m,u=1,v=0;
    while(b){
        ll 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 modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double n,m,sum=0,c=0;
    cin>>n>>m;
    vec<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,n){
        if(a[i]>=(double)(sum/(4*m))) c++;
    }
    cout<<(c>=m ? "Yes":"No")<<endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long K, N;
    cin >> K >> N;
    vector<unsigned long> A(2 * N);
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        A[i + N] = (A[i] = a) + K;
    }
    adjacent_difference(A.begin(), A.end(), A.begin());
    cout << K - *max_element(A.begin(), A.end()) << endl;
    return 0;
}

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

using namespace std;

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

    for(int i=0; i<str.size(); ++i)
    {
        if((int)str[i]+n<=90) cout<<char(str[i]+n);
        else{
            cout<<(char) (64+(str[i]+n)%90);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, M, C;
    cin >> N, cin >> M, cin >> C;
    int B[M];
    int A[M];
    for (int i = 0; i < M; ++i) cin >> B[i];
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = 0; j < M; ++j) cin >> A[j];
        for (int j = 0; j < M; ++j) sum += A[j] * B[j];
        if (sum + C > 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<int> s,t;
  for ( int i = 0; i < m; i++){
    cin >> a >> b;
    if ( a == 1){
      s.push_back(b);
    } else if ( b == n){
      t.push_back(a);
    }
  }
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for ( int i = 0; i < s.size(); i++){
    if ( binary_search(t.begin(), t.end(), s[i])){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf("%d %d %d", &b1, &b2, &b3);
	
	if (b1 == 1 && b2 == 0 && b3 == 0) {
		printf("Close\n");
	}
	else if (b1 == 0 && b2 == 1 && b3 == 0) {
		printf("Close\n");
	}
	else if (b1 == 1 && b2 == 1 && b3 == 0) {
		printf("Open\n");
	}
	else if (b1 == 0 && b2 == 0 && b3 == 1) {
		printf("Open\n");
	}
	else if (b1 == 0 && b2 == 0 && b3 == 0) {
		printf("Close\n");
	}
	
 	return (0);
}

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

using namespace std;
typedef long long LL;
const int mod=998244353;


LL quick(LL a,LL b){
	LL ans=1;
	while(b){
		if(b&1) ans = ans*a%mod;
		b>>=1;
		a = a*a%mod;
	}
	return ans;
}

int main()
{
	LL n,m,k,t=1,ans=0;
    cin>>n>>m>>k;
    for(LL i=0;i<=k;i++){
        ans = (ans+(t*m%mod) * quick(m-1,n-i-1))%mod;
        t = t*(n-i-1) % mod * quick(i+1,mod-2)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, K := sc.nextInt(), sc.nextInt()
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = sc.nextInt()
	}
	count := 0
	for _, v := range h {
		if v >= K {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long ans = 0;
        if((b-a) % 2 == 0) {
            System.out.println((b-a)/2);
        }else {
            if(n-a < b-1) {
                ans = n-b+1;
                a += (n-b)+1;
                b = n;
                
                System.out.println(ans + (b-a)/2);          
            }else {
                ans = a;
                b -= a-1;
                a = 1;
                System.out.println(ans + (b-a)/2);  
                
            }
        }
    }
 
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));

    if (y < 2019)
        cout << "Heisei" << endl;
    else if (y == 2019)
    {
        if (m < 5)
            cout << "Heisei" << endl;
        else
            cout << "TBD" << endl;
    }
    else
        cout << "TBD" << endl;
}


Measured memory_bytes: 3672
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void) {
	bool date[52][52] = { true };
	int H, W;
	char c;
	cin >> H >> W;
	for (int y = 0;y < H;y++)	 {
		for (int x = 0; x < W;x++) {
			cin >> c;
			if (c == '.')
				date[x + 1][y + 1] = true;
			else 
				date[x + 1][y + 1] = false;
		}
	}
	for (int y = 1;y <= H;y++) {
		for (int x = 1; x <= W;x++) {
			if (date[x][y] == false &&  date[x + 1][y] && date[x - 1][y] && date[x][y + 1] && date[x][y - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
items = [list(map(int, input().split())) for _ in range(N)]
for i in range(1, N+1):
    div = min([items[i-1][1], W+1])
    for j in range(0, div):
        dp[i][j] = dp[i-1][j]
    for j in range(div, W+1):
        dp[i][j] = max([dp[i-1][j], dp[i-1][j-items[i-1][1]] + items[i-1][0]])
print(dp[-1][-1])



Measured memory_bytes: 25952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        const double PI = Math.PI;
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = double.Parse(input[0]);
            var B = double.Parse(input[1]);
            var H = double.Parse(input[2]);
            var M = double.Parse(input[3]);

            double ans;

            double argA = (30 * H + M / 2) * PI / 180;
            double argB = 6 * M * PI / 180;

            double ax = A * Math.Sin(argA);
            double ay = A * Math.Cos(argA);

            double bx = B * Math.Sin(argB);
            double by = B * Math.Cos(argB);

            ans = Math.Sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18668
import math


def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
/*input
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
*/
/**
    Author: Kristopher Paul
    Date Created: 09-06-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 0x3f3f3f3f //0x3f3f3f3f = 63
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n,m;
    cin >> n >> m;
    char arr[n][m];
    FOR(i,0,n){
        FOR(j,0,m){
            cin >> arr[i][j];
        }
    }
    int d[n][m],u[n][m],l[n][m],r[n][m];
    FOR(i,0,m){
        int bid = n;
        FORD(j,n-1,0){
            if(arr[j][i] == '#'){
                bid = j;
            }
            d[j][i] = bid-j;
        }
    }
    FOR(i,0,m){
        int bid = -1;
        FOR(j,0,n){
            if(arr[j][i] == '#'){
                bid = j;
            }
            u[j][i] = j-bid;
        }
    }
    FOR(i,0,n){
        int bid = -1;
        FOR(j,0,m){
            if(arr[i][j] == '#'){
                bid = j;
            }
            l[i][j] = j-bid;
        }
    }
    FOR(i,0,n){
        int bid = m;
        FORD(j,m-1,0){
            if(arr[i][j] == '#'){
                bid = j;
            }
            r[i][j] = bid-j;
        }
    }
    int maxi = 0;
    FOR(i,0,n){
        FOR(j,0,m){
            remax(maxi,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
        }
    }
    cout << maxi << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 129152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> md;
    rep(i, n) {
        int d;
        cin >> d;
        md[d]++;
    }
    int m;
    cin >> m;
    map<int, int> mt;
    rep(i, m) {
        int t;
        cin >> t;
        mt[t]++;
    }
    for (auto t : mt) {
        if (md[t.first] < t.second) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize() {
    for (int i = 0; i < N; i++) {
        row[i] = FREE, col[i] = FREE;
    }
    for (int i = 0; i < 2 * N - 1; i++) {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j]) {
                if (row[i] != j) return;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {  // クイーンの配置に成功
        printBoard();
        return;
    }
    for (int j = 0; j < N; j++) {
        // (i,j)が他のクイーンに襲撃されている場合は無視
        if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] ||
            NOT_FREE == dneg[i - j + N - 1])
            continue;
        // (i,j)にクイーンを配置する
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        // 次の行を試す
        recursive(i + 1);
        // (i,j)に配置されているクイーンを取り除く
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
    // クイーンの配置に失敗
}

int main() {
    initialize();
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++) X[i][j] = false;

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end() 
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
signed main(){
    speed;
    int n; cin >> n;
    vi v(n); 
    int mod = 1e9 + 7ll;
    vector<int> data(61);
    rep(i, 0, n) {
        cin >> v[i];
        int k = v[i];
        int cnt = 0;
        while(k != 0) {
            data[cnt++] += k % 2;
            k /= 2;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++) {
        vector<bool> visited(61);
        int k = v[i];
        int cnt = 0;
        while(k != 0) {
            visited[cnt++] = k % 2;
            k /= 2;
        }
        rep(j, 0, 61) {
            k = pow(2, j);
            k %= mod;
            if(visited[j]) {
                sum += (k * (n - i - data[j])) % mod;
            } else {
                sum += (k * data[j]) % mod;
            }
            sum %= mod;
            if(visited[j]) data[j]--;
        }
    }
    sum %= mod;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5548
n = int(input())
ds = {}

for i in range(n):
    s = input()
    if s in ds:
        ds[s] += 1
    else:
        ds[s] = 0

d_sorted = sorted(ds.items(), key=lambda x: x[0])
f_sorted = sorted(d_sorted, key=lambda x: x[1], reverse=True)

i = f_sorted[0][1]

for s in f_sorted:
    if s[1] == i:
        print(s[0])
    else:
        break


Measured memory_bytes: 46684
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Raag4924 ios_base::sync_with_stdio(0);
#define fastio cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Raag4924
    fastio
 
   
    int n;
    cin>>n;

    int arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];

    int dp[n+1];
    dp[1] =0;
    
    for(int i=2;i<=n;i++)
    {
      
        dp[i] = abs(arr[i]-arr[i-1])+dp[i-1];

        if(i>=3)
            dp[i] = min(dp[i],abs(arr[i]-arr[i-2])+dp[i-2]);
    }

    cout<<dp[n]<<"\n";


 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 1792
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(i + j <= s && s - (i + j) <= k){
                ans++;
            }
        }
    }

    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int max_price = 0;
	int sum = 0;
	
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int p;
		scanf("%d", &p);
		sum += p;
		max_price = max(max_price, p);
	}
	printf("%d", sum - max_price / 2);
}

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

using namespace std;

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

int main() {
  int N; cin >> N;
  double pi = 3.141;

  cout << N*2*pi << endl;
  return 0;
}


Measured memory_bytes: 3256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int x, a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x>>a;
    if(x>=a)
    cout << 10 << "\n";
    else{
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256