akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		ans += M;
	}
	ans -= N;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
H  = list(map(int,input().split()))
A_B = [list(map(int,input().split())) for i in range(m)]
s = set()

for i in A_B:
    if H[i[0]-1] < H[i[1]-1]:
        s.add(i[0])
    elif H[i[0]-1] == H[i[1]-1]:
        s.add(i[0])
        s.add(i[1])
    else:
        s.add(i[1])

print(n-len(s))

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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> v;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(auto s : v)cout << s;
    cout << endl;

    return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
int sage(int n){
if(n%2==1){
  return n/2+1;
}else
{
  return n/2;
}


}
int main(){
int n;
cin>>n;
ll a[n];
int count2=0,count4=0;
rep(i,n){
  cin>>a[i];
  if(a[i]%4==0){
    count4++;
  }
  else if(a[i]%2==0){
    count2++;
  }
}
int count1=n-count2-count4;
//cout<<count1<<count2<<count4<<endl;

if(count2>0&&count1<=count4){
  cout<<"Yes"<<endl;
}else if(count2==0&&count1<=count4+1){
  cout<<"Yes"<<endl;
}
else
{
  cout<<"No"<<endl;
}


  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	static int N;
	static long A, B;
	static long[] S;
	static long[][] dpA;
	static long[][] dpB;
	static BinaryIndexedTree bitA;
	static BinaryIndexedTree bitB;
	static final long MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		S = new long[N];
		dpA = new long[2][N];
		dpB = new long[2][N];
		bitA = new BinaryIndexedTree(N);
		bitB = new BinaryIndexedTree(N);
		Stack<Query> stackA = new Stack<>();
		Stack<Query> stackB = new Stack<>();
		for (int i = 0; i < N; ++i) {
			S[i] = sc.nextLong();
		}
		Arrays.sort(S);

		bitA.addVal(0 + 1, 1);
		bitB.addVal(0 + 1, 1);
		stackA.push(new Query(0 + 1, 1));
		stackB.push(new Query(0 + 1, 1));
		int leftA = -1;
		int leftB = -1;
		for (int i = 0; i + 1 < N; ++i) {
			long sA = 0;
			long sB = 0;
			while (S[i + 1] - S[leftA + 1] >= A)
				++leftA;
			while (S[i + 1] - S[leftB + 1] >= B)
				++leftB;
			sB = bitA.getVal((leftB + 1) + 1);
			sA = bitB.getVal((leftA + 1) + 1);
			if (S[i + 1] - S[i] < A) {
				while (!stackA.isEmpty()) {
					Query q = stackA.pop();
					bitA.addVal(q.pos, -q.val);
				}
			}
			if (S[i + 1] - S[i] < B) {
				while (!stackB.isEmpty()) {
					Query q = stackB.pop();
					bitB.addVal(q.pos, -q.val);
				}
			}
			bitA.addVal((i + 1) + 1, sA);
			bitB.addVal((i + 1) + 1, sB);
			stackA.add(new Query((i + 1) + 1, sA));
			stackB.add(new Query((i + 1) + 1, sB));
		}
		System.out.println((bitA.getVal(N) + bitB.getVal(N)) % MOD);
	}

	static class BinaryIndexedTree {
		int n;
		long[] val;

		public BinaryIndexedTree(int n) {
			this.n = n;
			val = new long[n + 1];
		}

		void addVal(int k, long v) {
			while (k <= n) {
				val[k] += v;
				val[k] = (val[k] + MOD) % MOD;
				k += k & -k;
			}
		}

		long getVal(int k) {
			long s = 0;
			while (k > 0) {
				s += val[k];
				s = (s + MOD) % MOD;
				k -= k & -k;
			}
			return s;
		}

		void clear() {
			val = new long[n + 1];
		}
	}

	static class Query {
		int pos;
		long val;

		public Query(int pos, long val) {
			this.pos = pos;
			this.val = val;
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 55980
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);

  int a[N];
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    if(a[i] != i+1) cnt++;
  }

  if(cnt <= 2) printf("YES\n");
  else printf("NO\n");


  return 0;
}

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

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

  vector<vector<int>> f(m, vector<int>(100001));
  vector<int> r(100001);

  for (int i = 0; i < n; ++i) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;

    // while (s <= t) {
    for (; s <= t; ++s) {
      if (f[c][s]) continue;
      ++f[c][s];
      r[s]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < r.size(); ++i) {
    ans = max(ans, r[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 12536
N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = []
s0 = sum(p[0:K-1])
for x in range(0,N-K+1):
    s0 = s0 + p[x+K-1]
    ret.append(s0)
    s0 = s0 - p[x]
print((max(ret)+K)/2)

Measured memory_bytes: 24804
#include <iostream>
 
using namespace std;
 
int a[107];
 
int main(){
  int n; cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ct = 0;
  for (int i = 0; i < n; i++)
    for (int j = i+1; j < n; j++)
		for (int k = j+1; k < n; k++)
			if (a[i] + a[j] > a[k] && a[i]+a[k] > a[j] && a[j]+a[k] > a[i] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
              ct++;
  cout << ct << endl;
}

Measured memory_bytes: 3536
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
res = [1 for i in H]
for i in range(M):
    a, b = [int(i)-1 for i in input().split()]
    if H[a] <= H[b]:
        res[a] = 0
    if H[b] <= H[a]:
        res[b] = 0
print(sum(res))


Measured memory_bytes: 20112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;


int main()
{
	int a, b, c;
	while (cin >> a >> b >> c)
	{
		if (a == b and a != c) cout << "Yes" << endl;
		else if (a == c and a != b) cout << "Yes" << endl;
		else if (b == c and a != c) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    map<string,ll>m;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }
    cout<<m.size()<<endl;
    return 0;
}



Measured memory_bytes: 19020
import java.util.Scanner;


// ?????????????????????????????????????????????????????????
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = 2;
		boolean same = true; 
		Dice[] dice = new Dice[n];
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < 7; j++) {
				array[j] = scan.nextInt();
			}
			dice[i] = new Dice(array);
		}
		
		array = dice[0].getNum();
		if (dice[1].check(array)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}
	

class Dice {
	private int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(int[]ary, String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = ary;
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_2]; cp_array[6] = array[7 -now_1];
		return cp_array;
	}
	
	
	// ??????????????????????????????????????????
	public boolean check(int[] tarary) {
		int[] ary = tarary;
		String[] str = {"null", "N", "N", "N", "E", "WW"};
		int sum = 0;
		int[] array = new int[this.num.length];
		for (int i = 0; i < this.num.length; i++) {
			array[i] = this.num[i];
		}
		boolean decision = false;
		for (int i = 0; i < str.length; i++) {
			array = this.roll(array, str[i]);
			for (int j = 0; j < 4; j++) {
				if (array[1] == ary[1]) {
					if (array[2] == ary[2]) {
						for (int k = 3; k < ary.length; k++) {
							
							if (array[k] != ary[k]) {
								decision = false;
								break;
							}
							decision = true;
						}
					}
					if (decision) {
						break;
					} else {
						array = this.roll(array, "NWS");
					}
				} else {
					break;
				}
			}
			if (decision) break;
		}
		

		return decision;
	}
}

Measured memory_bytes: 26360
package main

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

func main() {
	n := readI()
	h := make([]int, n+1)
	for i := 1; i <= n; i++ {
		h[i] = readI()
	}

	dp := make([]int, n+1)
	for i := 2; i <= n; i++ {
		if i-2 >= 1 {
			dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]))
		} else {
			dp[i] = dp[i-1] + abs(h[i-1]-h[i])
		}
	}
	fmt.Println(dp[n])
}

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

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

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

