akhauriyash/Code-Regression huggingface dataset:
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()
	S := sc.nextRuneSlice()
	set := make(map[rune]int)
	for _, r := range S {
		set[r]++
	}
	if len(set) == 2 {
		for _, v := range set {
			if v != 2 {
				fmt.Println("No")
			}
		}
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.math.*;
import java.text.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		DecimalFormat df = new DecimalFormat("#.000");
		for(int iter=0; iter<n; iter++){
			double x1 = in.nextDouble(), y1 = in.nextDouble(),
				x2 = in.nextDouble(), y2 = in.nextDouble(),
				x3 = in.nextDouble(), y3 = in.nextDouble();
			double a, b, r, det;
			det = 4.0 * ((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2));
			a = 2.0 * ((x1*x1+y1*y1-x2*x2-y2*y2)*(y1-y3)-(x1*x1+y1*y1-x3*x3-y3*y3)*(y1-y2));
			b = -2.0 *((x1*x1+y1*y1-x2*x2-y2*y2)*(x1-x3)-(x1*x1+y1*y1-x3*x3-y3*y3)*(x1-x2));
			a /= det;
			b /= det;
			r = Math.sqrt(Math.pow(x1-a, 2) + Math.pow(y1-b, 2));
			System.out.println(df.format(a) + " " + df.format(b) + " " + df.format(r));
		}
	}

}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> A;

signed main()
{
    cin >> N;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end(), greater<ll>());
    ll a = 0, b = 0;
    for(ll i = 0; i < N; ++i) {
        if(i % 2 == 0) { a += A[i]; }
        else { b += A[i]; }
    }
    printf("%lld\n", a-b);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 
 int a,c,d,e,k,j,b,l,m=0;
scanf("%d%d%d",&a,&b,&c);
m=b;
while(1)
{
 if(m%a==0)
{
printf("OK\n");
break;
}
if(m>=c)
{
printf("NG\n");
break;
}
m++;
}
return 0;
}

Measured memory_bytes: 1660
N = int(input())
H = input()
H = H.split()
for i, val in enumerate(H):
    H[i] = int(val)
maxNum = max(H)
counter = 0
for i in range(maxNum):
    for j, val in enumerate(H):
        if H[j] != 0:
            H[j] -= 1
            if j < (N-1):
                if H[j + 1] == 0:
                    counter += 1
            if j == (N - 1):
                counter += 1
    # print(H)
    # print(counter)
print(counter)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,sum;
int main(){
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	if(sum%10==0){
		int x=999;
		for(int i=0;i<n;i++)
			if(a[i]%10!=0)
				x=min(x,a[i]);
		if(x==999)
			cout << 0;
		else
			cout << sum-x;
	}
	else
		cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, Q; cin >> N >> Q;

  vector<vector<int>> edge(N, vector<int>());
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int counter[N], ans[N];
  rep(i, N) {
    counter[i] = 0;
    ans[i] = -1;
  }
  rep(i, Q) {
    int p, x;
    cin >> p >> x;
    counter[p-1] += x;
  }

  queue<int> q;
  q.push(0);
  ans[0] = counter[0];
  while (!q.empty()) {
    int from = q.front(); q.pop();
    for (const auto& to:edge[from]) {
      if (ans[to] == -1) {
        ans[to] = counter[to] + ans[from];
        q.push(to);
      }
    }
  }
  rep(i, N) {
    cout << ans[i] << " ";
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 16372
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static HashMap<String, ArrayList<String>> map;
	static HashSet<String> done;

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			sc.nextLine();
			String firstGroup = null;
			map = new HashMap<String, ArrayList<String>>();
			done = new HashSet<String>();
			for (int i = 0; i < N; ++i) {
				String[] elems = sc.nextLine().split(":|,|\\.");
				ArrayList<String> member = new ArrayList<String>();
				for (int j = 1; j < elems.length; ++j) {
					member.add(elems[j]);
				}
				map.put(elems[0], member);
				if (i == 0) firstGroup = elems[0];
			}
			HashSet<String> set = new HashSet<String>();
			get(set, firstGroup);
			System.out.println(set.size());
		}
	}

	static void get(HashSet<String> set, String name) {
		if (done.contains(name)) return;
		if (map.containsKey(name)) {
			for (String c : map.get(name)) {
				get(set, c);
			}
		} else {
			set.add(name);
		}
		done.add(name);
	}

}

