akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a, b;
	cin >> a >> b;
	int ans = -1;
	for(int i = 1; i < 2000; i++) {
		if(i * 8 / 100 == a && i * 10 / 100 == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


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

int main(void){
    string S;
    cin >> S;
    int N = S.length();
    int ans = 0;
    for(int i=0;i+1<N;i++){
        if(S[i] == S[i+1]){
            ans++;
            if(S[i+1] == '0'){
                S[i+1] = '1';
            }
            else{
                S[i+1] = '0'; 
            }
        }
    }
    cout << ans << endl;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  int maxi = 0;
  int g = 0;
  REP(i,N) {
    int a;
    scanf("%d", &a);
    maxi = max(maxi, a);
    g = gcd(g, a);
  }
  if (K > maxi || K % g) {
    printf("IMPOSSIBLE\n");
  } else {
    printf("POSSIBLE\n");
  }
}


Measured memory_bytes: 256
MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0] * (S + 1)]
dp[0][0] = 1
for i in range(N):
    dp.append([d * 2 % MOD for d in dp[-1]])
    for k in range(A[i], S + 1):
        dp[-1][k] += dp[-2][k - A[i]]

print(dp[-1][-1] % MOD)

Measured memory_bytes: 146664
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, K = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np

x = np.argsort(list(map(lambda x: -abs(x), A)))
B = []
C = []

for xx in x:
    B.append(A[xx])
    C.append(np.sign(A[xx]))

ans = 1
s = 1
flag4 = 0

for i in range(K):
    s *= C[i]

if s < 0:
    p = np.sign(B[K-1])
    flag1 = 0
    for i in range(K-1,-1,-1):
        if C[i] == p*(-1):
            idx1 = i
            flag1 = 1
            break

    flag2 = 0
    for i in range(K,N):
        if C[i] == p*(-1):
            idx2 = i
            flag2 = 1
            break

    flag3 = 0
    if flag1 == 1:
        for i in range(K,N):
            if C[i] == p:
                idx3 = i
                flag3 = 1
                break

    if flag1 and flag2 and flag3:
        if abs(B[K-1])*abs(B[idx3]) <= abs(B[idx1])*abs(B[idx2]):
            B[K-1] = B[idx2]
        else:
            B[idx1] = B[idx3]
    elif flag1 and (not flag2) and flag3:
        B[idx1] = B[idx3]
    elif flag1 and flag2 and (not flag3):
        B[K-1] = B[idx2]
    elif (not flag1) and flag2:
        B[K-1] = B[idx2]
    else:
        flag4 = 1

if flag4:
    for i in range(N-1,N-K-1,-1):
        ans = (ans * (B[i] % mod)) % mod
else:
    for i in range(K):
        ans = (ans * (B[i] % mod)) % mod

print(ans % mod)























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

char st[100010];