int main(){
  int N,L;  cin >> N >> L;
  int ans = 0;
  int min = abs(L);
  int mini;

  for(int i=0;i<N;i++){
    if(min >= abs(L+i)){
      min = abs(L+i);
      mini = L+i;
    }
    ans += L+i;
  }
  cout << ans - mini << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2104
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    for {
      i <- 0 to a
      c500 = 500*i
      if c500 <= x
      j <- 0 to b
      c100 = 100*j
      if c500 + c100 <= x
      k <- 0 to c
      if c500 + c100 + 50*k == x
    } yield true
  }.size

  println(ans)
}

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

int main(void) {
    int a,b;cin>>a>>b;
    int d = a / b;
    int r = a % b;
    double f = a / double(b);
    printf("%d %d %.6f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 3148
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    L = [INT() for _ in range(5)]
    k = INT()

    print("Yay!" if L[4] - L[0] <= k else ":(")


if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int x[N+1]; rep(i,N+1) cin >> x[i];

  sort(x, x+N+1);
  int retval = x[1]-x[0];
  rep(i,N) retval = __gcd(retval, x[i+1]-x[i]);
  
  cout << retval << endl;
  
  

  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    int n = s.length();
    rep(i, n - 1) if(s[i] != s[i + 1]) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
	string a,b,c;
	cin>>a>>b>>c;
	string s="";
	s+=a[0]+'A'-'a';
	s+=b[0]+'A'-'a';
	s+=c[0]+'A'-'a';
	out(s);
}

signed 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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

ll f(ll n)
{
    if ((n + 1) % 4 == 0)
        return 0;
    if ((n + 1) % 4 == 1)
        return n;
    if ((n + 1) % 4 == 2)
        return 1;
    if ((n + 1) % 4 == 3)
        return n ^ 1;
}

int main()
{
    ll a, b, fa, fb;
    cin >> a >> b;

    fa = f(a - 1);
    fb = f(b);

    ll ans = fa ^ fb;
    cout << ans << endl;
}

Measured memory_bytes: 3444
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, M = map(int, input().split())

fact = []

X = M
i = 2
while i ** 2 <= X:
    v = 0
    while M % i == 0:
        M //= i
        v += 1
    if v != 0:
        fact.append(v)
    i += 1
if M != 1:
    fact.append(1)

MAX = 2 * 10 ** 5
MOD = 10 ** 9 + 7

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def com(n, r, mod):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod
    
comInit(MOD)


ans = 1
for f in fact:
    ans *= com(f + N - 1, N - 1, MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 33000
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

const int N = 1e7;
const long long mod = 1e9 + 7;
int F[N], Finv[N], inv[N];//F是阶乘，Finv是逆元的阶乘
						  //X 关于 mod 的逆元为 x^(mod - 2);
void init() {
	inv[1] = 1;
	for (int i = 2; i < N; i++) {
		inv[i] = (mod - mod / i) * 1ll * inv[mod % i] % mod;
	}
	F[0] = Finv[0] = 1;
	for (int i = 1; i < N; i++) {
		F[i] = F[i - 1] * 1ll * i % mod;
		Finv[i] = Finv[i - 1] * 1ll * inv[i] % mod;
	}
}
int comb(int n, int m) {///comb(n, m)就是C(n, m) n>m
	if (m < 0 || m > n) return 0;
	return F[n] * 1ll * Finv[n - m] % mod * Finv[m] % mod;
}

long long n, k;
long long ans;
int main()
{
	init();
	cin >> n >> k;
	cout << n - k + 1 << endl;
	for (int i = 2; i <= k; i++)
	{
		long long ans=comb(k - 1, i - 1);
		long long sum = 0;
		for (int j = i - 1; j <= n - k; j++)
		{
			long long temp = comb(j - 1, i - 2);
			temp *= (n - k - j + 1);
			sum = (sum+temp)%mod;
		}
		ans = ans * sum%mod;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 117504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] count = new long[k];
    for (int i = 1; i <= n; i++) {
      count[i % k]++;
    }
    long result = count[0] * count[0] * count[0];
    if (k % 2 == 0) {
      result += count[k / 2] * count[k /2] * count[k / 2];
    }
    System.out.println(result);
  }
}

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

using namespace std;

long long B(int N) {
	long long sum = 0;
	for (int i = 1; i <= N; i++) 
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	return sum;
}

int main() {
	int N;
	cin >> N;
	cout << B(N);
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  uli n,m;
  cin>>n>>m;
  if(m<2*n){
    cout<<m/2<<endl; 
  }
  else{
    uli ans=n;
    m-=2*n;
    ans+=m/4;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    string S;
    int A[100010];
    cin>>S;
    int N=S.size(),p=pow(10,9)+7;

    //マップ
    map<int,int> mp;
        mp[0]=0;
        mp[10]=1;
        mp[7]=2;
        mp[4]=3;
        mp[1]=4;
        mp[11]=5;
        mp[8]=6;
        mp[5]=7;
        mp[2]=8;
        mp[12]=9;
        mp[9]=10;
        mp[6]=11;
        mp[3]=12;

    int dp[100010][20];

    //初期化
    if(S[0]!='?'){
        A[0]=S[0]-'0';
        for(int j=0;j<13;j++)
             dp[1][j]=0;
        dp[1][A[0]]=1;
    }
    else {
        for(int j=0;j<10;++j)
            dp[1][j]=1;
        dp[1][10]=dp[1][11]=dp[1][12]=0;
    }

    //漸化式
    for(int i=1;i<N;++i){
        if(S[i]!='?'){
            A[i]=S[i]-'0';
            for(int j=0;j<13;++j)
                dp[i+1][j]=(dp[i][mp[(j-A[i]+13)%13]])%p;    
        }
        else {
            for(int j=0;j<13;++j){
                dp[i+1][j]=0;
                for(int k=0;k<10;++k){
                    dp[i+1][j]+=dp[i][mp[(j-k+13)%13]];
                    dp[i+1][j]=(dp[i+1][j])%p;
                }
            }
        }

    }

    cout<<dp[N][5]<<endl;
    return 0;
    
}

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

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		int data[] = new int[10];
		for(int i=0; i<10; i++)
		{
			data[i] = cin.nextInt();
		}
		Arrays.sort(data);
		
		for(int i=1; i<=3; i++)
		{
			System.out.println(data[data.length-i]);
		}
	}
}

