akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n;
	cin >> n;
	map<string, int> s;
	for (int i = 0; i < n; i++) {
		string s_in;
		cin >> s_in;
		if (s.count(s_in)) {
			s.at(s_in) += 1;
		} else {
			s[s_in] = 1;
		}
	}

	int cnt = 0;
	for (auto s_ele : s) {
		int num = s_ele.second;
		cnt = max(cnt, num);
	}

	vector<string> ans;
	for (auto s_ele : s) {
		int num = s_ele.second;
		if (num == cnt) {
			ans.push_back(s_ele.first);
		}
	}

	sort(ans.begin(), ans.end());
	for (auto ans_ele : ans) {
		cout << ans_ele << endl;
	}
}


Measured memory_bytes: 26868
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nmk = IO.RSLong;
            var a = IO.RSLong;
            var b = IO.RSLong;

            var cum_a = new long[a.Length + 1];
            for (int i = 0; i < a.Length; i++)
            {
                cum_a[i + 1] = cum_a[i] + a[i];
            }
            var cum_b = new long[b.Length + 1];
            for (int i = 0; i < b.Length; i++)
            {
                cum_b[i + 1] = cum_b[i] + b[i];
            }


            int cum_b_idx = cum_b.Length - 1;
            long ans = 0;
            for (int i = 0; i < cum_a.Length; i++)
            {
                long rem = nmk[2];
                rem -= cum_a[i];
                if (rem < 0) continue;
                long cnt = i;

                while (true)
                {
                    if (cum_b[cum_b_idx] <= rem)
                    {
                        cnt += cum_b_idx;
                        break;
                    }
                    cum_b_idx--;
                }

                ans = Max(ans, cnt);
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

string s;

const int N = 1e6;
const int INF = 1e9;

int memo[N+5][15][3];

int dp(int id, int cur, int bro){
	if(id < 0) {
		if(cur - bro < 0) return 1;
		return 0;
	}
	int &ret = memo[id][cur][bro];
	if(ret!=-1) return ret;
	ret = INF;
	if(bro==1) cur--;
	int tmp = (cur-(s[id]-'0') + 10)%10;
	int stat = 0;
	if(cur-(s[id]-'0') < 0) stat = 1;
	for(int i=0;i<10;i++){
		ret = min(ret,dp(id-1,i,stat)+i);
	}
	ret += tmp;
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	cin >> s;
	int ans = INF;
	for(int i=0;i<10;i++){
		ans = min(ans,dp(s.size()-1,i,0)+i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 255364
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        String s = sc.next();
        String[] split;
        char[] split2;
      	char[] split3;
      	int check1[] = new int[26];
        int check2[] = new int[26];
      	int i,j,t;	
        int count = 0;
        int end = 0;
      	
      	for(i = 2; i <= n;i++){
          
          
          
          split  = s.split("",i);
              StringBuilder sb = new StringBuilder();
          	  for(j=0;j < i - 1; j++){
              sb.append(split[j]);
              }

          split[0] = sb.toString();
          split[1] = split[i -1];
          
          
          split2 = split[0].toCharArray();
          split3 = split[1].toCharArray();
          
          for(j = 0 ; j < 26; j ++){
            check1[j] = 0;
            check2[j] = 0;
          }

          for(j=0;j < split[0].length(); j++){
            for(t = 97; t <=122;t++){
              if((int)split2[j] == t){
                check1[t - 97] = 1;
              }else{
                if(check1[t - 97] != 1){
                check1[t - 97] = 0;
                }
              }
            }
          }
          
          for(j=0;j < split[1].length(); j++){
			 for(t = 97; t <=122;t++){
              if((int)split3[j] == t){
                check2[t - 97] = 1;
              }else{
                if(check2[t - 97] != 1){
                check2[t - 97] = 0;
                }
              }
            }
          } 
          count = 0;
          for(j = 0;j<26;j++){
              if(check1[j] == 1 && check2[j] == 1){
                count += 1;
              }       
          }
          
          if(end < count){
            end = count;
          }
        }
        System.out.println(end);
    }
} 

Measured memory_bytes: 40076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int H, W, K;
void msearch(vector<vector<bool>> &c, vector<vector<bool>> &v, int count, int &ans)
{
}
void func()
{
    cin >> H >> W >> K;
    vector<vector<bool>> c(H, vector<bool>(W, false)); //黒が1
    vector<vector<bool>> v(H, vector<bool>(W, false)); //黒が1

    int count = 0, ans = 0;
    rep(i, 0, H)
    {
        string tmpstr;
        cin >> tmpstr;
        rep(j, 0, W)
        {
            c[i][j] = (tmpstr[j] == '.') ? false : true;
        }
    }
    for (int bith = 0; bith < (1 << H); ++bith)
    {
        vector<vector<bool>> c1 = c;
        for (int i = 0; i < H; ++i)
        {
            if (bith & (1 << i))
            {
                rep(j, 0, W) { c1[i][j] = false; }
            }
        }
        for (int bitw = 0; bitw < (1 << W); ++bitw)
        {
            vector<vector<bool>> c2 = c1;
            count = 0;
            for (int i = 0; i < W; ++i)
            {
                if (bitw & (1 << i))
                {
                    rep(j, 0, H) c2[j][i] = false;
                }
            }
            rep(i, 0, H)
            {
                rep(j, 0, W)
                {
                    if (c2[i][j])
                        ++count;
                }
            }
            if (count == K)
                ++ans;
        }
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3640
use strict;
use warnings;

my ($N, $K) = glob(<>);

my $b = $K ** int(log($N) / log($K));
my $d = '';

while ($b) {
    $d .= int($N / $b);
    $N %= $b;
    $b = int($b / $K);
}

print length($d);

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

typedef long long ll;
const int len = 55;
int n, x, arr[len];
ll dp[len][len][len*len];

ll solve(int pos, int rem, int sum){
    if (rem < 0 || sum < 0) return 0;
    if (pos == n){
        if (rem == 0 && sum == 0) return 1;
        return 0;
    }
    //printf("%d %d %d\n", pos, rem, sum);
    if (dp[pos][rem][sum] != -1) return dp[pos][rem][sum];

    return dp[pos][rem][sum] = solve(pos+1, rem, sum)+solve(pos+1, rem-1, sum-arr[pos]);
}

int main(){
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    for (int pos = 0; pos < n; pos++)
        for (int rem = 0; rem <= n; rem++)
            for (int sum = 0; sum <= x*n; sum++)
                dp[pos][rem][sum] = -1;

    ll ans = 0;
    for (int rem = 1; rem <= n; rem++)
        ans += solve(0, rem, x*rem);

    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    #define int long long int
    int x;
    cin >> x;
    int result = (x / 11) * 2;
    if(x % 11 > 6){
        result += 2;
    }else if(x % 11 > 0){
        result += 1;
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  	int N, res=0;
  	cin >> N;
  	vector<int> A(N);
  	vector<int> B(N);
  	vector<int> C(N-1);
  
  	for(int i=0; i<N; i++){
    	cin >> A[i];
    }
  
  	for(int i=0; i<N; i++){
    	cin >> B[i];
    }
  
  	for(int i=0; i<N-1; i++){
    	cin >> C[i];
    }
  
  	for(int i = 0; i < N; i++){
    	res+=B[A[i]-1];
      	if(A[i]==A[i+1]-1 && i < N-1){
        	res+=C[A[i]-1];
        }
    }
  	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

vector<lli> fac(1e6 + 2, 1), invfac(1e6 + 2, 1);

lli power(lli x, lli y) {
    // log y complexity
    // return (x^y) % MOD
    lli ans = 1;
    x = x % MOD;
    while (y > 0) {
        if (y & 1) {
            ans *= x;
            ans %= MOD;
        }
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return ans;
}

lli inverseMod(lli a) {
    return power(a, MOD - 2);
}

lli nCr(lli n, lli r) {
    if (r > n) {
        return 0;
    }
    lli ans = fac[n];
    lli val = (invfac[n - r] * invfac[r]) % MOD;
    ans *= val;
    ans %= MOD;
    return ans;
}

void solve() {
    for (lli i = 1; i <= 1e6; i++) {
        fac[i] = (fac[i - 1] * i) % MOD;
        invfac[i] = inverseMod(fac[i]);
    }

    lli n, a, m;
    cin >> n >> m;

    lli ans = (nCr(m, n) * fac[n]) % MOD;
    ans *= ans;
    ans %= MOD;

    lli sub = 0;
    for (lli i = 1; i <= n; i++) {
        lli val = (nCr(n, i) * nCr(m, i)) % MOD;
        val *= fac[i];
        val %= MOD;
        lli p = (nCr(m - i, n - i) * fac[n - i]) % MOD;
        p *= p;
        p %= MOD;
        val *= p;
        val %= MOD;
        if (i % 2 == 0) {
            val = -val;
        }
        sub += val;
        sub += MOD;
        sub %= MOD;
    }

    ans = ans - sub;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> b(n, k - q);
    for(int i = 0; i < q; i++){
        cin >> a[i];
        b[a[i] - 1]++;
    }

    for(int i = 0; i < n; i++){
        if(b[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4024
#!/usr/bin/env python3
import sys
from collections import defaultdict
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def solve(N: int):
    factors = defaultdict(int)
    res = prime_factorize(N)
    for f in res:
        factors[f]+=1
    r=0
    for key in factors:
        for c in range(1,10**10):
            if factors[key] >= c:
                factors[key]-= c
                r+=1
            else:
                break
    print(r)
    return


# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
#include <stdio.h>
 
int main(void){
  int a,b,c,k;
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a >= k){
    printf("%d",k);
  } else if(a + b >= k){
    printf("%d",a);
  } else{
    printf("%d",a-(k-a-b));
  }
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

int main()
{
	int N;
	std::vector<long> A;
	std::vector<long> B;
	std::vector<long> sufficients;
	long insufficients = 0;
	long asum = 0, bsum = 0;
	int numchange = 0;

	std::cin >> N;
	A.reserve(N);
	B.reserve(N);
	sufficients.reserve(N);
	for (int i = 0; i < N; ++i) {
		long a;
		std::cin >> a;
		A.push_back(a);
		asum += a;
	}
	for (int i = 0; i < N; ++i) {
		long b;
		std::cin >> b;
		B.push_back(b);
		bsum += b;
	}

	if (asum < bsum) {
		std::cout << "-1\n";
		return 0;
	}

	for (int i = 0; i < N; ++i) {
		if (A[i] < B[i]) {
			insufficients += B[i] - A[i];
			++numchange;
		} else if (A[i] > B[i]) {
			sufficients.push_back(A[i] - B[i]);
		}
	}
	if (insufficients == 0) {
		std::cout << "0\n";
		return 0;
	}
	std::sort(sufficients.begin(), sufficients.end(), std::greater<long>());

	for (auto it = sufficients.begin(); insufficients > 0; ++it) {
		insufficients -= *it;
		++numchange;
	}

	std::cout << numchange << "\n";
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string S;

    cin >> S;

    string three = S.substr(2, 1);
    string four = S.substr(3, 1);

    string five = S.substr(4, 1);
    string six = S.substr(5, 1);

    string Answer = "No";

    if (three == four)
    {
        if (five == six)
        {
            Answer = "Yes";
        }
    }

    cout << Answer << endl;
}

Measured memory_bytes: 256
mod=1000000007
n,k=map(int, input().split())
lst=list(map(int, input().split()))
lst=sorted(lst)
p=1
if lst[-1]==0 and k%2!=0:
    print(0)
elif lst[-1]<0 and k%2!=0:
    for i in range(n-1,n-k-1,-1):
        #print(p)
        p=(p%mod*lst[i]%mod)%mod
    #print(p)
    print(p%mod)
else:
    j=n-1
    if k%2!=0:
        p*=lst[j]
        k-=1
        j-=1
    k=k//2
    i=0
    for x in range(k):
        if lst[i]*lst[i+1]>lst[j]*lst[j-1]:
            p=(p%mod*lst[i]%mod*lst[i+1]%mod)%mod
            i+=2
        else:
            p=(p%mod*lst[j]%mod*lst[j-1]%mod)%mod
            j-=2
    #print(p)
    print(p%mod)

Measured memory_bytes: 31788
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
		
		int N;
		long long int x,Z,W,a[2000];
		cin>>N>>Z>>W;
		for(int i=0;i<N;i++)cin>>a[i];
		x=(long long int)fmax(labs(a[N-2]-a[N-1]),labs(a[N-1]-W));
		cout<<x<<"\n";
		return 0;
}

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

long modpow(long a, long n, int mod){
  long res = 1;
  while (n > 0){
    if (n & 1){
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  long N, b, c;
  cin >> N >> b >> c;
  
  long mod = 1000000007;
  
  long A = modpow(2, N, mod);
  
  long Bch = 1;
  long Bmo = 1;
  for (int i = 0; i < b; i++){
    Bch = Bch * (N - i) % mod;
    Bmo = Bmo * (b - i) % mod;
  }
  Bmo = modpow(Bmo, mod - 2, mod);
  long B = Bch * Bmo % mod;
  
  long Cch = 1;
  long Cmo = 1;
  for (int i = 0; i < c; i++){
    Cch = Cch * (N - i) % mod;
    Cmo = Cmo * (c - i) % mod;
  }
  Cmo = modpow(Cmo, mod - 2, mod);
  long C = Cch * Cmo % mod;
  
  long answer = A - 1 - B - C;
  if (answer < 0) answer += 2 * mod;
  
  cout << answer % mod << endl;
  
}

Measured memory_bytes: 256
;; C - Guess The Number

(defun solve (n sc)
  (loop for i from 0 below (expt 10 n)
        for digits = (map 'vector #'digit-char-p (princ-to-string i))
     when (and (= (length digits) n)
               (zerop
                 (loop for (s . c) in sc
                   count (not (eql c (aref digits (1- s)))))))
     do (return i)
     finally (return -1)))

(let* ((n  (read))
       (m  (read))
       (sc (loop repeat m collect (cons (read) (read)))))
  (princ (solve n sc)))


Measured memory_bytes: 6884
N = int(input())
F = [0] * N
for i in range(N):
    F[i] = list(map(int, input().split()))

P = [0] * N
for i in range(N):
    P[i] = list(map(int, input().split()))

ans = -float("inf")

for j in range(1, 1024):
    ss = 0
    for i in range(N):
        b = format(j, "010b")
        bb = [0] * 10
        for k in range(10):
            bb[k] = F[i][k] * int(b[k])
        ss += P[i][sum(bb)]
    ans = max(ans, ss)

print(ans)

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

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

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int r; cin >> r;
    cout << r*r*3 << endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    int res = 0;

    V st;

    st.push_back(s[0] - '0');

    REP(i, s.size())
    {
        if (i == 0)
            continue;

        if (st.size() && st[st.size() - 1] != s[i] - '0')
        {
            res += 2;
            st.pop_back();
        }
        else
        {
            st.push_back(s[i] - '0');
        }
    }

    int res_ = res;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 956
#include<stdio.h>
int main(void){
    int a,b,c;
    int s;
    scanf("%d%d%d",&a,&b,&c);
    if(a>c){
        s = a;
        a = c;
        c = s;
    }
    if(a>b){
        s = a;
        a = b;
        b = s;
    }
    if(b>c){
        s = b;
        b = c;
        c = s;
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2724
S = input()
N = len(S)
 
counter = [0] * 2019
counter[0] = 1
T = 0
R = 1
for i in range(N):
    T = (T + R * int(S[N - i - 1])) % 2019
    R = 10 * R % 2019
    counter[T] += 1
 
ans = 0
for i in range(2019):
    m = counter[i]
    ans += m * (m - 1) // 2
 
print(ans)

Measured memory_bytes: 9212
n, W = map(int, input().split())
w, v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())

# Dのように品物と重さでループまわすとO(nW)で今W<=10**9だから間に合わない
# 品物と価値でループ回す
# dp[i][j]の意味はi番目までの品物で、価値j以上となるように選んだ時の、重さの最小値
sum_v = sum(v)
dp = [[float("inf")]*(sum_v+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(sum_v+1):
        if j - v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
#print(dp)
ans = 0
for j in range(sum_v+1):
    if dp[n][j] <= W:
        ans = j
print(ans)



Measured memory_bytes: 311888
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarize_list(sl):

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append(c)
      a=x
      c=1
  res.append(c)

  return res
# Summarize count of factor within list --- END ---

def main():
  n,k=LI()
  s=list(S())

  s=summarize_list(s)

  if 2*k+1>=len(s):
    return n-1

  s=[0]+s

  for i in range(len(s)-1):
    s[i+1]+=s[i]
  # print(s)

  l1=[0]*len(s)
  l2=[0]*len(s)

  for i in range(1,len(s)):
    l1[i]+=l1[i-1]
    l1[i]+=s[i]-s[i-1]-1

  for i in range(1,len(s))[::-1]: 
    l2[i-1]+=l2[i]
    l2[i-1]+=s[i]-s[i-1]-1

  # print(s)
  # print(l1)
  # print(l2)

  ans=-inf
  for i in range(len(s)-(2*k+1)):
    a=s[2*k+1+i]
    b=s[i]
    # print(a,b)
    c=l1[i]
    d=l2[2*k+1+i]
    ans=max(ans,a-b+c+d)

  return ans-1

# main()
print(main())


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

	
int main(){
	int n;
	cin >> n;
	auto w = vector<string>();
	bool flag = true;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if(find(w.begin(),w.end(),s)!=w.end()){
			flag = false;
			break;
		}
		w.push_back(s);
	}

	
	if(flag){
		char c = w[0].back();
		for (int i = 1; i < n; i++)
		{
			if(c != w[i].front()){
				flag = false;
				break;
			}
			c = w[i].back();
		}
	}
	
	
	if(flag){
		cout<< "Yes";
	}else{
		cout << "No";
	}

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;

ll fact[2100010], ifact[2100010];
ll mpow(ll n, ll e) {
	ll r = 1;
	while (e) {
		if (e & 1)
			r = r * n % mod;
		n = n * n % mod;
		e /= 2;
	}
	return r;
}
void init() {
	fact[0] = 1;
	for (int i = 1; i <= 2100000; i++)
		fact[i] = fact[i - 1] * i % mod;
	ifact[2100000] = mpow(fact[2100000], mod - 2);
	for (int i = 2099999; 0 <= i; i--)
		ifact[i] = ifact[i + 1] * (i + 1) % mod;
}
ll comb(ll n, ll r) {
	return fact[n] * ifact[n - r] % mod * ifact[r] % mod;
}
ll k, n;
char s[1100000];
int main() {
	scanf("%lld", &k);
	scanf("%s", s);
	for (; s[n]; n++);
	init();
	ll sum = mpow(26, k + n);
	for (int i = 0; i < n; i++) {
		sum -= mpow(25, k + n - i) * comb(k + n, i) % mod;
		sum = (sum + mod) % mod;
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 35516
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    L=list(map(int,input().split()))
    L.sort()
    ans=0
    for b in range(1,n-1):
        c=b+1
        for a in range(b):
            while(c<n and L[a]+L[b]>L[c]): c+=1
            ans+=c-b-1
    print(ans)
resolve()

Measured memory_bytes: 42604
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

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

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    ll t;
    t=1;
    while(t--) {
        int m,n;
        cin>>m>>n;
        int sum=0;
        if(n>=2)
        {
            sum+=(n)*(n-1)/2;
        }
        if(m>=2)
        {
            sum+=(m*(m-1))/2;
        }
        cout<<sum;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 4/ 3
// Problem:2017likenumber / / b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int Q;

struct Eratosthenes {
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }

  void init(int n) {
    prime.resize(n + 1);
    REP(i, prime.size()) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i < sqrt(n); i++) {
      if (prime[i]) {
        for (int j = 0; i * (j + 2) < n; j++) {
	  prime[i * (j + 2)] = false;
	}
      }
    }
  }
};

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

  Eratosthenes e(MAX_N);
  vector< ll > likeNum(MAX_N, 0ll);
  FOR(i, 1, MAX_N) {
    likeNum[i] = likeNum[i - 1];
    if (e.prime[i] && e.prime[(i + 1) / 2]) likeNum[i]++;
  }

  cin >> Q;
  REP(i, Q) {
    CIN(l, r);
    ll ans = likeNum[r] - likeNum[l - 1];
    cout << ans << endl;
  }
  

  return 0;
}



Measured memory_bytes: 1408
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool mainmain(){
	int n;
	cin>>n;
	vint v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	bool ok = true;
	rep(i,n){
		if(v[i]!=n-1) ok=false;
	}
	if(ok) return true;
	int cnt = 0;
	rep(i,n){
		if(v.back()==v[i]) cnt++;
	}
	rep(i,n){
		if(abs(v[i]-v.back())>1) return false;
	}
	int syu = v.back();
	// cout<<n<<" "<<cnt<<" "<<syu<<endl;
	if(syu-(n-cnt)>=1 && cnt>=(syu-(n-cnt))*2) return true;
	return false;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<(mainmain()?"Yes":"No")<<endl;
}

Measured memory_bytes: 640
W,H,N=map(int,input().split())
W0,H0=0,0
for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    W0=max(x,W0)
  elif a==2:
    W=min(x,W)
  elif a==3:
    H0=max(y,H0)
  else:
    H=min(y,H)
if W-W0<0 or H-H0<0:
  print(0)
else:
  print((W-W0)*(H-H0))

Measured memory_bytes: 9200
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;



int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	ll CaseN=1; 
	//cin>>t;
	while(t--)
	{
		ll a,b,n;
		ll ans=0;
		cin>>a>>b>>n;
		ll x;
		//ll k = (a*n)/b;
		
		//ll x = b*k/a ;
		// bins=ary search in n
	    // ax = bk ;      k - k/a;
	   ll s =0;
	   ll e = n;  // x range
	    
	    while(s<=e)
	    {
		//cout<<"--"<<endl;		
		ll mid  = s + (e-s)/2 ;
		ll Ex = (a*mid/b);
		ll p = (mid/b);
		Ex = Ex - (a*p) ;	
		//ans = max(Ex,ans);	
		if(mid%b==0 && (a*mid)%b!=0)
		{	
		
		s++;	
		}
		else
		{
			
			if(Ex>=ans)
			{
				s =  mid+1;
				ans = Ex;
			}
			else
			{
			e = mid -1;
				
			}
			
		}
		
			
		}
	    
	    
		
		
		//ll Ans =0;
		//for(ll i=0;i<=n;i++)
		//{
		//x =i;
		//ll Ex = (a*x/b);
		//ll p = x/b;
		//Ex = Ex - (a*p) ;
		//cout<<Ex<<endl;
			//Ans = max(Ans,Ex);
		//}
		
		
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
		cout<<ans<<endl;
	}

return 0;
}

//if(ans)
//{ cout<<"YES"<<endl;  }
//else
//{cout<<"NO"<<endl;}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int x,y;
    cin >> x >> y;
    for(int i=0; i <= x ;i++){
        if(i*2 + 4*(x-i) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ll x,n,i,j,k;
    map<ll,ll>mp;
    cin>>x>>n;
    for(i=0;i<n;i++)
    {
        cin>>j;
        mp[j]++;
    }
    ll diff=INT_MAX,ans=-1;
    for(i=0;i<=101;i++)
    {
        if(mp.find(i)==mp.end() and diff>abs(x-i))
        {
            diff=abs(x-i);
            ans=i;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int N = 2e6 + 7;

int f[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k, s = 0; cin >> k;
	for(int i = 1; i < N; i++) {
		s = s * 10 + 7;
		s %= k;
		if(f[s]) {
			cout << -1 << endl;
			return 0;
		} 
		if(s == 0) {
			cout << i << endl;
			return 0;
		}
		f[s] = 1;
	}
}

Measured memory_bytes: 11400
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0; i<N; ++i) cin>>h[i];
  sort(h.begin(),h.end(),greater<int>());

  int ans = INT_MAX;
  for(int i=0; i<=N-K; ++i)
  {
    if(h[i]-h[i+K-1] < ans)
      ans = h[i]-h[i+K-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int n,k,ans,t[MAX],u[MAX];
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%d",&t[i]);
  for(int i=n;i>=1;i--)u[i]=(t[i]==t[i+1]?1:u[i+1]+1);
  for(int i=1;i<=n;i++)ans=max(ans,k+u[i]+u[i+u[i]]),k=(t[i]==t[i-1]?1:k+1);
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int c[n - 1], s[n - 1], f[n - 1];
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];

    rep(k, n - 1) {
        int sec = 0;

        REP(i, k, n - 1) {
            if (sec < s[i]) sec = s[i];
            else if ((sec - s[i]) % f[i] != 0) sec += -((sec - s[i]) % f[i]) + f[i];
            sec += c[i];
        }
        cout << sec << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

void init();

int n, nk;
ll k;
Vl keys, mul;

int main()
{
	init();

	Vl dp(nk, 0);
	dp[0] = 1;

	REP(_i, k)
	{
		Vl newdp(nk, 0);

		REP(i, nk)
			newdp[nk - 1 - i] = dp[i];

		for (int i = nk - 2; i >= 0; --i)
			newdp[i] = (newdp[i] + newdp[i + 1]) % MOD;

		REP(i, nk)
			newdp[i] = newdp[i] * mul[i] % MOD;

		swap(dp, newdp);
	}

	ll ans = accumulate(ALL(dp), 0LL) % MOD;
	cout << ans << endl;
}

void init()
{
	cin >> n >> k;

	int i = 1;
	while (i <= n / i)
	{
		keys.PB(i);
		keys.PB(n / i);
		++i;
	}
	sort(ALL(keys));
	nk = SZ(keys);

	mul.resize(nk);
	mul[0] = 1;
	REP1O(i, nk)
		mul[i] = keys[i] - keys[i - 1];
}

Measured memory_bytes: 2296
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#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=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans;
    cin >> n;
    REP(i, 7){
        int buf = (int)pow(2, i);
        if(buf > n){
            break;
        }
        ans = buf;
    }
    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
			for(int i = 0; n > i; i++)
			{
				double x1 = sc.nextDouble();
				double y1 = sc.nextDouble();
				double x2 = sc.nextDouble();
				double y2 = sc.nextDouble();
				double x3 = sc.nextDouble();
				double y3 = sc.nextDouble();
					double A1 = (2 * (x2 - x1));
					double B1 = (2 * (y2 - y1));
					double C1 = (x1*x1 - x2*x2 + y1*y1 - y2*y2);
					double A2 = (2 * (x3 - x1));
					double B2 = (2 * (y3 - y1));
					double C2 = (x1*x1 - x3*x3 + y1*y1 - y3*y3);
						double px = ((B1*C2 - B2*C1)/(A1*B2 - A2*B1));
						double py = ((C1*A2 - C2*A1)/(A1*B2 - A2*B1));
						double r = (Math.sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1)));
					System.out.printf("%.3f %.3f %.3f\n", px, py, r);
			}
	}
}

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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

LL a, b, c, d;

int main(){
	read(a, b, c, d);
	printf("%lld\n", max(max(a*c, a*d), max(b*c, b*d)));
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int x,n;
	cin>>x>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=123,diff=113;
	for(int i=0;i<=101;i++)
	{
		int f=1;
		for(int j=0;j<n;j++)  //4 7 10 6 5
		{
			if(i==a[j])
			{
				f=0;break;
			}
		}
		if(f)
		{
			if(diff>abs(x-i)){
				ans=i;
				diff=abs(x-i);
			}
		}
	}
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
using namespace std;

int main() {
	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	int ans = 0;

	string U;
	for(int i = 0; i <N;i++){
		if (T[i] == 's') U += 'r';
		else if (T[i] == 'r') U += 'p';
		else if (T[i] == 'p') U += 's';

		if (i >= K && U[i] == U[i - K]) U[i] = 'a';
	}

	for (int i = 0; i < N; i++) {
		if (U[i] == 's') ans += S;
		else if (U[i] == 'r') ans += R;
		else if (U[i] == 'p') ans += P;
	}

	cout << ans << endl;
}

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

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

using namespace std;

long long n;

int dfs(long long d,bool a,bool b,bool c){
	if(d>n) return 0;
	int res=(a&&b&&c?1:0);
	res+=dfs(10*d+3,true,b,c);
	res+=dfs(10*d+5,a,true,c);
	res+=dfs(10*d+7,a,b,true);
	return res;
}

int main(){
	scanf("%lld",&n);
	printf("%d\n",dfs(0,false,false,false));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b;ll c;}aaa;

ll a,b,n,k,m,ans=0,res,minimo; 
int grados[10];
int main(){



    scanf("%lld%lld%lld",&k,&a,&b);
    if(b-a>1)
        k=k+1-a;
    

    ans = a;
    ans += (b-a) * (k/2);
    ans += k%2;

    if(b-a<=1) ans = 1 + k;

    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;
ll R,C;
ll dp[3001][3001][4];
// dp[i][j][picked] : denotes the max value picked from (i,j) to (R,C) with the constraints given
ll rec(int i,int j,int picked,vector<vector<ll>> &grid)
{
	if(i>R||i<1||j>C||j<1) return 0;
	if(dp[i][j][picked]!=-1) return dp[i][j][picked];

	dp[i][j][picked]=max(dp[i][j][picked],rec(i+1,j,0,grid));
	if(picked<3) dp[i][j][picked]=max(dp[i][j][picked],grid[i][j]+rec(i+1,j,0,grid));
	dp[i][j][picked]=max(dp[i][j][picked],rec(i,j+1,picked,grid));
	if(picked<3) dp[i][j][picked]=max(dp[i][j][picked],rec(i,j+1,picked+1,grid)+grid[i][j]);

	return dp[i][j][picked];
}
void solve()
{
	ll K;
	cin>>R>>C>>K;
	vector<vector<ll>> grid(R+1,vector<ll>(C+1,0));
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<K;i++)
	{
		ll r,c,v;
		cin>>r>>c>>v;
		grid[r][c]=v;
	}
	cout<<rec(1,1,0,grid)<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 355628
#include <string>
#include <iostream>
using namespace std;
int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    string t = {a[0], b[0], c[0]};
    for (auto &c : t)
    {
        c -= ('a' - 'A');
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if (x >= a and a + b >= x) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
  
const int MAXH = 400;
const int MAXW = 105;
const int MAXX = 101;
const double inf = 1e100;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
  
int N, X;
int si, sj, ti, tj;
int pi[MAXX], pj[MAXX], qi[MAXX], qj[MAXX];
vector<int> vi;
map<int,int> mi, rmi;
int H;
set<pair<pair<int,int>, pair<int,int> > > wall;
double x;
  
struct State {
  int pi, pj;
  double cost;
  bool operator < (const State &s) const {
    return cost > s.cost;
  }
};
double cost[MAXH][MAXW];
  
double getDist(int si, int sj, int ti, int tj) {
  if(si == ti) {
    return rmi[si] * x;
  } else {
    return abs(rmi[si]-rmi[ti]);
  }
}
  
double dijkstra(int si, int sj, int ti, int tj) {
  priority_queue<State> que;
  fill(cost[0], cost[MAXH], inf);
  que.push((State){si,sj,0.0});
  cost[si][sj] = 0.0;
  while(!que.empty()) {
    const State s = que.top();
    que.pop();
    if(cost[s.pi][s.pj] < s.cost) continue;
    if(s.pi == ti && s.pj == tj) return s.cost;
    for(int k = 0; k < 4; ++k) {
      State t = s;
      t.pi += di[k];
      t.pj = (t.pj + dj[k] + N) % N;
      if(t.pi >= H) continue;
      if(t.pi < 0) continue;
      if(wall.count(make_pair(make_pair(s.pi,s.pj),make_pair(t.pi,t.pj)))) continue;
      t.cost += getDist(s.pi, s.pj, t.pi, t.pj);
      if(cost[t.pi][t.pj] <= t.cost) continue;
      que.push(t);
      cost[t.pi][t.pj] = t.cost;
    }
  }
  return inf;
}
  
int main() {
  while(cin >> N >> X && (N|X)) {
    cin >> si >> sj >> ti >> tj;
    --sj; --tj;
    for(int i = 0; i < X; ++i) {
      cin >> pi[i] >> pj[i] >> qi[i] >> qj[i];
      --pj[i]; --qj[i];
    }

    vi.clear();
    vi.push_back(1);
    vi.push_back(si);
    vi.push_back(ti);
    for(int i = 0; i < X; ++i) {
      if(pi[i]-1 >= 1) vi.push_back(pi[i]-1);
      vi.push_back(pi[i]);
      vi.push_back(pi[i]+1);
      if(qi[i]-1 >= 1) vi.push_back(qi[i]-1);
      vi.push_back(qi[i]);
      vi.push_back(qi[i]+1);
    }
    sort(vi.begin(), vi.end());
    vi.erase(unique(vi.begin(), vi.end()), vi.end());
  
    mi.clear();
    rmi.clear();
    for(int i = 0; i < vi.size(); ++i) {
      mi[vi[i]] = i;
      rmi[i] = vi[i];
    }
  
    H = vi.size();
    si = mi[si];
    ti = mi[ti];
    for(int i = 0; i < X; ++i) {
      pi[i] = mi[pi[i]];
      qi[i] = mi[qi[i]];
    }
  
    wall.clear();
    for(int i = 0; i < X; ++i) {
      pair<pair<int,int>, pair<int,int> > p = make_pair(make_pair(pi[i],pj[i]),make_pair(qi[i],qj[i]));
      wall.insert(p);
      swap(p.first, p.second);
      wall.insert(p);
    }
  
    x = sqrt(2.0 - 2.0*cos(M_PI*2.0/(double)N));
  
    printf("%.2f\n", dijkstra(si, sj, ti, tj));
  }
  return 0;
}

Measured memory_bytes: 1704