int main() {
	scanf("%s", st);
	int l = strlen(st);
	if (st[0] == st[l-1]) {
		if (l % 2 == 1) {
			puts("Second");
		} else {
			puts("First");
		}
	} else {
		if (l % 2 == 1) {
			puts("First");
		} else {
			puts("Second");
		}
	}
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

struct myComp {
    bool operator() (const pair<int, int>& lhs, const pair<int, int>& rhs) const
    { 
        return ((LL) lhs.first * (rhs.second+1) < (LL) rhs.first * (lhs.second+1)); 
    }
};


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

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int maxA = 0;
    rep(i, N) {
        cin >> A[i];
        maxA = max(maxA, A[i]);
    }
    sort(A.begin(), A.end(), greater<int>());

    int l = 0; //! NG
    int r = maxA; // !OK
    while (l+1 < r) {
        int m = (l+r)/2;
        int cnt = 0;
        rep(i, N) {
            if (K < cnt) break;
            cnt += (A[i]-1) / m;
        }
        if (cnt <= K) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 3896
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
int m,x,t;

template<typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(m); read(x); read(t);
    if(m % x == 0) printf("%d\n",m / x * t);
    else printf("%d\n",(m / x + 1) * t);
    return 0;
}
/*

*/

Measured memory_bytes: 1596
MOD = 10 ** 9 + 7

n, k = $stdin.readline.chomp.split.map(&:to_i)
inv = Array.new(n + 1, 0)
inv[0] = 1
fact = Array.new(n + 1, 0)
fact[0] = 1
fact_inv = Array.new(n + 1, 0)
fact_inv[0] = 1

n.times do |i|
  if i == 0
    inv[i + 1] = 1
  else
    inv[i + 1] = (- inv[MOD % (i + 1)] * (MOD / (i + 1))) % MOD
  end
end

1.step(n) do |i|
  fact[i] = (fact[i - 1] * i) % MOD
  fact_inv[i] = (fact_inv[i - 1] * inv[i]) % MOD
end

1.step(k) do |i|
  if n - k + 1 < i
    res = 0
  else
    res = (fact[n - k + 1] * fact_inv[n - k + 1 - i] * fact_inv[i]) % MOD
    res = (res * fact[k - 1] * fact_inv[k - i] * fact_inv[i - 1]) % MOD
  end
  puts res
end

Measured memory_bytes: 14220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(k, n)*x + max(0, (n-k))*y;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csgraph
H, W = map(int, input().split())
maze = "".join(input() for _ in range(H))
array = np.zeros((H * W, H * W), dtype=np.bool)
for n in range(H * W):
    if maze[n] == "#":
        continue
    r, c = divmod(n, W)
    if c and maze[n - 1] == ".":
        array[n][n - 1] = 1
        array[n - 1][n] = 1
    if r and maze[n - W] == ".":
        array[n][n - W] = 1
        array[n - W][n] = 1
dist = csgraph.shortest_path(array)
print(int(dist[dist < 401].max()))


Measured memory_bytes: 20284
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    static ArrayList<Integer>[] graph;
    public static void solve() {
        int n = in.nextInt();
        graph = new ArrayList[n+1];

        for(int i = 1; i <= n; i += 1)
            graph[i] = new ArrayList<>();

        int m = in.nextInt();

        for(int i = 1; i <= m; i += 1) {
            graph[in.nextInt()].add(in.nextInt());
        }

        Integer[] store = new Integer[n+1]; // length of longest path from vertex i;

        int result = 0;
        for(int i = 1; i <= n; i += 1) {
            result = Math.max(result, longestPath(i, store));
        }

        out.println(result);

    }

    private static int longestPath(int v, Integer[] store) {
        if(store[v] != null)
            return store[v];

        int length = -1;
        for(int n: graph[v]) {
            length = Math.max(length, longestPath(n, store));
        }

        store[v] = length+1;
        return store[v];
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

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

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

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

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

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 60120
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		string S = GetString();

		int ans = 0;
		for(int shift = 1; shift < N; shift++)
		{
			int len = N - shift;
			bool[] match = new bool[len];
			for(int i = 0; i < len; i++)
				match[i] = (S[i] == S[shift + i]);
			
			int cnt = 0;
			for(int i = 0; i < len; i++)
			{
				if(match[i])
				{
					cnt++;
					if(cnt > shift)
						cnt = shift;
				}
				else
				{
					cnt = 0;
				}
				
				chmax(ref ans, cnt);
			}
		}

		Console.WriteLine(ans);
	}

	private void chmax(ref int x, int y) => x = Math.Max(x, y);
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    if(N%2==0){
        double ans=N;
        cout << (double)((ans/2)/ans) << endl;
    }
    else{
        int ans=N/2+1;
        double ans_2=ans;
        cout << (double)((ans_2)/N) << endl;
    }
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, tok = 0;
    cin >> n;
    
    vector<pii> v(n);
    for (auto &x : v) cin >> x.X, x.Y = tok++;
    sort(ALL(v));
    
    int small = v[n/2 - 1].X, large = v[n/2].X;
    vector<int> ans(n);
    for (auto x : v) {
        if (x.X <= small) ans[x.Y] = large;
        if (x.X >= large) ans[x.Y] = small;
    }
    
    for (auto x : ans) cout << x << "\n";
    
    return 0;
}

Measured memory_bytes: 6912
def getval():
    n = int(input())
    a = list(map(int,input().split()))
    return n,a

def main(n,a):
    init = sum(a)
    dp = [init,init-2*a[0]-2*a[1]]
    #print(dp)
    for i in range(1,n-1):
        prev1 = dp[0]
        prev2 = dp[1]
        dp[0] = max(prev1,prev2)
        dp[1] = max(prev2+2*a[i]-2*a[i+1],prev1-2*a[i]-2*a[i+1])
        #print(dp)
    print(max(dp))