Measured memory_bytes: 11000
using System;

namespace ABC103B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            Console.WriteLine(isRotation(s, t) ? "Yes" : "No");
        }

        static Boolean isRotation(string s, string t)
        {
            for (int i = 0; i < s.Length; ++i)
            {
                if (t.Equals(rotate(s, i)))
                {
                    return true;
                }
            }

            return false;
        }

        static string rotate(string s, int n)
        {
            string res = "";
            for (int i = n; i < s.Length; ++i)
            {
                res += s[i];
            }

            for (int i = 0; i < n; ++i)
            {
                res += s[i];
            }

            return res;
        }
    }
}


Measured memory_bytes: 13140
S = input()
T = input()

res = len(T)
for i in range(len(S)-len(T)+1):
  target = S[i:i+len(T)]

  matchCount = 0
  for s, t in zip(T, target):
    if s == t:
      matchCount += 1
  res = min(res, len(T)-matchCount)

print(res)

Measured memory_bytes: 67936
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        k: i32,
        n: usize,
        v: [i32; n],
    }
    let mut kukan: Vec<i32> = vec![];
    let mut v = v;
    let mut dist = 0;
    for (idx, val) in v.iter().enumerate() {
        if (idx < n - 1) {
            kukan.push(v[idx + 1] - val);
        } else {
            kukan.push((k - val) + v[0]);
        }
    }
    kukan.sort_unstable();
    for i in 0..n-1 {
        dist += kukan[i as usize];
    }
    println!("{:?}", dist);
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	string s;
	cin >> s;
	int ans = 0, count = 0;
	repz(i, s.size()) {
		//cout << "s[i]: " << s[i] << endl;
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			count++;
			if (count > ans)ans = count;
		}
		else {
			count = 0;
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Maybe          (fromJust)

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

rollH :: Dice -> Dice
rollH (Dice ds) = Dice [ds !! (i-1) | i <- [1,4,2,5,3,6]]

rollTop :: Int -> Dice -> Dice
rollTop 0 ds = ds
rollTop 1 ds = roll 'N' ds
rollTop 2 ds = roll 'W' ds
rollTop 3 ds = roll 'E' ds
rollTop 4 ds = roll 'S' ds
rollTop 5 ds = roll 'S' $ roll 'S' ds

getRight :: Int -> Int -> Int
getRight top front =
    (\(Dice d) -> d !! 2) . head $
    filter (\(Dice (x:y:_)) -> x == top && y == front) hs
  where
    d = rollTop top dice
    hs = take 4 $ iterate rollH d

main :: IO ()
main = do
    xs <- fmap read . words <$> getLine :: IO [Int]
    getLine
    yss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    forM_ yss $ \[a, b] -> do
        let (Just top, Just front) = (a `elemIndex` xs, b `elemIndex` xs)
        let right = getRight top front
        print $ xs !! right



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

int main () {
    
    int h, w;
    cin >> h >> w;
    
    
    vector<string>hi(h);
    
    for (int t = 0; t < h; t++) {
        cin >> hi.at(t);
    }
    
    for (int t = 0; t < w+2; t++) {
        cout << '#';
    } cout << endl;
    
    for (int t = 0; t < h; t++) {
        cout << '#' << hi.at(t) << '#' << endl;
    }
    
    for ( int t = 0; t < w+2; t++) {
        cout << '#';
    }

}


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

int main(){

  int A[3][3];
  int count[3][3];
  rep(i,3){cin>>A[i][0];count[i][0]=0;}
  rep(i,3){cin>>A[i][1];count[i][1]=0;}
  rep(i,3){cin>>A[i][2];count[i][2]=0;}
  
  int N;
  cin>>N;
  int B[N];
  rep(i,N){


    cin>>B[i];
  
    rep(j,3){
      rep(k,3){

        if(A[j][k]==B[i])count[j][k]=1;
        
      }
    }
  }  
  
  if(count[0][0]==1 && count[1][0]==1 && count[2][0]==1){cout<<"Yes";return 0;}
  if(count[0][1]==1 && count[1][1]==1 && count[2][1]==1){cout<<"Yes";return 0;}
  if(count[0][2]==1 && count[1][2]==1 && count[2][2]==1){cout<<"Yes";return 0;}
  if(count[0][0]==1 && count[0][1]==1 && count[0][2]==1){cout<<"Yes";return 0;}
  if(count[1][0]==1 && count[1][1]==1 && count[1][2]==1){cout<<"Yes";return 0;}
  if(count[2][0]==1 && count[2][1]==1 && count[2][2]==1){cout<<"Yes";return 0;}
  if(count[0][0]==1 && count[1][1]==1 && count[2][2]==1){cout<<"Yes";return 0;}
  if(count[0][2]==1 && count[1][1]==1 && count[2][0]==1){cout<<"Yes";return 0;}
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;

int r, g, b;
const int INF = 10e8;
void BetweenTwoIntegers(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

}

int main() {
	BetweenTwoIntegers();
	return 0;
}



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

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    for (int a = 0; a <= A; ++a){
        for (int b = 0; b <= B; ++b){
            for (int c = 0; c <= C; ++c){
                int total = 500*a + 100*b + 50*c;
                if ( total == X) ++res;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    
    if b == '+':
        print(a + c)
    elif b == '-':
        print(a - c)
    elif b == '*':
        print(a * c)
    elif b == '/':
        print(a // c)
    else:
        break



Measured memory_bytes: 5596
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int N;
    i64 x = 0;

    cin >> N;
    rep(i, N) {
        i64 a; cin >> a;
        x ^= a;
    }

    puts(x ? "No" : "Yes");

    return 0;
}



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

char dig[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
char dc[10][10][8];
int main() {
	int n, num, buf;
	for(int i=0; i<10; ++i) for(int j=0; j<10; ++j) {
		for(int k=0; k<7; ++k) dc[i][j][k] = '0'+((dig[i][k]-'0')^(dig[j][k]-'0')); dc[i][j][7] = 0;
	}
	while(1) {
		cin >> n; if(n==-1) break;
		buf = -1;
		for(int i=0; i<n; ++i) {
			cin >> num;
			cout << (buf==-1?dig[num]:dc[buf][num]) << endl;
			buf = num;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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;}


template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

int main() {
    int n;
    cin >> n;
    cout << modpow((mint)10,n) - (mint)2 * modpow((mint)9,n) + modpow((mint)8,n) << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    cout<<(n*800)-(n/15)*200<<"\n";
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> Q;
    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        Q.push(A);
    }
    while(M--) {
        ll X = Q.top();
        Q.pop();
        Q.push(X >> 1);
    }
    ll ans = 0;
    while(!Q.empty()) {
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H=gets.to_i
W=gets.to_i
N=gets.to_i
m=max(H,W)
puts (N+m-1)/m

Measured memory_bytes: 14264
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int k,x,i,min,max;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  k=atoi(p);
  p=strtok(NULL," \n");
  x=atoi(p);
  
  min=x-(k-1);
  max=x+(k-1);
  
  for(i=min;i<=max;i++){
   if(i==max){
     printf("%d\n",i);
   }else{
     printf("%d ",i);
   }
  }
  
  
  return 0;
}

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

double expect(int total, int k){
  return (total+k)*0.5;
}

int main(void){
  int i;
  int n,k;
  int total=0;
  double max1=0.0;
  vector<int> p(n);
  cin>>n>>k;
  rep(i,n)cin>>p[i]; 
  rep(i,n){
  	if(i<k)total+=p[i];
 	else total+=p[i]-p[i-k];
    max1 = max1>expect(total,k)?max1:expect(total,k);
  }
  printf("%.10f\n",max1);
  return 0;
}

Measured memory_bytes: 16640
import numpy as np
a, b, c, d = map(int, input().split())

hoge = []
hoge.append(a*c)
hoge.append(a*d)
hoge.append(b*c)
hoge.append(b*d)

if max(hoge) < 0:
  if np.sign(a) != np.sign(b) or np.sign(c) != np.sign(d):
    print(0)
  else:
    print(max(hoge))
else:
  print(max(hoge))

Measured memory_bytes: 27148
N,Y = map(int,input().split())
if Y-1000*N<0:
    a1 = -1
    a2 = -1
    a3 = -1
else:
    flag = 0
    for i in range((Y//1000-N)//9+1):
        if (Y//1000-N-9*i)%4==0:
            a1 = i
            a2 = (Y//1000-N-9*i)//4
            a3 = N-a1-a2
            if a1>=0 and a2>=0 and a3>=0:
                flag = 1
                break
    if flag==0:
        a1 = -1
        a2 = -1
        a3 = -1
print(a1,a2,a3)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i; i<n; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a.begin(), a.end());
  for(int i; i<n; i++){
    if(b[i]==a[n-1]) cout << a[n-2] << endl;
    else cout << a[n-1] << endl;
  }
 }

Measured memory_bytes: 3200
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int main(){
  int i;
  long long res = 0;
  rd(N);
  for(i=(1);i<(N+1);i++){
    int j;
    for(j=(i);j<(N+1);j+=(i)){
      res += j;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// {
//   ll res = 0;
//   rd(N);
//   rep(i,1,N+1) rep(j,i,N+1,i) res += j;
//   wt(res);
// }


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

int main(){
	int size,i,chk=0;
	string s;
	cin >> s;
	size = (int)(s.length());

	for(i = 0; i < (size-1)/2; i++){
		if(s[i] != s[size-1-i]){
			chk = 1;
			break;
		}
	}
	if(chk == 0){
		for(i = 0; i < (size-1)/4; i++){
			if(s[i] != s[(size-3)/2-i]){
				chk = 1;
				break;
			}
		}
	}
	if(chk == 0){
		for(i = 0; i < (size-1)/4; i++){
			if(s[size-1-i] != s[(size+1)/2+i]){
				chk = 1;
				break;
			}
		}
	}

	if(chk == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}


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

g = 0
k = 0
for i in range(n):
    if a[i]%2 == 1:
        k += 1
    else:
        g += 1

if k%2 ==1 and g != 0:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 14112
#include <stdio.h>
int main(void){
    int a[3][3],i,j,k,n,x;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        int flag=0;
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(a[j][k]==x){
                    a[j][k]=-1;
                    flag=1;
                    break;
                }
            }
            if(flag==1) break;
        }
    }
    for(i=0;i<3;i++){
        if(a[0][i]==-1 && a[1][i]==-1 && a[2][i]==-1){
            printf("Yes");
            return 0;
        }
    }
    for(i=0;i<3;i++){
        if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1){
            printf("Yes");
            return 0;
        }
    }
    if(a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1){
            printf("Yes");
            return 0;
        }
    if(a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1){
            printf("Yes");
            return 0;
        }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

const int N_MAX = 301;
double dp[N_MAX][N_MAX][N_MAX];
double N;

double solve(double one, double two, double three) {
    if(one == 0 && two == 0 && three == 0) return 0;
    if(dp[int(one)][int(two)][int(three)] != 0) return dp[int(one)][int(two)][int(three)];
    double ret = 0;
    if(one >= 1) ret += solve(one - 1, two, three) * one / (one + two + three);
    if(two >= 1) ret += solve(one + 1, two - 1, three) * two / (one + two + three);
    if(three >= 1) ret += solve(one, two + 1, three - 1) * three / (one + two + three);
    ret += N / (one + two + three);
    return dp[int(one)][int(two)][int(three)] = ret;
}

int main() {
    cin >> N;
    int a[int(N)];
    int oneCount = 0, twoCount = 0, threeCount = 0;
    rep(i, N) {
        cin >> a[i];
        if(a[i] == 1) ++oneCount;
        else if(a[i] == 2) ++twoCount;
        else ++threeCount;
    }
    cout << fixed << setprecision(15) << solve(oneCount, twoCount, threeCount) << endl;
}


Measured memory_bytes: 213248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x;cin>>x;
    if(x==7||x==5||x==3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

int main() {
    int n, k, l;
    vector<int> L;

    cin >> n >> k;

    for (int i=0; i<n; i++) {
        cin >> l;
        L.push_back(-l);
    }

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

    int ans = 0;
    for (int i=0; i<k; i++) {
        ans -= L[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val pq = collection.mutable.PriorityQueue[Int]()
    var flag = true
    while (flag) {
      sc.next match {
        case "insert" => (pq.enqueue(sc.nextInt))
        case "extract" => (println(pq.dequeue()))
        case "end" => flag = false
      }
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 492796
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int array[] = new int[num];
		
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		
		selectionSort(array, num);
		
		scanner.close();
	}

	public static void selectionSort( int[] numArray, int num){
		int count = 0;
		
		//選択ソート
		for (int i = 0; i < num - 1; i++) {
			// 比較元の配列番号をセットする
			int comp = i;
			// 最小値の探索
			for (int j = i + 1; j < num; j++) {
				if (numArray[comp] > numArray[j]) {
					// 最少値設定
					comp = j;
				}
			}
			// 最小値が入れ替わっていなければ数値を入れ替えない
			if (i == comp) {
				continue;
			}
			//入れ替え処理
			int sub = numArray[i];
			numArray[i] = numArray[comp];
			numArray[comp] = sub;
			count++;		//入れ替えたので足しこむ
		}
		//出力
		for(int i = 0; i < num; i ++ ){
			System.out.print(numArray[i]);
			if( i == num - 1) {
			System.out.print("\n");
			}else {
				System.out.print(" ");
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26384