Measured memory_bytes: 44172
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9

struct edge {
    int to;
    double cost;
};

// <最短距離, 頂点の番号>
using P = pair<double, int>;

int V;
const int ci = 2e5+ 5;
vector<edge> G[ci];
double d[ci];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) { //cout << "On" << endl;
        P p = que.top();
        que.pop();
        int v = p.second; //cout << "v=" << v << endl;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i]; //cout << "koo" << endl;
            if (d[e.to] > d[v] + e.cost) { //cout << e.cost << endl;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main(){
    int n, m; cin >> n >> m;
    priority_queue<int> pq;
    vector<int> v[100005];
    rep(i,n){
        int a, b; cin >> a >> b;
        v[a].pb(b);
    }
    ll ans = 0;
    for(int i = 1; i <= m; i++){
        for(auto j : v[i]) pq.push(j);
        if(pq.size()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<stack>
#include<cctype>
using namespace std;
int main()
{
	stack<int> S;
	while (true)
	{
		string s;
		cin >> s;
		if (cin.fail())
			break;
		if (s == "+")
		{
			int a = S.top();
			S.pop();
			int b = S.top();
			S.pop();
			S.push(a + b);
		}
		else if (s == "-")
		{
			int a = S.top();
			S.pop();
			int b = S.top();
			S.pop();
			S.push(b - a);
		}
		else if (s == "*")
		{
			int a = S.top();
			S.pop();
			int b = S.top();
			S.pop();
			S.push(a * b);
		}
		else
		{
			int a = atoi(s.c_str());
			S.push(a);
		}
	}
	int res = S.top();
	cout << res << endl;
}


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

int n, m, l, a[100][100], b[100][100];
long c[100][100];

void make(int ar[100][100],int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			cin >> ar[i][j];
		}
	}
}

void mul() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			c[i][j] = 0;
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			if (j == 0) {
				cout << c[i][j];
			}
			else {
				cout << " " << c[i][j];
			}
		}
		cout << endl;
	}
}

int main(){
	cin >> n >> m >> l;
	make(a, n, m);
	make(b, m, l);
	mul();

	return 0;
}

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

using namespace std;

struct node
{
    int i;
    int n;
    int p;
}num[200010];

bool cmp(node aa,node bb)
{
    return aa.n<bb.n;
}

bool cmp1(node aa,node bb)
{
    return aa.i<bb.i;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i].n);
        num[i].i=i;
    }
    sort(num,num+n,cmp);
    int mid=n/2;
    for(int i=0;i<n;i++)
    {
        if(num[i].n<num[mid].n)
            num[i].p=num[mid].n;
        else
            num[i].p=num[mid-1].n;
    }
    sort(num,num+n,cmp1);
    for(int i=0;i<n;i++)
        printf("%d\n",num[i].p);
    return 0;
}


Measured memory_bytes: 4480
# 解説動画みた： https://www.youtube.com/watch?v=XI8exXVxZ-Q
# 最小公倍数
# ユーグリッドの互除法

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def f(x, c, d):
    res = x
    res -= x//c
    res -= x//d
    res += x//lcm(c, d)
    return res

a, b, c, d = map(int, input().split())
ans = f(b, d, c) - f(a-1, c, d)
print(ans)

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,i,e[1000];
cin >> a >> b;
c=b-a+1;
d=b+a;
for(i=0;i<2*a;i++){
        e[i]=c;
c++;
if(c>=d)break;

}
for(i=0;i<2*a-1;i++){
    cout << e[i]<< " ";
}
return 0;
}


