akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int main(){
	int N;
	cin>>N;
	int sum=0,mem=N;
	while(mem){
		sum+=mem%10;
		mem/=10;
	}
	if(N==10||N==100||N==1000||N==10000||N==100000){
		cout<<10<<endl;
	}else{
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
X, Y, p, q, r = list(map(int, input().split()))
P = list(sorted(list(map(int, input().split())), reverse = True))
Q = list(sorted(list(map(int, input().split())), reverse = True))
R = list(sorted(list(map(int, input().split())), reverse = True))
all_values = P[:X] + Q[:Y] + R[:X+Y]
all_values = list(sorted(all_values, reverse = True))
print(sum(all_values[:X+Y]))

Measured memory_bytes: 24308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n,0);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll ln=-1;
    ll ml=0;
    for(ll i=0;i<n;i++)
    {
        if(ln!=v[i])
        {
            ml++;
            ln=v[i];
        }
    }
    cout<<ml<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string s, t;
    cin >> s;
    cin >> t;
    REP(i, s.size()) {
        if(s[i] == t[i]) {
            
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int t1;
  int t2 = 0;
  int a1;
  int a2 = 0;
  int b1;
  int b2 = 0;

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t1 >> a1 >> b1;
    int s = abs(a1 - a2) + abs(b1 - b2);
    if (s > (t1 - t2) || ((s % 2) != ((t1 - t2) % 2))) {
      cout << "No" << endl;

      return 0;
    }
    a2 = a1;
    b2 = b1;
    t2 = t1;
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3112
def main():
    n,k = map(int, input().split())
    S = list(input())

    count = 0
    first_char = S[0]
    before_char = first_char
    if first_char == 'L':
        not_first_char = 'R'
    else:
        not_first_char = 'L'
    for i in range(1,n):
        if count == k:
            break
        if S[i] == first_char:
            if before_char == first_char:
                continue
            else:
                before_char = first_char
                count += 1
        else:
            if before_char == first_char:
                S[i] = first_char
                before_char = not_first_char
            else:
                S[i] = first_char
                continue

    ans = 0
    for i in range(1,n):
        if S[i-1] == S[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49392
#include <iostream>
#include <memory>
#include <cmath>

constexpr int max_size()
{
    return static_cast<int>(1e+6);
}

int insert(int* a, const int i, const int gear)
{
    if (i < gear) {
        return 0;
    }

    if (a[i - gear] <= a[i]) {
        return 0;
    }

    std::swap(a[i - gear], a[i]);
    return 1 + insert(a, i - gear, gear);
}

int insertion_sort(int* arr, const int n, const int gear)
{
    int insert_count = 0;
    for (int i = 0; i < n; i += gear) {
        insert_count += insert(arr, i, gear);
    }
    return insert_count;
}

int pow(const int a, const int x) {
    return x == 0 ? 1 : a * pow(a, x - 1);
}

void print(int* arr, const int n, char const delim) {
    int i = 0;
    for (; i < n - 1; ++i) {
        std::cout << arr[i] << delim;
    }
    std::cout << arr[i];
}

void shell_sort(int* arr, const int n) {
    static const double log3 = std::log(3);
    const int gear_index = static_cast<int>(std::log(2 * n + 1) / log3 - 1);
    int gear = (pow(3, gear_index + 1) - 1) >> 1;

    int gear_cache[100];
    int cache_idx = 0;
    int insert_count = 0;

    for (; gear > 0; gear = (gear - 1) / 3) {
        gear_cache[cache_idx] = gear;
        for (int i = 0; i < gear; ++i) {
            insert_count += insertion_sort(arr + i, n - i, gear);
        }
        ++cache_idx;
    }

    std::cout << cache_idx << std::endl;
    print(gear_cache, cache_idx, ' ');
    std::cout << std::endl;
    std::cout << insert_count << std::endl;

    return;
}

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

    int n;
    std::cin >> n;

    constexpr int N = max_size();
    const auto r = std::make_unique<int[]>(N);
    for (int i = 0; i < n; ++i) {
        std::cin >> r[i];
    }

    shell_sort(r.get(), n);
    print(r.get(), n, '\n');

    return 0;
}

Measured memory_bytes: 6792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int st[100];
  int I=0;
  while(1){
    stringstream ss;
    cin >> a;
    if(cin.eof())break;
    if(a[0]>='0'&&a[0]<='9'){
      ss << a;
      ss >> st[I];
      //cout << st[I];
      I++;
    }
    else{
      int r;
      int l;
      r=st[I-1];
      l=st[I-2];
      // cout << l << " "<<r<<endl;
      I-=2;
      if(a=="+"){
	st[I]=l+r;
	I++;
      }
      else if(a=="-"){
	st[I]=l-r;
	I++;
      }
      else{
	st[I]=l*r;
	I++;
      }
    }
  }
  cout << st[0]<<endl;
  return 0;
}

Measured memory_bytes: 3196
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> a(n, std::vector<int>(m));
    std::vector<int> b(m);

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            int val;
            std::cin >> val;
            a.at(i).at(j) = val;
        }
    }

    for(int i = 0; i < m; ++i){
        int val;
        std::cin >> val;
        b.at(i) = val;
    }

    for(int i = 0; i < n; ++i){
        int val = 0;
        for(int j = 0; j < m; ++j){
            val += a.at(i).at(j) * b.at(j);
        }

        std::cout << val << std::endl;
    }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int d[n];
    int ans=0;
    for(int i=0;i<n;i++)cin>>d[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, A;
	cin >> N >> A;

	vector<vector<lint>> DP(50 * 50 * 2 + 1 + 1, vector<lint>(50 + 1, 0));

	lint midium = 50 * 50 + 1;

	DP[midium][0] = 1;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;

		lint set = tmp - A;
		for (int j = 0; j < midium * 2; j++)
		{

			if (j - set < 0 || midium * 2 <= j - set)
				DP[j][i + 1] = DP[j][i];
			else
				DP[j][i + 1] = DP[j][i] + DP[j - set][i];
				}
	}

	cout << DP[midium][N] - 1 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 2432