if __name__=="__main__":
    n,a = getval()
    main(n,a)

Measured memory_bytes: 85432
hp, n = map(int,input().split())

list = [[0] * 2 for i in range(n)]
for i in range(n):
    list[i][0], list[i][1] = map(int,input().split())

dp = [[10000000000] * (hp+1) for i in range(n+1)]

dp[0][0] = 0
for i, lista in enumerate(dp):
    dp[i][0] = 0
    for j, value in enumerate(lista):
        if i == 0:
            continue
        if j < list[i-1][0]:
            dp[i][j] = min(list[i-1][1], dp[i-1][j])
        else:
            target = j - list[i-1][0]
            dp[i][j] = min((dp[i][target] + list[i-1][1]), dp[i-1][j])

print(int(dp[n][hp]))




Measured memory_bytes: 120300
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

ll k=1;
int n;
int main() {
	cin>>n;
	int a[11],ma=0,t=0;
	rep(i,0,n){
		cin>>a[i];
		ma=max(ma,a[i]);
		t+=a[i];
	}
	cout<<t-ma/2<<endl;
}


Measured memory_bytes: 256
//#line 2 "SubstringQueries.cpp"

#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int H, W;
vector<string>B;
bool flag[123][123];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		string s;
		cin >> s;
		B.push_back(s);
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (i % 2 && j % 2) {
			}
			else if (i % 2 == 0 && j % 2 == 0) {
				if ((i + j) % 4 == 0 && B[i][j] != '6') {
					B[i][j] = '#';
				}
				if ((i + j) % 4 == 2 && B[i][j] != '1') {
					B[i][j] = '#';
				}
			}
			else if (i % 2) {
				if (i % 4 == 1 && B[i][j] != '2') {
					B[i][j] = '#';
				}
				if (i % 4 == 3 && B[i][j] != '5') {
					B[i][j] = '#';
				}
			}
			else if (j % 2) {
				if (j % 4 == 1 && B[i][j] != '3') {
					B[i][j] = '#';
				}
				if (j % 4 == 3 && B[i][j] != '4') {
					B[i][j] = '#';
				}
			}
		}
	}
	queue<pair<int, int>>que;
	que.push({ 0,0 });
	flag[0][0] = true;
	int dx[4] = { 0,1,0,-1 };
	int dy[4] = { 1,0,-1,0 };
	while (!que.empty()) {
		int i = que.front().first;
		int j = que.front().second;
		que.pop();
		for (int d = 0; d < 4; ++d) {
			int ii = i + dx[d];
			int jj = j + dy[d];
			if (ii < 0 || jj < 0 || ii >= H || jj >= W)continue;
			if (B[ii][jj] != '#' && !flag[ii][jj]) {
				que.push({ ii,jj });
				flag[ii][jj] = true;
			}
		}
	}
	cout << (flag[H - 1][W - 1] ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 3252
a, b, c = map(int, input().split())
s=int(a*7+b)
t=c//(7*a+b)
r=t*s
m=c-r

if (7*a)<(c-r)<s:
    print((t+1)*7)
else:
    coin=0
    day=0
    while coin<(c-r):
        coin+=a
        day+=1
    print(t*7+day)



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

int main() {
  int N,A;
  cin >> N ;
  int j=0 , k=31 ;
  
  for (int i=0;i<N;i++)
  {
    cin >> A ;
    while ( A%2==0 )
    {
      A/=2;
      j++;
    }
    if (j<k) k=j;
    j=0;
  }
  cout << k << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 200005
int Col[M],dp[M],last[M];
const int P=1e9+7;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&Col[i]);
	int len=1;Col[len]=Col[1];
	for(int i=2;i<=n;i++)
		if(Col[i]!=Col[i-1])
			Col[++len]=Col[i];
	dp[0]=1;
	for(int i=1;i<=len;i++){
		dp[i]=dp[i-1];
		if(last[Col[i]])dp[i]+=dp[last[Col[i]]],dp[i]%=P;
		last[Col[i]]=i;
	}
	cout<<dp[len];
	return 0;
}

Measured memory_bytes: 2560
main = do
    r <- readLn -- 入力が一行に一文字の場合
    -- [a, b] <- map read . words <$> getLine -- 一行に入力が複数ある場合
    -- putStrLn $ show $ solve a b -- showの返り値がString型の場合
    -- putStrLn $ solve a b

    putStrLn $ show $ solve r -- showの返り値がString型の場合