Measured memory_bytes: 256
using System;
class Program {
    static void Main (string[] args) {
        long input = long.Parse(Console.ReadLine ());
        long gohyaku = (input - (input % 500)) / 500;
        long left = input - gohyaku * 500;
        long go = (left - (left % 5)) / 5;
        long ans = gohyaku * 1000 + go * 5;
        Console.WriteLine(ans);
    }
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

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

int main() {
	ll k,n;
	cin >> n >> k;
	ll ans = 0;

	if(n == 0) {
		ans = 0;
	} else if(k == 1) {
		ans = 0;
	} else {
		if(n % k == 0) {
			ans = 0;
		} else {
			ans = mini(n, n - (n/k)*k);
			ans = mini(abs(n-(n/k)*k-k), ans);
		}
	}

	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll maxi=a[0],ans=0;
	for(ll i=1;i<n;i++)
	{
		if(maxi>a[i])
		{
			ans+=(maxi-a[i]);
		}
		else
		{
			maxi=a[i];
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 5136
#include<iostream>
using namespace std;
int main(){
    int N;
    int W[110];
    int res = 3000;
    cin>>N;
    for(int i = 0;i < N;i++){
        cin>>W[i];
    }
    int A = 0,B = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(j >= i+1){
                B += W[j];
            }else{
                A += W[j];
            }
        
    }
        res = min(res,abs(A-B));
        A = 0;
        B = 0;
    }
    
    
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	int a, b;
	cin >> a >> b;

	cout << (a + b + 1) / 2 << endl;

}

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

using namespace std;

int main()
{
	int n; cin>>n;
	vector<int> v(n);
	for(int i = 0; i<n-1; i++) cin>>v[i];
	
	vector<int> b(n);
	int pre = v[0];
	b[0] = pre;
	b[1] = pre;
	for(int i = 1; i<n-1; i++)
	{
		if(v[i]>pre)
		{
			b[i+1] = v[i];
			pre = v[i];
		}
		else
		{
			b[i] = b[i+1] = v[i];
			pre = v[i];
		}
	}
	int total = 0;
	for(int i = 0; i<n; i++)
	{
			total+=b[i];
	}
	cout<<total;
}


Measured memory_bytes: 256
import math

a, b, C = [float(x) for x in input().split()]

C = math.radians(C)

S = (1/2) * a * b * math.sin(C)

L = a + b + (math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C)))

h = 2 * S / a

print(S, L, h, sep = "\n")


Measured memory_bytes: 5708
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
A = Counter(A)
Q = int(input())
for _ in range(Q):
  B, C = map(int, input().split())
  if A.get(B):
    x = A.get(B)
    del A[B]
    if A.get(C):
      A[C] +=  x
    else:
      A[C] = x
    S += (C - B) * x
  print(S)

Measured memory_bytes: 21528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A * B % 2 == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0)
    x=x*(-1);
    if(x>=0)
    {
    ll res=0;
    ll z=(x/d);
    int flag=0;
	if(k<=z)
	{
	flag=1;
	res=x-(d*k);
	cout<<res;
    }
	ll m1=x-(d*z);
	ll m2=m1-d;
	if(m2<0)
	m2=m2*(-1);
	if((k-z)%2==0 && flag==0)
	cout<<m1;
	if((k-z)%2!=0 && flag==0)
	cout<<m2;
    }
    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,p;
    char ch=' ';
    string s;
    cin>>n;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        int x=s[i];
        x=x-64;
        p=(x+n)%26;
        if(p==0)p=26;
        p=p+64;
        ch=p;
        cout<<ch;
    }


}


Measured memory_bytes: 3592
let () =
  Printf.printf "%d\n" @@
  match read_line () with
  | "SUN" -> 7
  | "MON" -> 6
  | "TUE" -> 5
  | "WED" -> 4
  | "THU" -> 3
  | "FRI" -> 2
  | "SAT" -> 1



Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
sumdigits(n) = sum(digits(n))

n=parseInt(readline())
arr=Set{String}()
function dfs(cnt,s)
    if n==cnt
        push!(arr,s)
        return 0
    end
    for i in ["0","1","2"]
        dfs(cnt+1,s*i)
    end
end

function main()
    a=parseMap(split(readline()))
    dfs(0,"")
    ans=0
    for i in arr
        for j in 1:n
            if i[j]=='0' && a[j]%2==0
                ans+=1
                break
            elseif i[j]=='1' && (a[j]-1)%2==0
                ans+=1
                break
            elseif i[j]=='2' && (a[j]+1)%2==0
                ans+=1
                break
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 142200
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;