N=int(input())
S=input()
cnt=0
for i in range(N):
    left=i-1
    right=i+1
    while 0<=left and right<N:
        if S[i]!=S[left] and S[i]!=S[right] and S[left]!=S[right]:
            cnt+=1
        left-=1
        right+=1
x=S.count('R')
y=S.count('G')
z=S.count('B')
print(x*y*z-cnt)


Measured memory_bytes: 9200
n, *d = map(int, open(0).read().split())
d = ''.join(map(str, d))
se = set()
for i in range(n):
    for j in range(i + 1, n + 1):
        se.add(int(d[i:j]))
ans = 0
while ans in se:
    ans += 1
print(ans)


Measured memory_bytes: 104720
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int i,n = s.size(),cnt = 0;
	for(i=0;i<n;i++){
		if(s[i]=='o'){
			cnt++;
		}
	}
	cnt += 15 - n;
	if(cnt>=8){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
ls = [int(input()) for i in range(q)]
a = [0 for k in range(n)]
for j in range(q):
    b = ls[j] - 1
    a[b] += 1
for l in range(n):
    if q - a[l] < k:
        print("Yes")
    else:
        print("No")

    

Measured memory_bytes: 8632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string YABAI, WAYO;
  char moji;
  int A, B, C, D, E;
  
  cin >> moji;
  
  if((moji>= 'a') && (moji<='z')){
    cout << 'a' << endl;
  }
  else if((moji>= 'A') && (moji<='Z')){
    cout << 'A' << endl;
  }
  
}


Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int a,b;cin>>a>>b;
	int i=1;
	while((int)(b/pow(10,i))!=0) i++;
	a*=pow(10,i);
	int c=a+b;
	if((int)sqrt(c)*sqrt(c)==c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main(int argc, char const *argv[]) {
  int N;
  int M;
  cin >> N >> M;

  int A[M];
  int sum = 0;
  for (int i = 0; i < M; i++){
    cin >> A[i];
    sum = sum + A[i];
  }
  int result;
  result = N - sum;
  if (result >= 0){
    cout << result << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}

Measured memory_bytes: 3648
N, M = [int(i) for i in input().split()]
graph = [[0]*N for i in range(N)]
vstd = [0] * N

for i in range(M):
    a, b = [int(i) for i in input().split()]
    graph[a-1][b-1] = graph[b-1][a-1] = 1
#print(*graph, sep="\n")

def dfs(v):
    vstd[v] = 1
    for v2 in range(N):
        if graph[v][v2] == 0:
            continue
        if vstd[v2] == 1:
            continue
        dfs(v2)
 
ans = 0
for i in range(N):
    for j in range(N):
        if graph[i][j] == 0:
            continue
        graph[i][j] = graph[j][i] = 0
        for k in range(N):
            vstd[k] = 0
        dfs(0)
        bridge = False
        for k in range(N):
            if vstd[k] == 0:
                bridge = True
        if bridge == True:
            ans += 1
        graph[i][j] = graph[j][i] = 1

print(ans//2)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define LL  long long
using namespace std;
const int Maxn = 100000 + 100;
int N;
LL A[Maxn], B[Maxn];
int main()
{
	scanf("%d", &N);
	for (int i = N; i >= 1; --i)
		scanf("%lld%lld", &A[i], &B[i]);
	LL Sum = 0;
	for (int i = 1; i <= N; ++i)
	{
		/*
		if (B[i] > (A[i] + Sum))
		{
			Sum += (B[i] - A[i] - Sum);
			continue;
		}
		*/
		A[i] += Sum;
		LL cnt = ((A[i]) / B[i]);
		if (A[i] % B[i])
		Sum += (B[i] * (cnt + 1) - A[i]);
		else Sum += (B[i] * cnt - A[i]);
	}
	cout<<Sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPostalCode solver = new BPostalCode();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPostalCode {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            String s = in.next();
            for (int i = 0; i < s.length(); i++) {
                if (i == a) {
                    if (s.charAt(i) != '-') {
                        out.println("No");
                        return;
                    }
                } else {
                    if (!Character.isDigit(s.charAt(i))) {
                        out.println("No");
                        return;
                    }
                }
            }
            out.println("Yes");
        }

    }
}



Measured memory_bytes: 23508
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	min := readMultiple(5)
	if n%min == 0 {
		fmt.Println(n/min + 4)
	} else {
		fmt.Println(n/min + 5)
	}
}

func readMultiple(n int) int {
	xi := []int{}
	min := 0
	for i := 0; i < n; i++ {
		j := 0
		fmt.Scan(&j)
		if i == 0 {
			min = j
		} else {
			if j < min {
				min = j
			}
		}
		xi = append(xi, j)
	}
	return min
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

#define M 10000000
bool prime[M];
int main()
{
	
	int ans, n;

	for (int i = 2; i * i < M; i++){
		if (prime[i] == false){
			for (int j = i; j < M; j += i){
				if (!(i == j)) {
					prime[j] = true;
				}
			}
		}
	}
	while (cin >> n){
	  ans = 0;
		for (int i = 2; i <= n; i++){
	 	 if (prime[i] == false) ans++;
	  }
		cout << ans << endl;
	}
	return (0);
}

Measured memory_bytes: 10924
class UnionFind

    def initialize(size)
        @rank = Array.new(size, 0)
        @parent = Array.new(size, &:itself)
    end
    def unite(id_x, id_y)
        x_parent = get_parent(id_x)
        y_parent = get_parent(id_y)
        return if x_parent == y_parent

        if @rank[x_parent] > @rank[y_parent]
            @parent[y_parent] = x_parent
        else
            @parent[x_parent] = y_parent
            @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
        end
    end

    def get_parent(id_x)
        @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
    end

    def same_parent?(id_x, id_y)
        get_parent(id_x) == get_parent(id_y)
    end

    def size
        @parent.map{ |id_x| get_parent(id_x) }.uniq.size
    end

end



n, m = gets.split(" ").map(&:to_i)
c = UnionFind.new(n)
m.times{ |i|
  a, b = gets.split(" ").map(&:to_i)
  c.unite(a-1, b-1)
}
puts c.size - 1

Measured memory_bytes: 19792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s;
  cin >> s;
  int len = s.length();

  if (len % 2 == 0) {
    // len : even
    if (s.front() == s.back()) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
  } else {
    // len : odd
    if (s.front() == s.back()) {
      cout << "Second" << endl;
    } else {
      cout << "First" << endl;
    }
  }
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)


def dfs(x, y, matrix, visited, isWhite):
    global black, white
    dxy = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    visited[y][x] = True
    w = len(matrix[0])
    h = len(matrix)

    for dx, dy in dxy:
        nx = x + dx
        ny = y + dy

        if nx < 0 or w <= nx or ny < 0 or h <= ny:
            continue

        if visited[ny][nx] is True:
            continue

        if (matrix[ny][nx] == "#" and isWhite is False) or (
            matrix[ny][nx] == "." and isWhite is True
        ):
            continue

        if matrix[ny][nx] == "#":
            black += 1
        else:
            white += 1

        isWhite = not isWhite
        dfs(nx, ny, matrix, visited, isWhite)
        isWhite = not isWhite

    return


h, w = map(int, input().split())
matrix = [""] * h
for i in range(h):
    matrix[i] = input()

ans = 0
visited = [[False] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if matrix[i][j] == "#" and visited[i][j] is False:
            black = 1
            white = 0
            dfs(j, i, matrix, visited, False)
            ans += black * white

print(ans)


Measured memory_bytes: 643400
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  vector<int> bingo (9);
  for(int i = 0;i < 3;i++){
  cin >> bingo.at(i * 3) >> bingo.at(i * 3 + 1) >> bingo.at(i * 3 + 2);
  }
  
  for(int i = 0; i < 9;i++){
  }
  
  vector<int> open (9);
  int N, num;
  cin >> N;
  for(int i = 0; i < N;i++){
  cin >> num;
    for(int j = 0;j < 9;j++){
      if(num == bingo.at(j)){
      open.at(j) = 1;
      }
    }
  }
  
  bool A = false;
  if(open.at(0) == 1 && open.at(1) == 1 && open.at(2) == 1) A = true;
  if(open.at(3) == 1 && open.at(4) == 1 && open.at(5) == 1) A = true;
  if(open.at(6) == 1 && open.at(7) == 1 && open.at(8) == 1) A = true;
  if(open.at(0) == 1 && open.at(3) == 1 && open.at(6) == 1) A = true;  
  if(open.at(1) == 1 && open.at(4) == 1 && open.at(7) == 1) A = true;  
  if(open.at(2) == 1 && open.at(5) == 1 && open.at(8) == 1) A = true;  
  if(open.at(0) == 1 && open.at(4) == 1 && open.at(8) == 1) A = true;  
  if(open.at(2) == 1 && open.at(4) == 1 && open.at(6) == 1) A = true;  
  if(A){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	var m = Int.MAX_VALUE
	var cnt = 0
	val n = scn.nextInt()
	repeat(n){
		val p = scn.nextInt()
		if (p<=m){
			cnt++
			m=p
		}
	}
	print(cnt)
}

Measured memory_bytes: 72940
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  set<int> s;
  int n,k,d;

  cin >> n >> k;

  for(ii=0;ii<k;ii++){
    cin >> d;

    ret.resize(d);
    for(jj=0;jj<d;jj++){
      cin >> ret[jj];
    }

    for(auto sunuke : ret){
      s.insert(sunuke);
    }
  }

  cout << n - s.size() << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll N;
  ll X, M;
  cin >> N >> X >> M;
  vector<ll> T(M, 0); // その数字が何番目に現れたか
  vector<ll> A(M + 1, 0); // i + 1番目までの和
  ll MX = X;
  ll ans = X;
  T.at(X) = 1;
  A.at(1) = X;
  for (ll i = 1; i < N; i++) {
    MX *= MX;
    MX %= M;
    if (T.at(MX) != 0) {
      ans += ((N - i) / (i + 1 - T.at(MX))) * (A.at(i) - A.at(T.at(MX) - 1));
      if (((N - i) % (i + 1 - T.at(MX))) != 0) {
        ans += (A.at(T.at(MX) + (((N - i) % (i + 1 - T.at(MX)))) - 1)
                - A.at(T.at(MX) - 1));
      }
      break;
    }
    else {
      T.at(MX) = i + 1;
      A.at(i + 1) += A.at(i);
      A.at(i + 1) += MX;
      ans += MX;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4852
object Main {
    def step(s: (Int, Int, Int), i: String) = i match {
        case "North" => (s._2, 7-s._1, s._3)
        case "East"  => (7-s._3, s._2, s._1)
        case "West"  => (s._3, s._2, 7-s._1)
        case "South" => (7-s._2, s._1, s._3)
        case "Right" => (s._1, s._3, 7-s._2)
        case "Left"  => (s._1, 7-s._3, s._2)
    }

    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (n <- in if n != "0") println(in.take(n.toInt).scanLeft((1, 2, 3))(step).map(_._1).sum)
    }
}

Measured memory_bytes: 44760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 200009;
const double pi = acos(-1.0);
int r;
int main(){
    scanf("%d",&r);
    printf("%.8lf",2*pi*r);
    return 0;
}

Measured memory_bytes: 3816
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

string s;
li n;

void solve(){
  li i;cin>>s;
  n=s.length();
  s='x'+s;
  rep(i,1,n+1){
    if(i+2<=n and s[i]==s[i+2]){
      cout<<i<<" "<<i+2;nl;
      return ;
    }
    if(i+1<=n and s[i]==s[i+1]){
      cout<<i<<" "<<i+1;nl;
      return ;
    }
  }
  cout<<"-1 -1";nl;
}

int main(){
  opt
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
ll l[15],r[15];
ll dp[200005];
ll pre[200005];
ll n,k;
ll ans=0;
int main()
{
    scanf("%d%d",&n,&k);
    for(ll i=1;i<=k;i++)
    {
        scanf("%d%d",&l[i],&r[i]);
    }
//    if(l[1]==n)
//    {
//        printf("0\n");
//        return 0;
//    }
    dp[1] = pre[1] = 1;
    for(int i = 2;i<=n;i++)
    {
        ans=0;
        for(int j=1;j<=k;j++)
        {
            if(i-r[j]>=1)
            {
                ans = (ans+pre[i-l[j]]-pre[i-r[j]-1] )%mod;
                ans = (ans+mod)%mod;
                //cout<<j<<" "<<pre[i-l[j]]<<" "<<pre[i-r[j]-1]<<" "<<ans<<endl;

            }
            else if(i-l[j]>=1)
            {
                ans = (ans + pre[i-l[j]])%mod;
            }

        }
        dp[i] = ans;
        pre[i] = (dp[i]+pre[i-1])%mod;
        //cout<<i<<" "<<dp[i]<<endl;
    }
    printf("%lld\n",dp[n]%mod);
    return 0;
}


Measured memory_bytes: 6948
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;
LL num(LL a) {
	if (a == 1)return 1;
	else return 2 * num(a / 2) + 1;
}
int main() {

	cin >> N;

	cout << num(N) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

class RMQ
{
private:
	int n;
	vector<long long int> v;

public:
	RMQ(int k)
	{
		n = k;
		v = vector<long long int>(2 * n, (1 << 31) - 1);
	}

	void update(int x, long long int val)
	{
		x += n - 1;
		v[x] = val;
		while(x > 0){
			x = (x - 1) / 2;
			v[x] = min(v[2 * x + 1], v[2 * x + 2]);
		}
	}

	long long int find(int tl, int tr, int nl, int nr, int index)
	{
		// [tl, tr)の最小値を求める
		// cout << tl << " " << tr << nl << nr << index << endl;
		if(tr <= nl || nr <= tl) return ((long long int)1 << 31) - 1;
		if(tl <= nl && nr <= tr) return v[index];
		// cout << find(tl, tr, nl, (nl + nr) / 2, 2 * index + 1);
		return min(find(tl, tr, nl, (nl + nr) / 2, 2 * index + 1), find(tl, tr, (nl + nr) / 2, nr, 2 * index + 2));
	}

	void print()
	{
		for(int i = 0; i < 2 * n; i++){
			cout << v[i] << " ";
		}
		cout << endl;
	}
};

int main()
{
	int n, q;
	cin >> n >> q;
	int tmp = 1;
	while(tmp < n) tmp = tmp << 1;
	RMQ rmq(tmp);
	for(int i = 0; i < q; i++){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			rmq.update(x, y);
		} else {
			cout << rmq.find(x, y + 1, 0, tmp, 0) << endl;
		}
		// rmq.print();
	}
	return 0;
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	string s, t;
    cin >> s;
    cin >> t;
    int n = s.size();
 
    int mas[26] = {}, mat[26] = {};
    bool f = true;
    for(int i = 0; i < n; i++)
    {
        if(mas[s[i] - 'a'])
        {
            if(mas[s[i] - 'a'] != (t[i] - 'a'))
            {
                f = false;
                break;
            }
        }
        else if(mat[t[i] - 'a'])
        {
            if(mat[t[i] - 'a'] != (s[i] - 'a'))
            {
                f = false;
                break;
            }
        }
        else
        {
            mas[s[i] - 'a'] = t[i] - 'a';
            mat[t[i] - 'a'] = s[i] - 'a';
        }
    }
 
    cout << (f ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 916
#include "iostream"
#include "vector"
#define N_MAX 100005

using namespace std;

// 素集合データ構造
struct UnionFind {
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        for (int i = 1; i < n; i++) {
            par[i] = i;
        }
    }

    // データxが属する木の根を得る
    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y) {
        // データの根ノードを得る
        x = find(x);
        y = find(y);

        // 既に同じ木に属しているならマージしない
        if (x == y) return;

        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y]) swap(x, y);

        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x) {
        return sizes[find(x)];
    }
};

int p[N_MAX];
int n, m;

int main() {

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(p[i], i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int N;
int X[100];

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

	int res = INF;
	for(int i = 0; i <= 100; i++){
		int tmp = 0;
		for(int j = 0; j < N; j++) tmp += (X[j] - i) * (X[j] - i);
		res = min(res, tmp);
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.split('\n');
  let iter = lines.nth(1).unwrap().bytes();

  let mut comb = [1u64, 0, 0, 0, 0, 0, 0];

  for ch in iter {
    let chg = match ch {
      b'J' => 1,
      b'O' => 2,
         _ => 4
    };
    let mut tmp = [0u64; 7];

    for (i, &n) in comb.iter().enumerate() {
      if n == 0 { continue }
      let bit = i + 1;

      if bit & (1 | chg) != 0 { tmp[(chg | 1) - 1] += n; }
      if bit & (2 | chg) != 0 { tmp[(chg | 2) - 1] += n; }
      if bit & (4 | chg) != 0 { tmp[(chg | 4) - 1] += n; }
      tmp[7 - 1] += n;
    }

    if tmp[7 - 1] >= 1<<62 {
      for n in &mut tmp { *n %= 10007; }
    }
    comb = tmp;
  }

  let sum = comb.into_iter().sum::<u64>() % 10007;
  println!("{}", sum);
}



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


int main(){
  int i;
  char s[100];
  int x[100];
  for(i=0;i<100;i++){
    x[i]=0;
  }
  i=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x[i-2]=x[i-1]+x[i-2];
      i--;
    }else if(s[0]=='-'){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    }else if(s[0]=='*'){
      x[i-2]=x[i-1]*x[i-2];
      i--;
    }else{
      x[i]=atoi(s);
      i++;
    }
  }
  printf("%d\n",x[i-1]);

  return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <stack>
#include <sstream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
	stack<int> stack;
	string line;
	getline(cin, line);
	stringstream ss(line);
	string input;

	while(ss >> input)
	{
		if (input == "+")
		{
			int a = stack.top();
			stack.pop();
			int b = stack.top();
			stack.pop();
			stack.push(b+a);
		}
		else if (input == "-")
		{
			int a = stack.top();
			stack.pop();
			int b = stack.top();
			stack.pop();
			stack.push(b-a);
		}
		else if (input == "*")
		{
			int a = stack.top();
			stack.pop();
			int b = stack.top();
			stack.pop();
			stack.push(a*b);
		}
		else if (input == "/")
		{
			int a = stack.top();
			stack.pop();
			int b = stack.top();
			stack.pop();
			stack.push(b/a);
		}
		else
		{
			istringstream iss(input);
			int x = 0;
			iss >> x;
			stack.push(x);
		}
	}
	cout << stack.top() << "\n";

	return 0;
}

Measured memory_bytes: 1236
import copy

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

    p1_total = 0
    p2_total = 0
    for i in range(N):
        if i % 2 == 0:
            tmp = max(A)
            p1_total += tmp
            del A[A.index(tmp)]
        else:
            tmp = max(A)
            p2_total += tmp
            del A[A.index(tmp)]

    print(p1_total - p2_total)

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  if (N == 10 || N == 100 || N == 1000 || N == 10000 || N == 100000)
    cout << 10 << endl;
  else if (N < 11)
    cout << N << endl;
  else if (N < 100) {
    if (N % 10 == 0)
      cout << N / 10 << endl;
    else
      cout << N / 10 + N % 10 << endl;
  }
  else if (N < 1000) {
    if (N % 100 == 0)
      cout << N / 100 << endl;
    else
      cout << N / 100 + N % 100 / 10 + N % 100 % 10 << endl;
  }
  else if (N < 10000) {
    if (N % 1000 == 0)
      cout << N / 1000 << endl;
    else
      cout << N / 1000 + N % 1000 / 100 + N % 1000 % 100 / 10 + N % 1000 % 100 % 10 << endl;
  }
  else if (N < 100000) {
    if (N % 10000 == 0)
      cout << N / 10000 << endl;
    else
      cout << N / 10000 + N % 10000 / 1000 + N % 10000 % 1000 / 100 + N % 10000 % 1000 % 100 / 10 + N % 10000 % 1000 % 100 % 10 << endl;
  }
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

ll now,n,k;






int main(){
  ll ans=0;
  cin>>n;
  vector<ll> a(n);
  vector<ll> prs;
  vector<ll> mns;

  REP(i,n){
    cin>>a[i];
  }

sort(a.begin(), a.end());
if (n==2){
  cout<<(a[1]-a[0])<<endl;
  cout<<a[1]<<" "<<a[0]<<endl;
  return 0;
}
ll maxans=0LL;
int pnp=-1;
if (a[0]>0){
  //a[0]のみマイナスで後プラス
  maxans=-a[0];
  mns.emplace_back(a[0]);
  REP(i,n-1){
    maxans+=a[i+1];
    prs.emplace_back(a[i+1]);
  }
}else{
  if (a[n-1]<0){
    maxans=a[n-1];
    prs.emplace_back(a[n-1]);
    REP(i,n-1){
      maxans-=a[i];
      mns.emplace_back(a[i]);
    }
    //a[n-1]のみプラスで後マイナス
  }else{
    maxans-=a[0];
    mns.emplace_back(a[0]);//最低でも１こいれる
    REP(i,n-1){
      if (a[i+1]>=0){
        pnp=i+1;
        break;
      }
      maxans-=a[i+1];
      mns.emplace_back(a[i+1]);
    }
    REP(i,n-pnp){
      maxans+=a[i+pnp];
      prs.emplace_back(a[i+pnp]);
    }
  }
}





//cout<<(maxdup)<<endl;
cout<<maxans<<endl;
ll m1;
ll p1;
ll rs;
if (prs.size()>=2){
  //最初にマイナスにしたいものを一つ選ぶ
  m1=mns.back();
  mns.pop_back();
  //次にプラスにしたいものを一つ選ぶ
  p1=prs.back();
  prs.pop_back();
  cout<<m1<<" "<<p1<<endl;
  rs=m1-p1;
  //次にプラスにしたいものを1このこすよう全部列挙していく
  for(int i=0;;i++){
    if (prs.size()==1){
      break;
    }
    p1=prs.back();
    prs.pop_back();
    cout<<rs<<" "<<p1<<endl;
    rs=rs-p1;
  }
}else{
  rs=mns.back();
  mns.pop_back();
}
//次にプラスをx、としてx-yをする
p1=prs.back();
prs.pop_back();
cout<<p1<<" "<<rs<<endl;
rs=p1-rs;
//マイナスをyに列挙してい
for(int i=0;;i++){
  if (mns.size()==0)break;
  m1=mns.back();
  mns.pop_back();
  cout<<rs<<" "<<m1<<endl;
  rs=rs-m1;
}



return 0;
}

Measured memory_bytes: 3572
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()
    ans = 0
    for i in a:
        ans += i-1
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a>b)cout << "a > b" <<endl;
    if(a<b)cout << "a < b" <<endl;
    if(a==b)cout << "a == b" <<endl;;
}