solve :: Int -> Int
solve r = 3 * r ^ 2


{-- その他 備忘録
    {{{ 型変換
       int 2 float: fromIntegral
       float 2 int: round
       int 2 string: show
    }}}
--}


Measured memory_bytes: 508
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	ll i,j,k,n,r,t;
	ld ans=0;
	cin>>n>>k;
	for (i=1;i<=n;i++){
		t=i;
		r=0;
		while (t<k){
			t*=2;
			r++;
		}
		ans+=(ld)1/n*pow(0.5,r);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <tuple<int,string,int>> data(n);
    for(int i=0;i<n;i++){
        string s; cin>>s;
        int p; cin>>p;
        data[i] = make_tuple(p,s,i+1);
    }
    //sort(data.begin(),data.end());
    //reverse(data.begin(),data.end());
    vector <tuple<string,int,int>> data2(n);
    for(int i=0;i<n;i++){
        data2[i] = make_tuple(get<1>(data[i]),get<0>(data[i]),get<2>(data[i]) );
    }
    sort(data2.begin(),data2.end());
    //priority_queue <pair<int,int>> q;
    int x =0;
    for(int i=0;i<n;i++){
       // cout<<get<0>(data2[i])<<' '<<get<2>(data2[i])<<endl;
        if(i==n-1){
            for(int j=i;j>=x;j--){
            cout<< get<2>(data2[j])<<endl;
         }
         x=i+1;
        }
        else if(get<0>(data2[i])!=get<0>(data2[i+1])){
            for(int j=i;j>=x;j--){
            cout<< get<2>(data2[j])<<endl;
         }
         x=i+1;
        }
        
    
    }
        
   
    
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=3e5+9;
const ll maxx=1e12+9;

int n,m,q;
int r[maxn],c[maxn];
map<P,int> mp;

int find_max(int ar[],int len)
{
    int res=0;
    for(int i=1;i<=len;i++) res=max(res,ar[i]);
    return res;
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    while(q--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        r[x]++; c[y]++;
        mp[P(x,y)]++;
    }
    int ma;
    vector<int> rr,cc;
    int mr=find_max(r,n);
    for(int i=1;i<=n;i++) if(r[i]==mr) rr.push_back(i);
    int mc=find_max(c,m);
    for(int i=1;i<=m;i++) if(c[i]==mc) cc.push_back(i);
    int ans=mr+mc-1,flag=0;
    for(int i=0;i<rr.size()&&!flag;i++)
        for(int j=0;j<cc.size()&&!flag;j++)
            if(!mp[P(rr[i],cc[j])]) flag=1;
    printf("%d\n",ans+flag);
}


Measured memory_bytes: 23324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
int p[200005];
int main()
{
	int n , k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> p[i];
		p[i]++;
	}
	int maxTotal = 0 , total = 0;
	for(int i = 0; i < k - 1; i++)
	{
		total += p[i];
	}
	for(int i = k - 1; i < n; i++)
	{
		total += p[i];
		maxTotal = max(maxTotal , total);
		total -= p[i - k + 1];
	}
	cout << fixed << setprecision(10) << maxTotal / 2.;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	ll a, b, ans;
	cin >> a >> b;
	if(b <= 1){
		cout << 0 << endl;
		return;
	}
	ans = (b - 2) / (a - 1) + 1;
	cout << ans << endl; 


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3580
<?php
// C2 解説の方法でAC
fscanf(STDIN, '%d %d', $D, $G);
for ($i = 0; $i < $D; $i++) {
    fscanf(STDIN, '%d %d', $p[], $c[]);
}
$ans = PHP_INT_MAX;
for ($i = 0; $i < (1 << $D); $i++) {
    $score = 0;
    $num = 0;
    $rest_max = -1;
    for ($j = 0; $j < $D; $j++) {
        if ($i >> $j & 1) {
            $score += 100 * ($j + 1) * $p[$j] + $c[$j];
            $num += $p[$j];
        } else {
            $rest_max = $j;
        }
    }
    if ($score < $G) {
        $need = (int) ceil(($G - $score) / (100 * ($rest_max + 1)));
        if ($need >= $p[$rest_max]) continue;
        $num += $need;
    }
    $ans = min($ans, $num);
}
echo $ans;

Measured memory_bytes: 4604
// 2014/11/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	int A[1000];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	int B[1000];
	for(int i=0; i<M; i++){
		cin >> B[i];
	}

	int cnt[1000] = {0};
	for(int i=0; i<M; i++){
		for(int j=0; j<N; j++){
			if(B[i]>=A[j]){
				cnt[j]++;
				break;
			}
		}
	}

	int i_max = 0;
	for(int i=1; i<N; i++){
		if(cnt[i]>cnt[i_max]){
			i_max = i;
		}
	}

	cout << i_max+1 << endl;

	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b;
  cin >> a >> b;
  if(a*b%2==0){
    print("No");
  }
  else{
    print("Yes");
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=998244353;
const long long int INF=99999999999999999;

long long int n,m,sum,res=9999999999999999;
long double a,b,x,y;

int main() {
	cout << fixed << setprecision(10);
    cin>>a>>b>>x;
    if(a*a*b/2<=x){
        y=2.0*((a*a*b-x)/(a*a));
        cout<<atan(y/a)*180/3.14159265358979;
    }else{
        y=2*x/(a*b);
        cout<<atan(b/y)*180/3.14159265358979;
    }
    
} 


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
		long N = s.nextLong();
		String Ans = "";
		while(N != 0){
			N = N-1;
			long mod = N%26;
			int mod2 = (int)mod;
			char a = (char)('a'+mod2);
			Ans = String.valueOf(a) + Ans;
			N = N/26;
		}
		System.out.println(Ans);
		
		
			
	}
} 