int main(){
    int N;
    set<string> S;
    string s;
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 19232
#include<iostream>
#define rep(i,n) for((i)=0;(i)<(n);i++)

using namespace std;

int v[3],n,c;
string s;

int f(){
  n++;
  int r;
  if(s[n-1]=='(')r=f(),n++,r=s[n-1]=='+'?max(r,f()):min(r,f()),n++;
  else if(s[n-1]=='-')r=2-f();
  else if(s[n-1]-'P'>=0)r=v[s[n-1]-'P'];
  else r=s[n-1]-'0';
  return r;
}

int main(){ 
  cin >> s;
  if(s!="."){
    c=0;
    rep(v[0],3)rep(v[1],3)rep(v[2],3)n=0,c+=f()/2;
    cout << c << endl;
    main();
  }
}

Measured memory_bytes: 1188
#include <stdio.h>
int main(){
  int N,K,i,j;
  int a[1000],b[1000],A[1000],B[1000];
  scanf("%d %d",&N,&K);
  for(i=0;i<K;i++){
    scanf(" %d %d",&a[i],&b[i]);
  }
  for(i=0;i<K;i++){
    if(a[i]>N/2){
      A[i]=N-a[i]+1;
    } else{
      A[i]=a[i];
    }
    if(b[i]>N/2){
      B[i]=N-b[i]+1;
    } else{
      B[i]=b[i];
    }
    if(A[i]==B[i]&&A[i]<=N/2){
      if(A[i]%3==1){
        printf("1\n");
      } else if(A[i]%3==2){
        printf("2\n");
      } else if(A[i]%3==0){
        printf("3\n");
      }
    } else if(A[i]==B[i]&&A[i]>N/2){
      if((N-A[i])%3==1){
        printf("1\n");
      } else if((N-A[i])%3==2){
        printf("2\n");
      } else if((N-A[i])%3==0){
        printf("3\n");
      }
    } else if(A[i]>B[i]&&B[i]<=N/2){
      if(B[i]%3==1){
        printf("1\n");
      } else if(B[i]%3==2){
        printf("2\n");
      } else if(B[i]%3==0){
        printf("3\n");
      }
    } else if(A[i]>B[i]&&B[i]>N/2){
      if((N-B[i])%3==1){
        printf("1\n");
      } else if((N-B[i])%3==2){
        printf("2\n");
      } else if((N-B[i])%3==0){
        printf("3\n");
      }
    } else if(A[i]<B[i]&&A[i]<=N/2){
      if(A[i]%3==1){
        printf("1\n");
      } else if(A[i]%3==2){
        printf("2\n");
      } else if(A[i]%3==0){
        printf("3\n");
      }
    } else if(A[i]<B[i]&&A[i]>N/2){
      if((N-A[i])%3==1){
        printf("1\n");
      } else if((N-A[i])%3==2){
        printf("2\n");
      } else if((N-A[i])%3==0){
        printf("3\n");
      }
    }
  }
  return 0;
} 

Measured memory_bytes: 2596
#include<stdio.h>

int main(void)
{
    int a, b;
    
    while(1){
        scanf("%d %d", &a, &b);
        if(a==0 && b==0){
            break;
        }else if(a>b){
            printf("%d %d\n", b, a);
        }else{
            printf("%d %d\n", a, b);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
def func(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)

n = int(input())
LL = [list(map(int,input().split())) for _ in range(n)]
t0,x0,y0 = 0,0,0
ans = "Yes"
for l in LL:
    t,x,y = l[0],l[1],l[2]
    dist = func(x0,y0,x,y)
    time = t-t0
    if dist-time > 0 or (dist-time <= 0 and (dist-time)%2 == 1):
        ans = "No"
        break
print(ans)

Measured memory_bytes: 27324
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    s = input()
    print('Yes') if '7' in s else print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9000
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(2, int(n**0.5)+1):
    while(n%i == 0):
        n//=i
        d[i]+=1
if n > 1:
    d[n]+=1
ans = 0
for i in d.values():
    val = 1
    while i >= val:
        i-=val
        ans+=1
        val+=1
print(ans)

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

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

const int N = 1000+2, MOD = 1e9+7;
char a[N][N];
ll memo[N][N];

int main() {
	int h,w;
	cin >> h >> w;
	memset(memo, 0, sizeof memo);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> a[i][j];
			if(a[i][j] == '.') memo[i][j] = -1;
			else memo[i][j] = 0;
		}
	}
	memo[1][1] = 1;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(i == 1 && j == 1) continue;
			if(memo[i][j] == 0) continue;
			ll up = 0, left=0;
			if(i > 1) up = memo[i-1][j];
			if(j > 1) left = memo[i][j-1];
			memo[i][j] = (up+left)%MOD;
		}
	}
	cout << memo[h][w];
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <map>

int main(){
 long long N,K;
 std::cin>>N>>K;
 std::vector<long long> a(N+1);
 for(int i=1;i<=N;i++){
  std::cin>>a[i];
 }

 std::map<long long,long long> m;
 int count=0;
 int current=1;
 while(m[current]==0 || count==0){
  count++;
  m[current]=count;
  current=a[current];
 }
 long long loop=count+1-m[current];
 long long kk=(K-m[current]+1)%loop;
 //std::cout<<m[current]<<" "<<loop<<" "<<kk<<std::endl;
 if(K<count){
  kk=K;
  current=1;
 }
 for(int i=0;i<kk;i++){
  current=a[current];
 }

 std::cout<<current<<std::endl;

 return 0;
}

Measured memory_bytes: 17080
def main():
    length, num = map(int, input().split())
    a = list(map(int, input().split()))
    max_dis = 0
    first_h = a[0]
    prev_h = a[0]
    for h in a[1:]:
        dis = h - prev_h
        max_dis = max(max_dis, dis)
        prev_h = h

    dis = (length - prev_h) + first_h
    max_dis = max(max_dis, dis)
    print(length - max_dis)


if __name__ == "__main__":
    main()

Measured memory_bytes: 26060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;
int lst[Max];

bool compare(int a,int b)
{
	if (a < b)return true;
	return false;
}

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 1;i <= n;i++)
	{
		scanf("%d", &lst[i]);
		sum += lst[i];
	}
	sort(lst + 1, lst + 1 + n, compare);
	if (sum % 10 != 0)cout << sum;
	else
	{
		int f = 1;
		for (int i = 1;i <= n;i++)
		{
			if (lst[i] % 10 != 0)
			{
				sum -= lst[i];
				f = 0;
				break;
			}
		}
		if (f)cout << 0;
		else
		cout << sum;
	}
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int A,B,C,K; // C > B > A
  cin >> A >> B >> C >> K;
  int count = 0;
  while(A >= B){
    count++;
    B *= 2;
  }
  while(A >= C){
	count++;
    C *= 2;
  }
  while(C <= B){
    count++;
    C *= 2;
  }
  if(count <= K){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int F[101][11];
int P[101][11];
int main() {
    int N;
    cin >> N;
    REP(i, N) {
        REP(j, 10) { cin >> F[i][j]; }
    }
    REP(i, N) {
        REP(j, 11) { cin >> P[i][j]; }
    }
    long long ans = -INF;
    for(int msk = 1; msk < 1 << 10; msk++) {
        long long sm = 0;
        REP(i, N) {
            int cnt = 0;
            REP(j, 10) {
                if(msk & (1 << j)) {
                    if(F[i][j]) {
                        cnt++;
                    }
                }
            }
            sm += P[i][cnt];
        }
        ans = max(ans, sm);
    }
    cout << ans << endl;
}

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

namespace ABC
{
    class APC2020C
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var N = RI();

            int[] ans = new int[N + 1];
            for (int x = 1; ; ++x)
            {
                for (int y = 1; y <= x; ++y)
                {
                    for (int z = 1; z <= y; ++z)
                    {
                        int n = x * x + y * y + z * z + x * y + y * z + z * x;
//                        Console.WriteLine(x + " " + y + " " + z + " -> " + n);

                        if (n <= N)
                        {
                            int add;
                            if (z == y && y == x)
                            {
                                add = 1;
                            }
                            else if (z == y || y == x)
                            {
                                add = 3;
                            }
                            else
                            {
                                add = 6;
                            }
                            ans[n] += add;
                        }

                        if (z == 1 && y == 1)
                        {
                            if (n > N)
                            {
                                goto EXIT;
                            }
                        }
                        /*
                        if (++cnt == 100)
                        {
                            goto EXIT;
                        }
                        */
                    }
                }
            }
EXIT:
            for (int i = 1; i <= N; ++i)
            {
                Console.WriteLine(ans[i]);
            }

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


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

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

  ll a, b;
  cin >> a >> b;

  cout << a / __gcd(a, b) * b << '\n';

  return (0);
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

const int N = 1e6;

int n , a[N];

int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    cin >> n;
    int Xor = 0;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
        Xor ^= a[i];
    }

    for(int i = 1 ; i <= n ; i++){
        cout << (Xor ^ a[i]) << " ";
    }

    return 0;
}



