akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
t = n.times.map{gets.to_i}.sort!

def gcd a, b
  if b > a
    a, b = b, a
  end
  while a % b != 0
    tmp = a % b
    a = b
    b = tmp
  end
  return b
end

def lcm a, b
  a * b / gcd(a, b)
end

while t.length > 1
	i = t.length - 1
	while i > 0
		t[i-1] = lcm t[i], t[i-1]
		t.delete_at i
    i = i - 2
	end
end

puts t[0]

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r;
    while (1) {
        c -= b;
        if (c <= 0) break;
        a -= d;
        if (a <= 0) break;
    }

    cout << (a > 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n;
cin>>n;
ll a[n];
map<ll,ll>rensou;
for(int i=0;i<n;i++){
cin>>a[i];
rensou[i]=a[i];
}
sort(a,a+n,greater<ll>());
for(int i=0;i<n;i++){
    if(a[0]==rensou[i]){
        cout<<a[1]<<endl;
    }else{
        cout<<a[0]<<endl;
    }
}
}





Measured memory_bytes: 16768
import java.util.*;
public class Main 
{
	static boolean[] isPrime = new boolean[55000];
	static List<Integer> list = new ArrayList<Integer>();
	static void primeCalc()
	{
		for(int i = 0; i < isPrime.length; ++i)
		{
			isPrime[i] = true;
		}
		isPrime[0] = isPrime[1] = false;
		for(int i = 2; i < isPrime.length; ++i)
		{
			if(isPrime[i])
			{
				list.add(i);
				for(int j = 2 * i; j < isPrime.length; j += i)
				{
					isPrime[j] = false;
				}
			}
		}
	}
	
	public static void main(String[] args) 
	{
		primeCalc();
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			int pos = 0;
			while(true)
			{
				if(list.get(pos) >= n)
				{
					System.out.print(list.get(pos - 1) + " ");
					break;
				}
				++pos;
			}
			if(list.get(pos) == n)
			{
				System.out.println(list.get(pos + 1));
			}
			else
			{
				System.out.println(list.get(pos));
			}
		}
	}
}

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

#define ll long long

ll f(ll b, ll n){
    if(n<b)return n;
    return f(b, n/b) + (n%b);
}