Measured memory_bytes: 39256
import copy
from collections import Counter
n = int(input())
S = [input() for i in range(n)]
c1 = Counter(S[0])
for i in range(n):
    c2 = Counter(S[i])
    common_keys = c1.keys() & c2.keys()
    c3 = {}
    for key in common_keys:
        c3[key] = min(c1[key], c2[key])
    c1 = copy.deepcopy(c3)

ans = ""
for key, val in sorted(c1.items(), key=lambda x:x[0]):
    ans = ans + key * val
print(ans)

Measured memory_bytes: 3444
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

X = int(sys.stdin.readline())
a = 100.0
n = 0
while X > a:
    a *= 1.01
    a = math.floor(a)
    n += 1
print(n)


Measured memory_bytes: 9160
#include<stdio.h>
#include<stdlib.h>

struct node{
  
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;

};

typedef struct node * Node;

Node root, NIL;
int maxh;


void insert(int);
void inorder(Node );
void preorder(Node );
Node treeSearch(Node , int);


int main(){

  int n, i, x;
  char com[20];

  scanf("%d", &n);

  maxh = 0;

  for ( i = 0; i < n; i++ ){
    
    scanf("%s", com);

    if ( com[0] == 'f' ){

      scanf("%d", &x);

      Node t = treeSearch(root, x);

      if ( t != NIL ) printf("yes\n");

      else printf("no\n");
    }


    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }
  /*
  for ( i = 0; i < n; i++ ){

    scanf("%s", com);

    if ( strcmp(com, "insert") == 0 ){

      scanf("%d", &x);

      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){

      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");

    }
  }*/

  return 0;
}

void insert(int k){
  
  int H;
  Node y;
  Node x;
  Node z;

  y = NIL; // x ??????
  x = root; // T??????

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    
    y = x; // ???????¨????

    if ( z->key < x->key ){

      x = x->left; // ?????????????§????
    }
    else {

      x = x->right; // ?????????????§????

    }
  }

  z->parent = y;

  if ( y == NIL ){ // T ???????????´???

    root = z;

  }
  
  else {
    if (z->key < y->key) {

      y->left = z; // z ??? y ?????????????????????
    }
    else {

      y->right = z;// z ??? y ?????????????????????

    }
  }
}

void inorder(Node u){
  
  if ( u == NIL ) return;

  inorder(u->left);

  printf(" %d", u->key);

  inorder(u->right);

}
void preorder(Node u){

  if ( u == NIL ) return;

  printf(" %d", u->key);

  preorder(u->left);
  preorder(u->right);

}



Node treeSearch(Node u, int k){
  
  while( u != NIL && k != u->key ){
    
    if ( k < u->key ) u = u->left;

    else u = u->right;

  }

  return u;
}