Measured memory_bytes: 3100
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a == b && b == c){
		    out.println("No");
		}else if(a != b && b != c && c != a){
		    out.println("No");
		}else{
		    out.println("Yes");
		}
        out.close();
        
    }
}

Measured memory_bytes: 35784
#include <stdio.h>

int
main(void)
{
	char line[80];

	int l[10], v[2];

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", 
				   &(l[0]), &(l[1]), &(l[2]), &(l[3]), &(l[4]), &(l[5]),
				   &(l[6]), &(l[7]), &(l[8]), &(l[9]),
				   &(v[0]), &(v[1])) != 12) {
			break;
		}

		int total = 0;
		for (int k : l) {
			total += k;
		}
		
		double h = (double)(v[0]) / (v[0] + v[1]);
		
		double p = total * h;
		
		for (int i = 0; i < 10; i++) {
			p -= l[i];
			if (p <= 0) {
				printf("%d\n", i+1);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

const int INF = 1e9;

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

  IN(N); IN(K);

  vi H(N);
  REP(i, N)
    cin >> H[i];

  int dp[N]; // dp[i] = 足場iに至るまでの最小コスト
  REP(i, N)
    dp[i] = INF;
  dp[0] = 0;

  REP(i, N)
    FOR(k, 1, min(K+1, N - i))
      dp[i+k] = min(dp[i+k], dp[i] + abs(H[i] - H[i+k]));

  OUT(dp[N-1]);

  return 0;
}


Measured memory_bytes: 1024
A, B, C, D = gets.chomp.split.map(&:to_i)
lcm = C.lcm(D)

def count_multiple s, e, int
  e/int - (s-1)/int
end

puts ((B-A+1) - (count_multiple(A, B, C) + count_multiple(A, B, D) - count_multiple(A, B, lcm)))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num[3];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  string A;
  int a[1252521];
  cin>>n>>A;
  int one=0, two=0;
  REP(i, n){
    a[i]=A[i]-'1';
    ++num[a[i]];
    if(a[i]==1){
      one+=(n-1==(i|(n-1-i)));
    }
    if(a[i]==2){
      two+=(n-1==(i|(n-1-i)));
    }
  }
  // DEBUG(one);DEBUG(two);
  if(one&1){
    cout<<1<<'\n';
    return 0;
  }
  if(num[0] && num[1] && num[2]){
    cout<<0<<'\n';
    return 0;
  }
  cout<<(two&1 ? 2 : 0)<<'\n';
  return 0;
}