int main(){
    ll n, s;
    cin>>n>>s;
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    for(ll b= 2; b<=sqrt(n)+1;b++){
        if(f(b, n)==s){
            cout<<b<<endl;
            return 0;
        }
    }
    if(n-s>1){
        for(ll i=sqrt(n);i>0;i--){
            ll b = (n-s)/i+1;
            if(f(b,n)==s){
                cout<<b<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
  int price;
  int a, b;
  scanf("%d%d", &a, &b);
  for(price = 13; price < 1009; price++){
    if((int)(price * 0.08) == a && (int)(price * 0.1) == b){
      printf("%d\n", price);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}

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

int N, M;
vector<P> AB;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, N) {
        int A, B; cin >> A >> B;
        AB.pb(P(A, B));
    }
    sort(AB.begin(), AB.end());
    int ans = 0;
    rep(i, N) {
        int A = AB[i].first, B = AB[i].second;
        if (M-B>0) {
            ans += B*A;
            M -= B;
        }
        else {
            ans += M*A;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
 int a,b,c;
  cin >> a >> b >> c;
  if (b-a == c-b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int a,b,c,e,h=0;
	cin>>a;
	int d[a][3]={0};
	int D[a]={0};
	for (b=0;b<a;b++){
		for (c=0;c<3;c++){
			cin>>e;
			d[b][c]=e;
		}
	}
	for (c=0;c<3;c++){
		for (b=0;b<a;b++){
			for (int G=0;G<a;G++){
				if (d[b][c]!=d[G][c]) h++;
				if (h>=a-1){
						D[b]=d[b][c]+D[b];
						break;
					}
			}
			h=0;
		}
	}
	for (b=0;b<a;b++) cout<<D[b]<<endl;
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void solve()
{
    string s,t; cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])
    cnt++;
    cout<<cnt;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1; //cin>>test;
    int x=1;
    while(test--)
    {
        //cout<<"Case #"<<x++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
string s;
int vvv,res;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	for(int i=0;i<s.size();i++){
		if((s[i]=='A')||(s[i]=='C')||(s[i]=='G')||(s[i]=='T')){
			vvv++;
		}
		else{
			res=max(res,vvv);
			vvv=0;
		}
	}
	res=max(res,vvv);
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
line1 = input()
line2 = input()

a, b, c = tuple([int(val) for val in line1.split()])
k = int(line2)

for i in range(k):
    if b <= a:
        b = b*2
    elif c <= b:
        c = c*2
    else:
        continue

done = False
if b > a and c > b:
    done = True

if done:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
<?php
 
fscanf(STDIN, "%d%d", $x, $y);
 
$arrayA = [1,3,5,7,8,10,12];
$arrayB = [4,6,9,11];
$arrayC = [2];
 
$rslA = [];
$rslB = [];
 
if (in_array($x,$arrayA)){
    $rslA[] = 1;
}elseif (in_array($x,$arrayB)){
    $rslA[] = 2;
}else{
    $rslA[] = 3;
}
 
if (in_array($y,$arrayA)){
    $rslB[] = 1;
}elseif (in_array($y,$arrayB)){
    $rslB[] = 2;
}else{
    $rslB[] = 3;
}
 
if ($rslA == $rslB){
    echo 'Yes';
}else{
    echo 'No';
}

Measured memory_bytes: 4728
class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		
		String str = sc.next();
		
		for( int index = str.length()-1 ; index >= 0 ; index-- )
			System.out.print( str.charAt( index ) );
		System.out.println();
	}
}

Measured memory_bytes: 26012
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  int count[n];
  for(int i=0;i<=n;i++)
    count[i]=0;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      int s=j-i;
      int k=abs(x-i-1)+1+abs(j-y+1);
      //int u=abs(y-i-1)+1+abs(j-x+1);
      //int v=((s<k)&&(s<u))?s:(k<u)?k:u;
      int v=(s<k)?s:k;
      count[v]++;
    }
  }
  for(int i=1;i<n;i++)
    cout<<count[i]<<"\n";
}


Measured memory_bytes: 256
from collections import defaultdict

KINDS = ['S','H','C','D']
NUM = 13

n = int(input())

cards = defaultdict(bool)
for _ in range(n):
    cards[input()] = True

for mark in KINDS:
    for num in range(1,NUM+1):
        if not cards[f'{mark} {num}']:
            print(f'{mark} {num}')


Measured memory_bytes: 6012
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    const int base = 26;
    long long N;
    string name = "";
    vector<int> nameNum;

    cin >> N;

    long long quotient = N;
    int remainder;

    while (quotient > 0 )
    {
        remainder = quotient % base;
        quotient  = quotient / base;

        if( remainder > 0 )
        {
            nameNum.push_back( remainder );
        } else {
            nameNum.push_back( base );
            --quotient;
        }
    }

    for (auto i = nameNum.rbegin(), e = nameNum.rend(); i != e; ++i)
    {
        name.push_back(static_cast<char>(('a' + *i) - 1));
    }

    cout << name << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int a,p;
  cin >> a >> p;
  int ans = (3*a+p)/2;

  cout << ans << 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 __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vll l(n);
	for(ll& x : l)cin >> x;
	
	sort(all(l));
	
	int cnt=0;
	for(int i=0 ; i<n ; ++i){
		for(int j=i+1 ; j<n ; ++j){
			for(int k=j+1 ; k<n ; ++k){
				set<ll> s;
				s.insert(l[i]);s.insert(l[j]);s.insert(l[k]);
				if(s.size() < 3)continue;
				if(l[i] + l[j] > l[k])++cnt;
				else break;
			}
		}
	}
	
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
  
vector<int>aget(const vector<int>&l, const vector<int>&r,const int type) {
	vector<int>v(4);
	for (int i = 0; i < 4; ++i) {
		if (type == 0)v[i] = l[i] || r[i];
		else if (type == 1)v[i] = l[i] && r[i];
		else v[i] = l[i] ^ r[i];
	}
	return v;
}

struct node {
	int type;
	node* l;
	node* r;

	node() : l(nullptr), r(nullptr) {
		type = -1;
	}
};


string st;
int a = 0;
int  num = 0;
vector<vector<int>>cakes;
node* make_tree() {
	node* no=new node();
	if (st[a] == '(') {
		num++;
		no->type = -num;
		a++;
		no->l = make_tree();
		a++;
		assert(st[a] == ' ');
		a++;
		no->r = make_tree();
		a++;
		assert(st[a] == ')');
	}
	else {
		no->type = st[a] - '1';
	}
	return no;
}

vector<int>getans(node* now,const vector<int>&types) {
	if (now->type <0) {
		return aget(getans(now->l, types), getans(now->r, types), types[-now->type - 1]);
	}
	else {
		return cakes[now->type];
	}
}

long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

int main() {
	while (getline(cin, st)) {
		cakes.clear();
		if (st == "END")break;
		a = 0;
		num = 0;
		node* root(make_tree());
		int M; cin >> M;
		for (int i = 0; i < M; ++i) {
			vector<int>v(4);
			for (int j = 0; j < 4; ++j)cin >> v[j];
			cakes.emplace_back(v);
		}
		int sum = 0;
		for (int i = 0; i <powint(3,num); ++i) {
			vector<int>types(num);
			{
				int n(i);
				for (int i = 0; i < num; ++i) {
					types[i] = n % 3;
					n /= 3;
				}
			}
			auto ans = getans(root, types);
			if (all_of(ans.begin(), ans.end(), [](const int a) {return a == 1; })) {
				sum++;
			}
		}
		cout << sum << endl;
		getline(cin, st);
	}

	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
const int N = 5e5+5;
ll n, m, k, x, y, a, b, t, q, ans, sum;
ll mod=1e9+7;
char c;
string s;

vector< ll >v;
ll A[N],B[N],C[N];
ll dp[N];
bool ok;

main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>C[i];
 	
 	k=1;
 	
 	for(int i=1;i<=n;i++)
 	if(C[i]!=C[i-1])
 	A[k]=C[i],k++;
 	
 	dp[0]=1;
 	for(int i=1;i<k;i++)
 	dp[i] += dp[i-1] + B[A[i]], B[A[i]] = dp[i], dp[i]%=mod, B[A[i]]%=mod; 
 
    cout<<dp[k-1]<<endl;
}







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

ans = 0
b = [0] * n
c = 0

for i in range(n):
    c = c + a[i]
    b[i] = c

for j in range(n-1):
    ans = (a[j] * (b[n-1] - b[j]) + ans) % (10**9+7)

print(ans)


Measured memory_bytes: 105064
A=int(input())
B=[int(i) for i in input().split()]
flag=True
s=0
while flag:
    flag=False
    for j in range(1,A):
        if B[j]<B[j-1]:
            B[j],B[j-1]=B[j-1],B[j]
            flag=True
            s+=1
for i in range(A):
    if i!=A-1:
        print(B[i],end=" ")
    else:
        print(B[i])
print(s)



Measured memory_bytes: 5616
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 13;
ll dp[2][1 << N], n;

void clear(int id) {
  for(int i = 0; i < (1 << n); i++) {
    dp[id][i] = 0x3f3f3f3f3f3f3f3f;
  }
}

void Main() {
  int m; cin >> n >> m;
  int cur = 0; clear(0), clear(1);
  dp[0][0] = 0;
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    int now = 0;
    for(int i = 0; i < b; i++) {
      int c; cin >> c;
      now |= (1 << (c - 1));
    }
    for(int i = 0; i < (1 << n); i++) {
      if(dp[cur][i] != 0x3f3f3f3f3f3f3f3f) {
        dp[!cur][i | now] = min(dp[!cur][i | now], dp[cur][i] + a);
        dp[!cur][i] = min(dp[!cur][i], dp[cur][i]);
      }
    }
    clear(cur);
    cur = !cur;
  }
  cout << (dp[cur][(1 << n) - 1] == 0x3f3f3f3f3f3f3f3f ? -1 : dp[cur][(1 << n) - 1]) << "\n";
}


Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//最小全域木を作る、最小全域木でつながった中で任意の配分ができる
	//二分探索ではなく有理数でも解くことができる
	//3^n DP しかなくない?
	cout<<setprecision(20);
	double dp[32768];
	llint i,j,n;cin>>n;
	double x[15],y[15];
	double a[15];
	for(i=0;i<(1<<n);i++){dp[i]=big;}
	for(i=0;i<n;i++){cin>>x[i]>>y[i]>>a[i];dp[1<<i]=0;}
	//全域木のコストを求める,葉に何かを入れるタイプの探索をする
	for(int bi=1;bi<(1<<n);bi++){
		for(i=0;i<n;i++){
			if(!(bi&(1<<i))){continue;}
			for(j=0;j<n;j++){
				if(!(bi&(1<<j))){continue;}
				if(i==j){continue;}
				mineq(dp[bi],dp[bi-(1<<j)]+sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
			}
		}
	}
	for(int bi=1;bi<(1<<n);bi++){
		double wata=0,mati=0;
		for(i=0;i<n;i++){if(bi&(1<<i)){wata+=a[i];mati+=1;}}
		dp[bi]=(wata-dp[bi])/mati;
	}
	for(int bi=1;bi<(1<<n);bi++){
		for(int Anum=0;Anum<bi;Anum++){
			while(-1){
				int x=Anum&(~bi);
				if(x==0){break;}
				else{Anum+=x;}
			}
			int Bnum=bi-Anum;
			maxeq(dp[bi],min(dp[Anum],dp[Bnum]));
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

int main() {
   vector<string> s(3);
   rep(i, 3) {
       cin >> s[i];
   }

   cout << (char)(s[0][0]-32) << (char)(s[1][0]-32) << (char)(s[2][0]-32) << endl;

}

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

using namespace std;

const int MaxN = 505;

long long a[MaxN][MaxN];

vector <int> p1;
vector <int> p2;

long long lcm(long long a, long long b)
{
    return a / __gcd(a, b) * b;
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};

void build(int x, int y)
{
    for(int i = 0; i < 4; ++i)
    {
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(xx >= 0 && xx < MaxN && yy >= 0 && yy < MaxN)
            a[x][y] = lcm(a[x][y], a[xx][yy]);
    }

    ++a[x][y];

    assert(a[x][y] <= 1e15 && a[x][y] > 0);
}

void check()
{
    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
        {
            for(int d = 0; d < 4; ++d)
            {
                int x = i + dx[d];
                int y = j + dy[d];

                if(x >= 0 && x < MaxN && y >= 0 && y < MaxN)
                {
                    long long k1 = min(a[i][j], a[x][y]);
                    long long k2 = max(a[i][j], a[x][y]);

                    assert(k2 % k1 == 1);
                }
            }
        }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    mt19937 rnd(clock());

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            a[i][j] = 1;

    for(int i = 2; i <= 20000; ++i)
        if(isPrime(i))
        {
            if(p1.size() < MaxN)
                p1.push_back(i);
            else
                p2.push_back(i);
        }

//    shuffle(p1.begin(), p1.end(), rnd);
//    shuffle(p2.begin(), p2.end(), rnd);

    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j + i < MaxN; ++j)
            a[i + j][j] *= p1[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; i + j < MaxN; ++i)
            a[i][j + i] *= p1[j - 1];


    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j < MaxN && i - j >= 0; ++j)
            a[i - j][j] *= p2[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; j + i < MaxN; ++i)
            a[MaxN - 1 - i][j + i] *= p2[j - 1];

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            if((i + j) & 1)
                build(i, j);

    check();

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
            cout << a[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 4992
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, X, M = rl()

Xs = [None] * M

ans = 0
dif_i = 0
dif_v = 0
cur_i = 0
for i in range(1, N+1):
	ans += X
	if Xs[X] != None:
		cur_i = i
		dif_v = ans - Xs[X][1]
		dif_i = i - Xs[X][0]
		cur_x = X
		break
	Xs[X] = (i, ans)
	X = (X**2) % M
if cur_i > 0 and cur_i < N:
	remain = N - cur_i
	ans += (remain // dif_i) * dif_v
	X = cur_x
	for i in range(remain % dif_i):
		X = (X**2) % M
		ans += X
print(ans)


Measured memory_bytes: 76120
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;



int main() {
    int s,w;
    cin>>s>>w;
    
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else cout<<"safe"<<endl;
    
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll N,A;
    cin>>N>>A;
    ll x=N/500;
    if((N-500*x)<=A*1)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int sz = s.size(), cnt = 0;
    for (int i = 0; i < sz; i++) if (s[i] != t[i]) cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3420
import sys
from bisect import bisect_left

input = sys.stdin.readline


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

    L.sort()
    ans = 0
    for i in range(N - 1):
        a = L[i]
        for j in range(i + 1, N):
            k = bisect_left(L, a + L[j])
            ans += (k - 1 - j)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    int a,p;
    cin>>a>>p;
    p+=3*a;
    cout << p/2 << endl;
}


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


Measured memory_bytes: 2036
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 2e5 + 5;

int n, m;
char a[12][12];
bool used[12][12];

bool f(int x, int y) {
	if (x >= 1 && x <= n && y >= 1 && y <= m) {
		if (a[x][y] == '#' && used[x][y] == 0) return 1;
		else return 0;
	}
	else return 0;
}

void rec(int x, int y) {
	
	used[x][y] = 1;
	if (f(x + 1, y)) {
		rec(x + 1, y);
		return;
	}
	if (f(x, y + 1)) {
		rec(x, y + 1);
		return;
	}
}

int main() {	

	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	rec(1, 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == '#' && used[i][j] == 0) {
				cout << "Impossible";
				return 0;
			}
		}
	}
	cout << "Possible";
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const ans = input
                 .trim()
                 .split(" ")
                 .map(n => Number(n))
                 .sort((a,b) => a - b)
                 .slice(0,2)
                 .reduce((a,b) => a + b)
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
main = do
  [a, b] <- map (read :: String -> Int) . words <$> getLine
  print $ solve a b

rates = [0.08, 0.1]

solve a b = if start > finish then -1 else start
  where
    [minA, minB] = zipWith (/) [fromIntegral a, fromIntegral b] rates
    [maxA, maxB] = zipWith (/) [fromIntegral a + 1, fromIntegral b + 1] rates
    [start, finish] = [ceiling (minA `max` minB), fixup (maxA `min` maxB)]
    fixup x
      | fromIntegral (floor x) == x = floor (x - 1)
      | otherwise = floor x

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

int main(int argc, char ** argv)
{
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a(n);
  std::vector<double> K(n);

  double tmp_max = 0.0;
  double max = 0.0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    K[i] = (1 + a[i]) / 2.0;

    tmp_max += K[i];
    if (i < k) {
      max = tmp_max;
      continue;
    }
    tmp_max -= K[i - k];
    max = std::max(max, tmp_max);
  }

  std::printf("%f\n", max);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    cout << (N + 2 - 1) / 2 << endl;
}


Measured memory_bytes: 256
s=input()
l=len(s)
if l%2==0:
    for i in range(l-3,0,-2):
        if s[:i//2+1]==s[i//2+1:i+1]:
            print(len(s[:i+1]))
            exit()
else:
    for i in range(l-2,0,-2):
        if s[:i//2+1]==s[i//2+1:i+1]:
            print(len(s[:i+1]))
            exit()

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

using namespace std;

int main(void) {
	long long N, M;
	vector<long long> v;
	map<long long, long long> m;
	cin >> N >> M;
	long long s = 0;
	for(int i = 0; i < N; ++i) {
		long long t;
		cin >> t;
		s += t;
		++m[s % M];
	}
	long long result = 0;
	for(auto const& x : m) {
		result += x.second * (x.second - 1) / 2;
	}
	result += m[0];
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	if (a+b>c+d) cout <<"Left";
	else if (a+b==c+d) cout <<"Balanced";
	else if (a+b<c+d) cout <<"Right";
	cout <<endl;
	return 0;
}

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



#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


// a の i ビット目と j ビット目を swap する
void swa(int &a, int i, int j) {
    if ( (a & (1<<i)) && !(a & (1<<j)) ) a += -(1<<i) + (1<<j);
    else if ( !(a & (1<<i)) && (a & (1<<j)) ) a += (1<<i) - (1<<j);
}

// 0, 1, ..., n-1 ビット目を動かして、a を b にする
vector<int> solve(int n, int a, int b) {
    if (n == 1) return {a, b};
    
    // a^b の最高位が 1 でないときは 1 を見つけて swap する
    int exchange = n-1;
    int c = a^b;
    if (!(c & (1<<(n-1)))) {
        for (int d = 0; d < n-1; ++d) if (c & (1<<d)) exchange = d;
    }
    swa(a, n-1, exchange), swa(b, n-1, exchange);

    // 前半戦: テキトーに最後尾のビットを入れ替えておく
    int na = a & ~(1<<(n-1));
    auto zenhan = solve(n-1, na, na^1);

    // 後半戦: na の最上位を 0 にたものについて、1 を na にする感じ
    int nb = b & ~(1<<(n-1));
    auto kouhan = solve(n-1, na^1, nb);

    // マージする
    vector<int> res;
    if (a & (1<<(n-1))) {
        for (auto v : zenhan) res.push_back(v ^ (1<<(n-1)));
        for (auto v : kouhan) res.push_back(v);
    }
    else {
        for (auto v : zenhan) res.push_back(v);
        for (auto v : kouhan) res.push_back(v ^ (1<<(n-1)));
    }

    // 最後に swap して戻す
    for (auto &v : res) swa(v, n-1, exchange);
    return res;
}

int main() {
    int N, A, B; cin >> N >> A >> B;
    int C = A ^ B;
    int bitcount = 0;
    for (int i = 0; i < N; ++i) if (C & (1<<i)) ++bitcount;
    if (bitcount % 2 == 0) {
        cout << "NO" << endl;
        return 0;
    }
    auto res = solve(N, A, B);
    cout << "YES" << endl;
    for (auto v : res) cout << v << " ";
    cout << endl;
}


Measured memory_bytes: 1756
var
	n,k,i,c,t,min:longint;
begin
	read(n,k);
	min:=100000;
	for i:=1 to n do
	begin
		read(c,t);
		if t<=k then 
			if c<min then min:=c;
	end;
	if min=100000 then writeln('TLE') else writeln(min);
end.

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

int main(){
    string s;
    cin >> s;
    int han;
    int i;
    for(i=0;i<(s.size()/2);i++){
        if(s.at(i) != s.at(s.size()-i-1)){
            han++;
        }
    }
    for(i=0;i<(s.size()/2);i++){
        if(s.at(i) != s.at((s.size()-1)/2-i-1)){
            han++;
        }
    }
    for(i=(s.size()+3)/2-1;i<(s.size()/2);i++){
        if(s.at(i) != s.at(s.size()-i-1)){
            han++;
        }
    }
    if(han==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Data.List
  
check a str = incheck $ splitAt a str
 where
  incheck (_,[]) = []
  incheck (x,y)  = inincheck x':(check (a+1) str)
   where
    x' = nub x
    inincheck [] = 0
    inincheck (k:ks)
     | elem k y = 1 + inincheck ks
     | otherwise= 0 + inincheck ks

main = do
 _ <- getLine
 str <- getLine
 print $ maximum $ check 1 str

Measured memory_bytes: 892
#include<stdio.h>
void swap(int&x,int&y){int t=x;x=y;y=t;}
const int Maxn=200010;
int n,a[Maxn],b[Maxn],c[Maxn],d[Maxn],ld=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),c[a[i]]++;
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),c[b[i]]++;
	for(int i=1;i<=n;i++)if(c[i]>n)return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n/2;i++)swap(b[i],b[n-i+1]);
	int L=-1,R,x;
	for(int i=1;i<=n;i++)
	if(a[i]==b[i])
	{
		L=i;x=a[i];
		for(int j=i;j<=n;j++)
		if(a[j]==b[j])R=j;
		break;
	}
	if(L!=-1)
	{
		for(int i=1;i<=n;i++)
		if(a[i]!=x&&b[i]!=x)d[++ld]=i;
		for(int i=L;i<=R;i++)
		swap(b[i],b[d[ld--]]);
	}
	for(int i=1;i<=n;i++)printf("%d ",b[i]);
 } 

Measured memory_bytes: 4652
fn main() {
    proconio::input! {
        n: usize,
        p: [f64; n],
    }
    let mut dp = vec![1f64, 0f64];
    for p in p {
        let mut next = vec![0f64; dp.len() + 1];
        let q = 1f64 - p;
        next[0] = dp[0] * q;
        for (next, dp) in next.iter_mut().skip(1).zip(dp.windows(2)) {
            *next = dp[0] * p + dp[1] * q;
        }
        dp = next;
    }
    let ans = dp.into_iter().skip(n / 2 + 1).sum::<f64>();
    println!("{:.10}", ans);
}

Measured memory_bytes: 2408
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      n: usize,
      mut a: [usize; n+1]
   }
   if a[0] != 0 {
      if n == 0 && a[0] == 1 {
         println!("1");
      } else {
         println!("-1");
      }
      return;
   }

   let mut mn = vec![0usize; n + 1];
   let mut mx = vec![0usize; n + 1];
   mn[n] = a[n];
   mx[n] = a[n];
   for i in (0..n).rev() {
      mn[i] = a[i] + (mn[i + 1] - 1) / 2 + 1;
      mx[i] = mx[i + 1] + a[i];
   }

   let mut now = 1;
   let mut ans = 0;
   for i in 0..n {
      ans += now;
      let m = (now - a[i]) * 2;
      if m < mn[i + 1] {
         println!("-1");
         return;
      }
      now = std::cmp::min(mx[i + 1], m);
   }
   ans += now;
   println!("{}", ans);
}


Measured memory_bytes: 5256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        public enum Mark : int {
            S,
            H,
            C,
            D }

        static void Main(string[] args)
        {
            int cardNum = int.Parse(Console.ReadLine());

            //4??????????????????????????¨1???13?????°??????2?¬??????????
            int[,] haveCard2D = new int[4, 13];


            //????????¶???????????£?????????????????????2?¬????????????????????????????
            for (int i = 0; i < cardNum; i++)
            {
                string[] cardInput = Console.ReadLine().Split(' ');

                //2?¬????????????????????????????????????????
                switch (cardInput[0])
                {
                    case "S":
                        haveCard2D[(int)Mark.S , int.Parse(cardInput[1]) - 1] = int.Parse(cardInput[1]);
                        break;


                    case "H":
                        haveCard2D[(int)Mark.H, int.Parse(cardInput[1]) - 1] = int.Parse(cardInput[1]);
                        break;


                    case "C":
                        haveCard2D[(int)Mark.C, int.Parse(cardInput[1]) - 1] = int.Parse(cardInput[1]);
                        break;

                    case "D":
                        haveCard2D[(int)Mark.D, int.Parse(cardInput[1]) - 1] = int.Parse(cardInput[1]);
                        break;
                }

            }


            //????¶?????????????????????????
            for(int i = 0; i < (int)Mark.D + 1; i++)
            {
                for(int x = 0; x < 13; x++)
                {
                    if (NullCheck(haveCard2D[i, x])) OutPut(x, i);

                    else
                    {        
                        continue;
                    }
                }

            }

        }


        private static bool NullCheck(int args)
        {
            if (args == 0) return true;
            else return false;
        }

        private static void OutPut(int argsnum, int flag)
        {
            string outMark = string.Empty;

            switch (flag)
            {
                case (int)Mark.S:
                    outMark = "S";
                    break;

                case (int)Mark.H:
                    outMark = "H";
                    break;

                case (int)Mark.C:
                    outMark = "C";
                    break;

                case (int)Mark.D:
                    outMark = "D";
                    break;
            }

            Console.WriteLine("{0} {1}", outMark, argsnum + 1);
        }
    }
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	auto acgt = [&] (char c) {
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
			return true;
		return false;
	};
	int ans = -INF;
	int cnt = 0;
	rep(i, s.size()) {
		if (acgt(s[i]))
			cnt++;
		else {
			chmax(ans, cnt);
			cnt = 0;
		}
	}
	chmax(ans, cnt);
	cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    ll ans = 0;
    rep(i, N) {
        rep(j, D) {
            cin >> X[i][j];
        }
    }
    rep(i, N - 1) {
        rep2(j, i + 1, N) {
            ll temp = 0;
            rep(x, D) {
                ll tmp = X[i][x] - X[j][x];
                temp += tmp * tmp;
            }
            ld tmp2 = sqrtl(temp);
            if(tmp2 == floorl(tmp2)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
 
using namespace std;
 
typedef unsigned long long ull;
 
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
 
int main(){
    int n; cin>>n;
    cin.ignore();
    while(n--){
        string s; getline(cin,s);
        size_t beg;
        while(beg=s.find("Hoshino"), beg!=string::npos){
            s[beg+6]='a';
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int>prefix(n),suffix(n);
    prefix[0]=arr[0];
    for(int i=1;i<n;i++) prefix[i]=prefix[i-1]+arr[i];
    suffix[n-1]=arr[n-1];
    for(int i=n-2;i>=0;i--) suffix[i]=suffix[i+1]+arr[i];
    int minn=INT_MAX;
    for(int i=0;i<n;i++)
    {
        minn=min(minn,abs(prefix[i]-suffix[i]+arr[i]));
    }
    cout<<minn<<" ";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;

int main(){
    fast;
    int n,k,ans=0;
    cin >> n >>k;
    int num[n] = {0};
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        int arr[d];
        for(int j=0;j<d;j++){
            cin >> arr[j];
            num[arr[j]-1] = num[arr[j]-1]+1;
        }
    }
    for(int i=0;i<n;i++){
        if(num[i]==0) ans++;
        //cout << i << endl;
    }
    cout << ans;
}


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

def comb(n,k):
    nCk = 1
    # X
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    # Y
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk

n, a, b = map(int, input().split())
ans = pow(2, n, MOD) - comb(n, a) - comb(n, b) - 1
print(ans%MOD)

Measured memory_bytes: 40880
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

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

int main() {

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

	int N, X;
	cin >> N >> X;

	vector<int> city(N);
	for (int i = 0; i < N; i++) cin >> city[i];

	int ans = 0;
	for (int i = 0; i < N; i++) ans = gcd(ans, abs(city[i] - X));

	cout << ans << "\n";

	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

int main() {
  ll n;
  cin >> n;
  vl a(n);
  REP(i,n){
    cin >> a[i];
  }
  vl yaku;
  REP(i,sqrt(a[0])+1){
    if(a[0]%(i+1)==0){
      yaku.push_back(i+1);
      yaku.push_back(a[0]/(i+1));
    }
  }
  REP(i,sqrt(a[1])+1){
    if(a[1]%(i+1)==0){
      yaku.push_back(i+1);
      yaku.push_back(a[1]/(i+1));
    }
  }
  ll ans;
  sort(yaku.begin(),yaku.end());
  REP(i,yaku.size()){
    ll cand = yaku[yaku.size()-1-i];
    ll cnt = 0;
    REP(j,n){
      if(a[j]%cand==0){
        cnt++;
      }
    }
    if(cnt>=n-1){
      ans = cand;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)

long long n;
long long a[20006];
long long k;
long long ans;
long long h[200006];
int main()
{
    cin>>n>>k;
    rep(i,n)cin>>h[i];

    sort(h,h+n);
    rep(i,n-k)
    {
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792