Measured memory_bytes: 19364
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, k;

	cin >> n >> k;

	cout << n - k + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
    int n;
    cin >> n;
    string f[2];
    cin >> f[0] >> f[1];

    lli dp[53][3][3];
    memset(dp, 0, sizeof(dp));
    REP(i, 3) REP(j, 3){
        if((f[0][0]==f[1][0]) == (i==j)){
            dp[0][i][j] = 1;
        }
    }
    for(int i=1; i<n; i++){
        REP(j,3) REP(k,3) REP(s,3) REP(t,3){
            if((f[0][i]==f[1][i]) != (s==t)) continue;
            if((f[0][i-1]==f[0][i]) != (j==s)) continue;
            if((f[1][i-1]==f[1][i]) != (k==t)) continue;
            dp[i][s][t] += dp[i-1][j][k];
            dp[i][s][t] %= mod;
        }
    }
    lli ans = 0;
    REP(i,3) REP(j,3){
        ans += dp[n-1][i][j];
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    ll n,i,j,s=0,k;
    cin>>n;
    ll a[n+1];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(i!=j&&i!=k&&j!=k)
                {
                    if(((a[i]+a[j])>a[k])&&((a[i]+a[k])>a[j])&&(a[i]<(a[j]+a[k])))
                    {
                        if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
                        {
                            s++;
                            //cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                        }

                    }
                }
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll ans=0;
  ll now=1;
  for(ll i=0;i<n;i++){
    ll a;cin>>a;
    if(i==0){
      ans+=a-1;
      now++;
      continue;
    }
    if(a==now){
      now++;
      continue;
    }
    if(a%now==0){
      ans+=a/now-1;
    }
    else{
      ans+=a/now;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	int sum=0;
	rep(i,100000){
		sum+=a;
		if(sum%b==c){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
import math
def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list
n=int(input())
l=get_div_list(n)
ans=10**15
for i in range(len(l)):
    if l[i] < n//l[i]:break;
    ans=min(abs(l[i]-1)+abs(n//l[i] -1),ans)
print(ans)


Measured memory_bytes: 3928
N, M, X = map(int, input().split(' '))
price, exp = [], [ [] for i in range(N) ]
rst = -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Measured memory_bytes: 9032
#!/usr/bin/env python3
import sys


def solve(M: "List[int]", D: "List[int]"):
    print(int(M[0]!=M[1]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = [int()] * (2)  # type: "List[int]"
    D = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        M[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(M, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int check(long long int *,int);
int main()
{
int n,t=0;
scanf("%d",&n);
long long a[n];
for(int i=0;i<n;i++)
{
scanf("%lld",&a[i]);
//printf ("          %lld\n",a[i]);
}
while (check(&a[0],n)==1)
{
t++;
//printf ("\n%d",t);
}
printf ("%d",t);
}

int check(long long int* a,int n)
{
int t=0;
for (int i=0;i<n;i++)
{
//printf ("\n%lld",*(a+i));
if ((*(a+i))%2!=0)
{t=1;break;}
}
if (t==1)
return (0);
else 
{
for (int i=0;i<n;i++)
{
a[i]=a[i]/2;
}
return (1);
}
}

Measured memory_bytes: 128
n = int(input())
a = [int(x) for x in input().split()]
if 0 in a: print(0)
else:
    m = 1
    flag = 0
    for i in a:
        m *= i
        if m > 1e+18:
            print(-1)
            flag = 1
            break
    if flag == 0: print(m)

Measured memory_bytes: 21644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int result = 0;
        for(int i = 0; i < a.length(); i++) {
            if(a.charAt(i) == '1') {
                result++;
            }
        }
        System.out.println(result);
    }
}


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

int main()
{
    int A[3];
    std::cin >> A[0] >> A[1] >> A[2];
    int sum = A[0] + A[1] + A[2];
    std::string ans = sum >= 22 ? "bust" : "win";
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

bool c(int mid, vi& h, int a, int b) {
	int cnt = 0;
	for (const auto& i : h) {
		int tmp = i;
		tmp -= b * mid;
		if (tmp < 0) continue;
		cnt += (tmp / (a - b)) + ((tmp % (a - b)) != 0);
	}
	return cnt <= mid;
}

int execute(int low, int high, vi& h, int a, int b) {
	for(int i = 0; i < 50; i++) {
		int mid = (high + low) / 2;
		(c(mid, h, a, b) ? high : low) = mid;
	}
	return high;
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	vi h(n);
	rep (i, n) cin >> h[i];
	cout << execute(0, 1e9, h, a, b) << endl;
	return 0;
}

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

int main(){
  int N;  cin >> N;
  vector<long long>A(N);
  long long X = 0;

  for(int i=0;i<N;i++){
    cin >> A.at(i);
    A.at(i) = A.at(i) % 1000000007;
    X += A.at(i);
    X = X % 1000000007;
  }
  long long sum = 0;
  for(int i=0;i<N;i++){
    X -= A.at(i);
    if(X < 0) X += 1000000007;
    sum += A.at(i)*X;
    sum = sum % 1000000007;
  }
  cout << sum << endl;
}


Measured memory_bytes: 4816
#include <stdio.h>
int main(void){
    int n,i;
    int fib[100]={1,1};
    
    scanf("%d",&n);
     
    for(i=2;i<=n;i++){
        fib[i]=fib[i-1]+fib[i-2];
         
    }
    printf("%d\n",fib[n]);
     
    return 0;
}





Measured memory_bytes: 2104
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

const ll MOD=1e9+7;

#include <bits/stdc++.h>
using namespace std;

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x %MOD;
    x=x*x %MOD;
    n/=2;
  }
  return ans;
}
int main(){
  ll n;
  cin>>n;
  
  cout<<((modpow(10,n)-2*modpow(9,n)%MOD+MOD)%MOD+modpow(8,n))%MOD<<endl;
  
  return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

long long dp[5][3100][3100];

void solve(long long R, long long C, long long K, std::vector<long long> r_,
           std::vector<long long> c_, std::vector<long long> v) {
    vector<vector<long long> > sc(R, vector<long long>(C));
    rep(i, K) {
        c_[i]--;
        r_[i]--;
        sc[r_[i]][c_[i]] = v[i];
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 0;
    dp[1][0][0] = max(0LL, sc[0][0]);
    rep(r, R) rep(c, C) rep(k, 4) {
        if (c + 1 < C) {
            dp[k][r][c + 1] = max(dp[k][r][c + 1], dp[k][r][c]);
            if (k < 3) {
                dp[k + 1][r][c + 1] =
                    max(dp[k + 1][r][c + 1], dp[k][r][c] + sc[r][c + 1]);
            }
        }
        if (r + 1 < R) {
            dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[k][r][c]);
            dp[1][r + 1][c] = max(dp[1][r + 1][c], dp[k][r][c] + sc[r + 1][c]);
        }
    }

    long long ans = 0;
    rep(k, 4) { ans = max(ans, dp[k][R - 1][C - 1]); }
    cout << ans << endl;
}

int main() {
    long long R;
    scanf("%lld", &R);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> r(K);
    std::vector<long long> c(K);
    std::vector<long long> v(K);
    for (int i = 0; i < K; i++) {
        scanf("%lld", &r[i]);
        scanf("%lld", &c[i]);
        scanf("%lld", &v[i]);
    }
    solve(R, C, K, std::move(r), std::move(c), std::move(v));
    return 0;
}


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

const int C = 1e5 + 1;

vector<vector<int>> frend_g(C);
vector<vector<int>> block_g(C);
vector<int> parent(C, -1);

int root(int num)
{
    return parent[num] == -1 ? num : parent[num] = root(parent[num]);
}

void merge(int a, int b) {
    int p1 = root(a);
    int p2 = root(b);
    if (p1 == p2) return;
    if (p1 > p2) parent[p1] = p2;
    else parent[p2] = p1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(10);
    
    int N, M, K;
    cin >> N >> M >> K;
    
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        frend_g[a].push_back(b);
        frend_g[b].push_back(a);
        merge(a, b);    
    }
    for (int i = 0; i < K; ++i) {
        int c, d; cin >> c >> d;
        block_g[c].push_back(d);
        block_g[d].push_back(c);
    }
    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        int p1 = root(i);
        cnt[p1]++;
    }
    for (int i = 1; i <= N; ++i) {
        int p1 = root(i);
        int ans = cnt[p1] - frend_g[i].size() - 1;
        for (int b : block_g[i]) {
            int p2 = root(b);
            if (p1 == p2) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

using cpx = complex<double>;

double dist(cpx a, cpx b) {
    return abs(a - b);
}

pair<int, pair<cpx, cpx>> intersect(cpx a, cpx b, double s, double t) {
    pair<cpx, cpx> res = {{0, 0}, {0, 0}};
    if (abs(a - b) > s + t - 1e-8) {
        return {0, res};
    }
    if (abs(abs(a - b) - s - t) < 1e-8) {
        res.first = (a * s + b * t) / (s + t);
        return {1, res};
    }
    double d = abs(b - a);
    cpx x = (b - a) * (d * d + s * s - t * t) / (d * d * 2.0);
    cpx y = (b - a) * sqrt(max(s * s - abs(x) * abs(x), 0.0)) / d;
    y *= (cpx){0, -1};
    res.first = a + x + y;
    res.second = a + x - y;
    return {2, res};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<double> x(n), y(n), c(n);
    vector<cpx> z(n);
    rep(i, 0, n) {
        cin >> x[i] >> y[i] >> c[i];
        z[i] = {x[i], y[i]};
    }
    double l = 0, r = 1e7;
    while (r - l > 1e-8) {
        double t = (l + r) / 2;
        vector<double> d(n);
        rep(i, 0, n) d[i] = t / c[i];
        vector<cpx> p = z;
        rep(i, 0, n) rep(j, i + 1, n) {
            pair<int, pair<cpx, cpx>> q = intersect(z[i], z[j], d[i], d[j]);
            if (q.first >= 1) p.emplace_back(q.second.first);
            if (q.first == 2) p.emplace_back(q.second.second);
        }
        bool ok = false;
        for (cpx a : p) {
            int cnt = 0;
            rep(i, 0, n) {
                if (abs(z[i] - a) <= d[i] + 1e-8) cnt++;
            }
            if (cnt >= k) {
                ok = true;
                break;
            }
        }
        if (ok)
            r = t;
        else
            l = t;
    }
    debug(intersect({1, 1}, {3, 0}, 2, 3));
    cout << fixed << setprecision(10);
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint K = 100000;
	vector<lint>H(K);
	for(lint i=0;i<K;i++){
		H[i] = (i * i);
	}
	lint N;
	cin >> N;
	rep(i, K) {
		if (N < H[i]) {
			cout << H[i - 1] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,k;
  cin>>n>>m>>k;
  if(k%n==0 || k%m==0)
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  int flag=0;
  for(int i=1;i<=m;i++)
  {
    if((2*i)==m)continue;
    if((i*n)>k && ((i*n)-k)%((2*i)-m)==0 && (2*i)>m && ((i*n)-k)/((2*i)-m)<=n )
    {
      cout<<"Yes"<<endl;
      flag=1;
      break;
    }
    if((i*n)<k && (k-(i*n))%(m-(2*i))==0 && (2*i)<m && (k-(i*n))/(m-(2*i))<=n)
    {
      cout<<"Yes"<<endl;
      flag=1;
      break;
    }   
  }
  if(!flag)cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int n;
 
void compute(int depth,double x1,double y1,double x2,double y2){
  double si60 = sqrt(3.0)/2.0;
  double co60 = 0.5;
   
  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;
   
  double vx = tx-sx;
  double vy = ty-sy;
   
  double ux = sx + co60*vx - si60*vy;
  double uy = sy + si60*vx + co60*vy;
   
  if(depth>=n)return;
   
  compute(depth+1,x1,y1,sx,sy);
  printf("%.8f %.8f\n",sx,sy); 
  compute(depth+1,sx,sy,ux,uy);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty);
  printf("%.8f %.8f\n",tx,ty);   
  compute(depth+1,tx,ty,x2,y2);
 
   
}
 
int main(){
  cin>>n;
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}



Measured memory_bytes: 3232
#include<iostream>

using namespace std;

int main()
{
	char s[]="012345678954321012345678";
	int len=24;

	int n;	cin>>n;
	while(n--){
		int start,goal;	cin>>start>>goal;
		int ans=100,ans_st;
		for(int i=0;i<len;i++){
			if(s[i]!=start+'0')	continue;
			for(int j=i+1;j<len;j++){
				if(s[j]==goal+'0'){
					if(ans>j-i)	ans=j-i,ans_st=i;
				}
			}
		}
		for(int i=ans_st;;i++){
			cout<<(i==ans_st?"":" ")<<s[i];
			if(s[i]==goal+'0')	break;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0