Measured memory_bytes: 1948
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: i64,
        xy: [(i64, i64); n],
    };

    let mut ans = 0;

    for (x, y) in xy {
        if x*x + y*y <= d*d {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 7796
#include <iostream>
#include <string>
#include <vector>
#include <map>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

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

	ullong x = n / (a + b);
	ullong mod = n % (a + b);

	ullong ret = x * a;
	if (mod > a)
		ret += a;
	else
		ret += mod;

	cout << ret;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemD solver = new ProblemD();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			int[][] sb = new int[2 * k + 1][2 * k + 1];
			int[][] sw = new int[2 * k + 1][2 * k + 1];
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				char c = in.next().charAt(0);
				x %= 2 * k;
				y %= 2 * k;
				++x;
				++y;
				if (c == 'B') {
					++sb[x][y];
				} else {
					++sw[x][y];
				}
			}

			for (int[][] s : new int[][][]{sb, sw}) {
				for (int i = 1; i <= 2 * k; i++) {
					for (int j = 1; j <= 2 * k; j++) {
						s[i][j] += s[i - 1][j];
						s[i][j] += s[i][j - 1];
						s[i][j] -= s[i - 1][j - 1];
					}
				}
			}

			int ans = 0;
			for (int di = 0; di < 2 * k; di++) {
				for (int dj = 0; dj < 2 * k; dj++) {
					int cur = 0;
					for (int bigI = -2; bigI <= 2; bigI++) {
						for (int bigJ = -2; bigJ <= 2; bigJ++) {
							int i1 = bigI * k + di + 1;
							int i2 = i1 + k - 1;
							int j1 = bigJ * k + dj + 1;
							int j2 = j1 + k - 1;
							int[][] s;
							if ((bigI + bigJ) % 2 == 0) {
								s = sb;
							} else {
								s = sw;
							}
							if (i1 > 2 * k) {
								continue;
							}
							i1 = Math.max(i1, 1);
							if (i2 < 1) {
								continue;
							}
							i2 = Math.min(i2, 2 * k);
							if (j1 > 2 * k) {
								continue;
							}
							j1 = Math.max(j1, 1);
							if (j2 < 1) {
								continue;
							}
							j2 = Math.min(j2, 2 * k);
							if (i1 <= i2 && j1 <= j2) {
								--i1;
								--j1;
								cur += s[i2][j2];
								cur -= s[i2][j1];
								cur -= s[i1][j2];
								cur += s[i1][j1];
							}
						}
					}
					ans = Math.max(ans, cur);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



Measured memory_bytes: 97584