Measured memory_bytes: 5172
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    int x[4];
    char op[3];
    random_device rd;
    for(int i = 0; i < 4; i++){
        char c;
        cin >> c;
        x[i] = c-'0';
    }
    while(1){
        int y = x[0];
        for(int i = 1; i < 4; i++){
            if(rd()%2 == 0){
                y += x[i];
                op[i-1] = '+';
            }else{
                y -= x[i];
                op[i-1] = '-';
            }
        }
        if(y == 7){
            cout << x[0] << op[0] << x[1] << op[1] << x[2] << op[2] << x[3] << "=7" << endl;
            return;
        }
    }
}

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

Measured memory_bytes: 256
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e5 + 7;
typedef vector < vector < ll > > matrix;
   
int main()
{   
    speed;
    int n;
    cin >> n;
    vector < int > a(n), dp(n);
    forn( i, n ) cin >> a[i];
    dp[0] = 0;
    dp[1] = abs( a[1] - a[0] );
    fore( i, 2, n ) {
        int mn1 = dp[i - 1] + abs( a[i] - a[i - 1] ), mn2 = dp[i - 2] + abs( a[i] - a[i - 2] );
        dp[i] = min( mn1, mn2 );
    }
    cout << dp[n - 1];
    time;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
A = inputIL()

a = [i-A[i] for i in range(N)]
b = [i+A[i] for i in range(N)]

key = list(set(a)|set(b))
dic = {k:0 for k in key}
for k in a:
  dic[k] += 1

ans = 0
for i in range(N):
  dic[a[i]] -= 1
  ans += dic[b[i]]

print(ans)
  

Measured memory_bytes: 170064
#include<stdio.h>

void swaps(int *x,int *y){
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
        swaps(&a,&b);
    if(b>c)
        swaps(&b,&c);
    if(a>b)
        swaps(&a,&b);
        
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vi C(26), Last(26, -1), T(365);
vector<vi> S(365, vi(26));
vector<vi> table(365, vi(26));
ll ans = 0;
int D, M;

void Query(int d, int q) {
  int prev;
  prev = T.at(d);
  T.at(d) = q;
  ll sabun = 0;
  sabun += (S.at(d).at(q) - S.at(d).at(prev));

  sabun += table.at(d).at(q);
  table.at(d).at(q) = 0;
  for (int i = d + 1; i < D && table.at(i).at(q) != 0; i++) {
    sabun += table.at(i).at(q);
    table.at(i).at(q) = table.at(i - 1).at(q) + C.at(q);
    sabun -= table.at(i).at(q);
  }
  /*
  cout << "table " << q << ": ";
  REP(i, D) cout << table.at(i).at(q) << " ";
  cout << "\n";
  */

  table.at(d).at(prev) =
      (d == 0) ? C.at(prev) : table.at(d - 1).at(prev) + C.at(prev);
  sabun -= table.at(d).at(prev);
  for (int j = d + 1; j < D && table.at(j).at(prev) != 0; j++) {
    sabun += table.at(j).at(prev);
    table.at(j).at(prev) = table.at(j - 1).at(prev) + C.at(prev);
    sabun -= table.at(j).at(prev);
  }
  /*
  cout << "table " << prev << ": ";
  REP(i, D) cout << table.at(i).at(prev) << " ";
  cout << "\n";
  cout << "sabun = " << sabun << endl;
*/
  ans += sabun;
  // cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"

  cin >> D;
  REP(i, 26) cin >> C.at(i);
  REP(i, D) REP(j, 26) cin >> S.at(i).at(j);

  REP(i, D) { T.at(i) = i % 26; }

  for (int i = 0; i < D; i++) {
    REP(j, 26) {
      if (j == T.at(i)) {
        Last.at(j) = i;
        table.at(i).at(j) = 0;
      } else {
        table.at(i).at(j) = C.at(j) * (i - Last.at(j));
      }
    }
    // cout << count << endl;

    // cout << "T = " << T.at(i) << " S = " << S.at(i).at(T.at(i)) << endl;
    ans += S.at(i).at(T.at(i));
  }

  REP(i, D) {
    REP(j, 26) { ans -= table.at(i).at(j); }
  }
  /*
    REP(i, 26) {
      cout << "table " << i << ": ";
      REP(j, D) cout << table.at(j).at(i) << " ";
      cout << "\n";
    }
    cout << ans << endl;
  */

  random_device rnd;
  mt19937 mt((int)time(0));
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  // Query
  REP(i, 100000) {
    ll pans = ans;
    vector<vi> oldtable = table;
    int d = rand365(mt), q = rand26(mt);
    // cout << d << " " << q << endl;
    int oq = T.at(d);
    Query(d, q);
    if (ans < pans) {
      ans = pans;
      T.at(d) = oq;
      table = oldtable;
    }
  }

  REP(i, D) cout << T.at(i) + 1 << endl;
  /*
std::random_device rnd;  // 非決定的な乱数生成器を生成
std::mt19937 mt(
    rnd());  //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
std::uniform_int_distribution<> rand100(0, 99);  // [0, 99] 範囲の一様乱数
for (int i = 0; i < 20; ++i) {
  std::cout << rand100(mt) << "\n";
}*/
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint a(1<<n);
  for(auto&& e:a)cin>>e;
  auto fst = a;
  vecint snd(1<<n,0);
  vecint tmp(4);
  REP(i,n)REP(j,1<<n) {
    if ((j>>i)&1) {
      tmp[0] = fst[j];
      tmp[1] = snd[j];
      tmp[2] = fst[j^(1<<i)];
      tmp[3] = snd[j^(1<<i)];
      sort(ALL(tmp),greater<int>());
      fst[j] = tmp[0];
      snd[j] = tmp[1];
    }
  }
  vecint res(1<<n);
  REP(i,1<<n){
    res[i] = fst[i] + snd[i];
    if (i) {
      res[i] = max(res[i], res[i-1]);
      cout<<res[i]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7168
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char S[100000];
	int N = fread_unlocked(S, 1, 100000, stdin);

	bool OK = 1;
	int i = N - 2;
	while (i >= 4) {
		if (S[i] == 'r' && S[i - 1] == 'e') {
			if (i >= 5 && S[i - 2] == 's' && S[i - 3] == 'a' && S[i - 4] == 'r' && S[i - 5] == 'e') i -= 6;
			else if (i >= 6 && S[i - 2] == 'm' && S[i - 3] == 'a' && S[i - 4] == 'e' && S[i - 5] == 'r' && S[i - 6] == 'd') i -= 7;
			else break;
		}
		else {
			if (S[i] == 'm' && S[i - 1] == 'a' && S[i - 2] == 'e' && S[i - 3] == 'r' && S[i - 4] == 'd') i -= 5;
			else if (S[i] == 'e' && S[i - 1] == 's' && S[i - 2] == 'a' && S[i - 3] == 'r' && S[i - 4] == 'e') i -= 5;
			else break;
		}
	}
	if (i == -1) printf("YES\n");
	else printf("NO\n");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int a, b, num, z;
  num = 0;
  cin >> a >> b;
  for(int x = 0; x <= a; x++) {
    for(int y = 0; y <= a; y++) {
      z = b - x - y;
      if(z >= 0 && z <= a) {
        num += 1;
      }
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    ll point = (ll)N*(N-1)/2;
    vector<ll> ans;
    UnionFind tree((ll)N);
    int A[100100],B[100100];
    rep(i,0,M){
        int a,b; cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
    } 

    
    rep(i,0,M){
        ans.pb(point);
        if(tree.same(A[M-1-i], B[M-1-i])) continue;

        ll a = tree.size(A[M-1-i]);
        ll b = tree.size(B[M-1-i]);
        point -= a*b;
        tree.unite(A[M-1-i], B[M-1-i]);
    }
    reverse(all(ans));
    rep(i,0,SZ(ans)) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<int> L(2*N);
    rep(i,2*N){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    int ans=0;
    rep(i,N){
        ans+=L[2*i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(){
    int  N,K,ans = 0;
  cin >> N >> K;
  int X[N];
    for(int i=0;i<N;i++){
    cin >> X[i];
    if(X[i]>= K)ans++;
    }

    cout << ans << endl;

  
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<string>
#include<stdlib.h>
#include<iostream>
#include<stack>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
#define MST(vis,x) memset(vis,x,sizeof(vis))
#define maxn 200010
#define maxm 1010
#define INF 0x3f3f3f3f
int main()
{
    ll s1[60];
    ll k,n,x,temp,all;
    while(scanf("%lld",&n)!=EOF)
    {
        all=0;
        for(int a=1;a<=n;a++)
            scanf("%lld",&s1[a]);
        sort(s1+1,s1+1+n);
        while(s1[n]>=n)
        {
            ll temp=s1[n]/n;
            s1[n]%=n;
            for(int a=1;a<=n-1;a++)
                s1[a]+=temp;
            sort(s1+1,s1+1+n);
            all+=temp;
        }
        printf("%lld\n",all);
    }
    return 0;
}


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

int main(){
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    
    int card[110];
    for (int i = 0; i < 110; i++) card[i] = 0;
    int temp;
    for (int j = 0; j < N; j++){
        int current_max = 0;
        for (int i = 0; i < N; i++){
            if (a[i] >= current_max) {
                current_max = a[i];
                temp = i;
            }
        }
        card[j] = current_max;
        a[temp] = 0;
    }
    int Ascore = 0;
    int Bscore = 0;
    for (int i = 1; i <= N; i++){
        if(i%2 == 1) Ascore += card[i-1];
        else Bscore += card[i-1];
    }
    // cout << Ascore << endl;
    // cout << Bscore << endl;
    cout << Ascore - Bscore << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var o, e string
	fmt.Scan(&o, &e)
	for i := 0; i < len(o); i++ {
		fmt.Printf("%s", string(o[i]))
		if i < len(e) {
			fmt.Printf("%s", string(e[i]))
		}
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = 2e5 + 5;
ll a[MAX];
ll b[MAX];
bool ok(ll n,ll m ,ll x) {
	REP(i, 1, m) {
		b[i] = (a[i] >= x);
	}
	ll c = b[n];
	REP(i, 1, n - 1) {
		if ((!(b[n - i + 1] ^ b[n - i])) || !((b[n + i - 1] ^ b[n + i]))) {
			return b[n - i + 1];
		}
	}
	if (n % 2 == 0) {
		return !b[n];
	}
	else {
		return b[n];
	}
}

int main() {
	cin.tie(0);
	ll n;
	cin >> n;
	ll m = 2 * n - 1;
	REP(i, 1, m) {
		cin >> a[i];
	}
	ll ub = m; ll lb = 1;
	while (ub - lb > 1) {
		ll mid = (ub + lb) / 2;
		if (ok(n,m,mid)) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	cout << lb << endl;
}

Measured memory_bytes: 3456
#https://atcoder.jp/contests/agc034/submissions/5781329
S = input()
ans = 0
a = 0
i = 0
while (i < len(S)):
  if S[i] == 'A':
    a += 1
    i += 1
  elif S[i:i+2] == 'BC':
    ans += a
    i += 2
  else:
    a = 0
    i += 1
print(ans)


Measured memory_bytes: 40304
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double[] e = new double[1001];
    for(int i = 1; i <= 1000; i++) {
      double sum = 0;
      for(int j = 1; j <= i; j++) {
        sum += ((double)j / (double)i);
      }
      e[i] = sum;
    }
    int n = sc.nextInt();
    int k = sc.nextInt();
    double[] rui = new double[n + 1];
    for(int i = 1; i <= n; i++) {
      int p = sc.nextInt();
      rui[i] = rui[i - 1] + e[p]; 
    }
    double ans = 0;
    for(int i = k; i <= n; i++) {
      ans = Math.max(ans, rui[i] - rui[i - k]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 81920