akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, m, a;
struct mint{
	static constexpr int mod = 1e9+7;
	int x;
	mint(ll x=0): x((x %= mod) < 0 ? x+mod : x){}
	mint operator-(){return mint(mod-x);}
	mint &operator+=(const mint &n){if((x += n.x) >= mod) x -= mod; return *this;}
	mint &operator-=(const mint &n){if((x += n.x) >= mod) x -= mod; return *this;}
	mint &operator*=(const mint &n){x = (ll)x * n.x % mod; return *this;}
	mint &operator/=(const mint &n){return *this *= n.inv();}
	mint &operator^=(const mint &n){
		mint ret{1}, tmp{x};
		for(int t = n.x; t; t >>= 1){
			if(t&1) ret *= tmp;
			tmp *= tmp;
		}
		return *this = ret;
	}
	mint inv() const{return *this ^ (mod - 2);}
	mint operator+(const mint &n){return mint(*this) += n;}
	mint operator-(const mint &n){return mint(*this) -= n;}
	mint operator*(const mint &n){return mint(*this) *= n;}
	mint operator/(const mint &n){return mint(*this) /= n;}
	mint operator^(const mint &n) const{return mint(*this) ^= n;}
} dp[1005];
mint exp(mint b, int n){
	mint res = 1;
	for(; n; n/=2,b*=b) if(n%2) res *= b;
	return res;
}
mint fact[1005] = {1}, invf[1005];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
	invf[n] =  fact[n].inv();
	for(int i = n; i > 0; i--) invf[i-1] = invf[i] * i;
}
inline mint comb(int a, int b){return fact[a] * invf[a-b] * invf[b];}
int main(){
	scanf("%d%d", &n, &m);
	dp[0] = 1;
	setcomb(n);
	rep(i,m){
		scanf("%d", &a);
		mint nw[1005] = {};
		rep(j,a+1) rep(k,n+1-j) nw[k+j] += dp[k] * comb(n-k,j) * comb(n-j,a-j);
		rep(j,n+1) dp[j] = nw[j];
	}
	printf("%d\n", dp[n].x);
}

Measured memory_bytes: 384
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    li = list(map(int, input().split()))

    cnt = 0
    frag = 0

    while True:
        for i in range(N):
            if li[i] % 2 == 1:
                frag = 1
                break

            else:
                li[i] = li[i] / 2

        if frag == 1:
            break

        cnt = cnt + 1

    print(cnt)


Measured memory_bytes: 3060
import sys

s = input()
if s[0] == "A" and s.count("C") == 1 and "C" in s[2:-1]:
    ss = set(s)
    ss.remove("A")
    ss.remove("C")
    SS = set([i.upper() for i in ss])
    if len(ss & SS) == 0:
        print("AC")
        sys.exit()

print("WA")

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B;cin>>A>>B;
	int sum = A+B;
	int subs = A-B;
	int prod = A*B;
	int res = max(sum,max(subs,prod));
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,a[100005],tmp;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	tmp=a[1];
	for(int i=2;i<=n;i++)tmp=tmp xor a[i];
	if(tmp==0)cout<<"Yes";
	else cout<<"No"; 
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

vector<int> a(4);
vector<int> S;
bool finish = false;

void calc(int n, int sign, int count) {
    if(finish) return;
    S.push_back(sign);
    if (count == 3) {
        if(n == 7) finish = true;
        return;
    }
    calc(n+a[count+1], 0, count+1);
    S.pop_back();
    calc(n-a[count+1], 1, count+1);
    S.pop_back();
    return;
}


int ctoi(char c) {
    return c-'0';
}

char digit_sign(int n) {
    if (n == 0) return '+';
    else return '-';
}

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    for (int i = 0; i < 4; ++i) a[i] = ctoi(s[i]);
    calc(a[0], 0, 0);
    char opt[3];
    for (int i = 0; i < 3; ++i) opt[i] = digit_sign(S[i+1]);
    for (int i = 0; i < 3; ++i) cout << a[i] << opt[i];
    cout << a[3] << "=7" << std::endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

const long long md = 1e9 + 7;

int n, m;
int a[205];
int dp[100005][205];
long long ans;
int cnt[100005];
int nxt[100005];

int main(int argc, const char * argv[]) {
//    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= m; ++i) {
        int l = 1;
        int r = n;
        while (l < r) {
            int mid = (l + r) >> 1;
            if (a[mid] > i) r = mid;
            else l = mid + 1;
        }
        if (a[r] > i) cnt[i] = n - r + 1;
    }
    dp[m][0] = 1;
    long long cur;
    for (int i = m; i > 0; --i) {
        for (int j = 1; j <= n && a[j] <= i; ++j)
            nxt[j] = i % a[j];
        for (int j = 0; j <= n; ++j) if (dp[i][j]) {
            if (j < cnt[i]) {
                cur = cnt[i] - j;
                cur *= dp[i][j];
                cur %= md;
                dp[i][j + 1] += cur;
                if (dp[i][j + 1] >= md) dp[i][j + 1] -= md;
            }
            for (int k = 1; k <= n && a[k] <= i; ++k) {
                dp[nxt[k]][j + 1] += dp[i][j];
                if (dp[nxt[k]][j + 1] >= md) dp[nxt[k]][j + 1] -= md;
            }
        }
        ans += dp[i][n] * 1ll * i;
        ans %= md;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 38784
#include <bits/stdc++.h>
using namespace std;
#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 ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int A,B,M;
    cin >> A >> B >> M;
    int mina = 1000000;
    int minb = 1000000;
    int a[100000],b[100000],c[100000],x[100000],y[100000];
    REP(i,A){
        cin >> a[i];
        if(a[i]<mina)mina = a[i];
    }
    REP(i,B){
        cin >> b[i];
        if(b[i]<minb)minb = b[i];
    }
    REP(i,M){
        cin >> x[i] >> y[i] >> c[i];
    }
    int mint = mina + minb;
    REP(i,M){
        if(a[x[i]-1]+b[y[i]-1]-c[i]<mint)mint = a[x[i]-1]+b[y[i]-1]-c[i];
    }
    cout << mint << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin>>x;
	for(ll i=-150;i<=150;i++){
		for(ll j=-150;j<=150;j++){
			if(pow(i,5)-pow(j,5)==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
} 

Measured memory_bytes: 4020
N = int(input())
I = input().split()
A = []
for i in range(N):
    A.append([int(I[i]),i,])

b = sorted(A,key=lambda A :A[0])

print(b[0][1]+1, end=" ")

if N > 2:
    for i in range(1,N-1):
        print(b[i][1]+1, end=" ")

if N > 1:        
    print(b[N-1][1]+1, end =" ")

Measured memory_bytes: 28660
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    int ans=0;
    if(a>=13)ans=b;
    else if(a>=6) ans=b/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n,a,b = map(int,input().split())
mod = pow(10,9)+7

def comb(n,x):
  numerator = 1
  for i in range(n-x+1,n+1):
    numerator = numerator * i % mod

  denominator = 1
  for j in range(1,x+1):
    denominator = denominator * j % mod
  d = pow(denominator,mod-2,mod)
  return numerator * d
a = comb(n, a)
b = comb(n, b)

print((pow(2,n,mod)-1-a-b)%mod)

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

import queue

n, m = map(int, input().split())
edges = []
graph = [ [] for _ in range(n) ]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    edges.append( (a, b) )

    graph[a].append(b)
    graph[b].append(a)

def bfs(u, v):
    is_visited = [ False ]*n
    que = queue.Queue() 
    is_visited[0] = True
    que.put(0)

    while not que.empty():
        cur = que.get()
        for adj in graph[cur]:
            if is_visited[adj]: continue
            if cur == u and adj == v: continue
            if cur == v and adj == u: continue
            is_visited[adj] = True
            que.put(adj)

    return all(is_visited)

ans = 0
for u, v in edges:
    if not bfs(u, v):
        ans += 1

print(ans)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

float t, x;

int main(void) {
  // Here your code !
  scanf("%f %f", &t, &x);
  
  printf("%f\n", t / x);

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int in[5],k;


	for(int i=0;i<5;i++){
		scanf("%d",&(in[i]));
	}
	scanf("%d",&k);

	if(in[4]-in[0]>k){
		printf(":\(\n");
		return 0;
	}
	printf("Yay!\n");
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int maxv=max(a,b);
    int minv=min(a,b);
    
    int sum=0;
    int l=1;
    for(int i=0;i<maxv;++i){
       l*=10;
       sum+=l*minv;
    }
    cout<<sum/10<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll n,i,j,k,c,f;
	string s,t,temp;
	cin>>s>>t;
	ll n1=s.length(),n2=t.length();
	ll cnt=0,mn=n1+1;
	for(i=0;i<=n1-n2;i++)
	{
	    cnt=0;
	    temp=s.substr(i,n2);
	    for(j=0;j<n2;j++)
	    {
	        if(temp[j]!=t[j])
	            cnt++;
	    }
	    mn=min(mn,cnt);
	}
	cout<<mn;
	return 0;
}


Measured memory_bytes: 3624
main(x,y,b,p,n,m){for(gets(&x);~scanf("%d%d%d%d",&x,&y,&b,&p);printf("%d\n",n<m?n:m))n=x*b+y*p,m=(x*(b>5?b:5)+y*(p>2?p:2))*4/5;exit(0);}

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

int main() {
  int N;
  std::cin >> N;

  std::vector<int> A(N);
  for (auto& a : A) {
    std::cin >> a;
  }

  std::vector<int> B(N);
  for (auto& b : B) {
    std::cin >> b;
  }

  std::vector<int> C(N - 1);
  for (auto& c : C) {
    std::cin >> c;
  }

  int result = 0;
  int prev_a = N;
  for (const auto& a : A) {
    result += B[a - 1];
    if (a == prev_a + 1) result += C[prev_a - 1];
    prev_a = a;
  }

  std::cout << result;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

w,a,b = li()

if a <= b <= a+w or b <= a <= b+w:
    print(0)
elif b > a:
    print(b - (a+w))
else:
    print(a - (b+w))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
    class Program
    {
        static void Main()
        {
            List<string> sss = new List<string>();string s;
            int a = int.Parse(Console.ReadLine());
            for(int b = 0; b < a; b++)
            {
                string c = Console.ReadLine();
                sss.Add(c);
            }
            for(int d = 0; d < 4; d++)
            {
              
                for(int e = 1; e < 14; e++)
                {
                    switch (d) {
                        case 0:s = "S " + e; break;
                        case 1: s = "H " + e; break;
                        case 2: s = "C " + e; break;
                        default: s = "D " + e;break;
                    }

                    for(int f = 0; f < sss.Count; f++)
                    {
                        if (s == sss[f]) break;
                        else if (sss.Count - 1 == f) Console.WriteLine(s);
                    }
                }
            }
        }
    }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t, u;
  cin >> s >> t >> u;
  string ans;
  ans.push_back(s[0] - 'a' + 'A');
  ans.push_back(t[0] - 'a' + 'A');
  ans.push_back(u[0] - 'a' + 'A');
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		int n = Integer.parseInt(str);
		str = input.readLine();
		String temp = str;
		while(temp.contains("()")){
			temp = temp.replace("()", "");
		}
		int r = temp.length() - temp.replace("(", "").length();
		int l = temp.length() - temp.replace(")", "").length();

		for(int i=0; i<r; i++){
			str = str + ")";
		}
		for(int i=0; i<l; i++){
			str = "(" + str;
		}


		System.out.println(str);
	}

}


Measured memory_bytes: 21332
Imports System

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim H As Integer = CInt(tmp(0))
        Dim N As Integer = CInt(tmp(1))
        Dim tmp2 As String() = Split(Console.ReadLine(), " ")
        Dim hit As Integer = 0

        For i As Integer = 0 To N - 1
            hit += tmp2(i)
        Next

        If H > hit Then
            Console.WriteLine("No")
        Else
            Console.WriteLine("Yes")
        End If

    End Sub

End Module


Measured memory_bytes: 20704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 3010;
int n, a[maxn];
ll dp[maxn][maxn];
int main()
{
    read(n);
    rep(i, 1, n) read(a[i]), dp[i][i] = a[i];
    rep(len, 2, n) rep(l, 1, n - len + 1) {
        int r = l + len - 1;
        dp[l][r] = max(-dp[l + 1][r] + a[l], -dp[l][r - 1] + a[r]);
    }
    printf("%lld\n", dp[1][n]);
    return 0;
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int N;
ll BIT[SIZE];
ll table[SIZE];
map<ll,int> MAP;

void add(int loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll getSum(int loc){

	ll sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

ll calc(int left,int right){
	return getSum(right)-getSum(left-1);
}

int main(){

	int first_N;
	ll K;
	scanf("%d %lld",&first_N,&K);

	ll sum = 0,tmp;
	vector<ll> V;
	V.push_back(0);

	for(ll i = 0; i < first_N; i++){

		scanf("%lld",&tmp);
		sum += tmp;
		table[i] = sum-(i+1)*K;
		V.push_back(table[i]);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(int i = 0; i < V.size(); i++){

		MAP[V[i]] = i+1;
	}

	N = V.size();

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

		BIT[i] = 0;
	}

	ll ans = 0;
	add(MAP[0],1);

	for(int i = 0; i < first_N; i++){

		ans += getSum(MAP[table[i]]);
		add(MAP[table[i]],1);
	}

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

	return 0;
}



Measured memory_bytes: 11544
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] A = new int [N];
        
        for(int i=0; i<K; i++){
            int d = sc.nextInt();
            for(int j=0; j<d; j++){
                A[sc.nextInt()-1]++;
            }
        }
        
        int sum =0;
        for(int i=0; i<N; i++){
            if(A[i] == 0){
                sum++;
            }
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 46308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int n = 5;
    vector<int> a(n);
    int saihaya = 9;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] % 10 != 0 && saihaya % 10 >= a[i] % 10)
            saihaya = a[i];
    }
    int sum = 0;
    int saihaya_flag = 1;
    rep(i, n)
    {
        if (a[i] != saihaya)
        {
            if (a[i] % 10 == 0)
            {
                sum += a[i];
            }
            else
            {
                sum += a[i] / 10 * 10 + 10;
            }
        }
        else
        {
            if (saihaya_flag == 1)
            {
                sum += saihaya;
                saihaya_flag = 0;
            }
            else
            {
                sum += a[i] / 10 * 10 + 10;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

CD = C * D // gcd(C, D)
A -= 1

A_div = A - (A // C + A // D - A // CD)
B_div = B - (B // C + B // D - B // CD)

print(B_div - A_div)

Measured memory_bytes: 38356
def main():
    def insertSort(A):
        N = len(A)
        for i in range(1,N):
            print(*A)
            val = A[i]
            j = i - 1
            while j >= 0 and A[j] > val:
                A[j+1] = A[j]
                j -= 1
            A[j+1] = val
        else:
            print(*A)

    N = int(input())
    A = [int(i) for i in input().split()]
    insertSort(A)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5984
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  string s; cin >> s; int n = s.size();
  ll an=0;
  for(int i=0; i<(1<<(n-1)); i++) {
    ll sm=0, nw=0;
    for(int j=0; j<n; j++) {
      nw=nw*10+(s[j]-'0');
      if (j!=n-1 && (i&(1<<j))) sm+=nw, nw=0;
    } sm += nw; an += sm;
    //cout << sm << endl; 
  }
  cout << an << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,U,V = map(int, input().split())
U -= 1
V -= 1
ns = defaultdict(set)
for _ in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add(v)
    ns[v].add(u)

def bfs(start, ng=None):
    from queue import deque
    q = deque([start])
    seen = [None] * n
    dist = [None] * n
    dist[start] = 0
    seen[start] = -1
    while q:
        u = q.pop()
        d = dist[u]
        for v in ns[u]:
            if seen[v] is None and (ng is None or v!=ng):
                seen[v] = u
                dist[v] = d + 1
                q.appendleft(v)
    return seen, dist
ps, du = bfs(U)
_, dv = bfs(V)
l = []
tmp = V
while tmp!=U:
    l.append(tmp)
    tmp = ps[tmp]
d = len(l)
l = l[::-1]
dist = d//2 if d%2 else d//2-1
ng = l[dist]
start = U if dist==0 else l[dist-1]
_, D = bfs(start, ng=ng)
if max(item for item in D if item is not None)==0:
    ans = dv[start] - 1
else:
    ans = -1
    for i,num in enumerate(D):
        if num is None:
            continue
        val = num + dv[start] - 1#((dv[num]-du[num])%2==1)
        ans = max(ans, val)
print(ans)

Measured memory_bytes: 126100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
//#define INF 1145141919810893//810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int long long 


signed main(){
    int N;
    cin >> N;
    int d=0,e=0;
    
    while(N>0){
        d=0,e=0;
        while(e<N){
            d++;
            e+=d;
        }
        cout << d<<endl;
        N-=d;
    }
	return 0;
}


Measured memory_bytes: 256
import sys
N,P=map(int,input().split())
N=list(input().split())
for i in range (len(N)):
    N[i]=int(N[i])%2
count1=N.count(1)
count0=N.count(0)
if count1<1 and P==1:
    print (0)
    sys.exit()
if count0==0 and count1<2 and P==0:
    print (0)
    sys.exit()
import math
count0_c=0
count1_c=0
if count0!=0:
    for k in range (0,count0+1):
        count0_c+=math.factorial(count0)/(math.factorial(k)*math.factorial(count0-k))
else:
    count0_c=1

if count1!=0:
    for j in range (0,count1//2+1-P):
        count1_c+=math.factorial(count1)/(math.factorial(2*j+P)*math.factorial(count1-2*j-P))
else:
    count1_c=1
print(int(count0_c*count1_c))


Measured memory_bytes: 3064
# ABC073 D - joisino's travel
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

inf = 10**18
dist = [[inf]*N for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    dist[A-1][B-1] = dist[B-1][A-1] = C

dist = floyd_warshall(dist)

ans = inf
for rr in permutations(r):
    cost = 0
    for i in range(R-1):
        cost += dist[rr[i]-1][rr[i+1]-1]
    if cost < ans:
        ans = cost
print(int(ans))

Measured memory_bytes: 15252
// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

int main() 
{
  fast();
 
  ll n;
  cin >> n;
  ll arr[n-1];
  ll ans = 0;
  f(i,0,n-1)
  {
  	cin >> arr[i];
  }
  ans += arr[0];
  f(i,1,n-1)
  {
  	ans += min(arr[i - 1], arr[i]);
  }
  cout << ans + arr[n - 2];
  return 0;
}

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

int N, M;
vector<vector<bool>> Graph(10, vector<bool>(10, false));

int dp[(1 << 10) + 1][10];
int rec(int bit, int v) {
    if (dp[bit][v] != -1) return dp[bit][v];

    if (bit == (1 << v)) {
        if (v == 0)
            return dp[bit][v] = 1;
        else
            return dp[bit][v] = 0;
    }

    int res = 0;

    int prev_bit = bit & ~(1 << v);

    for (int u = 0; u < N; ++u) {
        if (!(prev_bit & (1 << u))) continue;
        if (!Graph[u][v]) continue;
        res += rec(prev_bit, u);
    }

    return dp[bit][v] = res;
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        Graph[a][b] = true;
        Graph[b][a] = true;
    }

    for (int bit = 0; bit < (1 << N); ++bit) {
        for (int v = 0; v < N; ++v) {
            dp[bit][v] = -1;
        }
    }

    ll ans = 0;
    rep(i, N) ans += rec((1 << N) - 1, i);

    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
    int N;
    cin >>N;
    vector<int> result(N,0);
    int num;
    for(int i=1;i<=N;i++){
        cin >> num;
        result[num-1] = i;
    }
    for(int i=0;i<N-1;i++){
    cout <<result[i] << " ";
    }
    cout << result[N-1] <<endl;
    return 0;
}

Measured memory_bytes: 1152
def HB(A,B):
    hit=0
    blow=0
    for i in range(4):
        for j in range(4):
            if A[i]==B[j]:
                if i==j:
                    hit+=1
                else:
                    blow+=1
    return [hit,blow]
while True:
    try:
        A=input().split()
        B=input().split()
        print(HB(A,B)[0] , HB(A,B)[1] )
    except:
        break

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
long long ans,n,fuck;
vector<int>v;
int main(){
    //freopen("input.txt","r",stdin);
    scanf("%d",&n);
    for(int i = 0,a,b;i < n;i++){
    	scanf("%d%d",&a,&b);
    	ans-=b;
    	v.push_back(a + b);
    }
    sort(v.begin(),v.end());
    while(v.size()){
    	ans+=v.back();
    	v.pop_back();
    	if(v.size())v.pop_back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){

    vector<long long> position;
    vector<long long> distance;

    long long koma;
    long long pNum;

    cin >> koma >> pNum;

    for(long long i = 0; i < pNum; i++){
        long long tmp;
        cin >> tmp;
        position.push_back(tmp);
    }

    sort(position.begin(), position.end());

    for(long long i = 0; i < pNum - 1; i++){
        distance.push_back(abs(position[i] - position[i + 1]));
        //cout << distance[i];
    }


    sort(distance.begin(), distance.end(), std::greater<long long>());

    long long sum = 0;

    for(long long i = koma - 1; i < distance.size(); i++){
        sum += distance[i];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <queue>
#include <iomanip>
using namespace std;

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

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

const int INF = 1000;

#define MAX_R 51
#define MAX_C 51 

int h, w, sx, sy, gx, gy;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
char maze[MAX_R][MAX_C];
int d[MAX_R][MAX_C];

void show_maze(){
  rep1(i, h){
    rep1(j, w){
      if(d[i][j] == INF)
        cout << " .";
      else 
        cout << setfill(' ') << setw(2) << right << d[i][j];
    }
    cout << endl;
  }
}

void show_maze2(){
  rep1(i, h){
    rep1(j, w){
      cout << setfill(' ') << setw(2) << right << maze[i][j];
    }
    cout << endl;
  }
}

int bfs(){
  queue<P> que;
  rep1(i, h) rep1(j, w) d[i][j] = INF;
  
  que.push(P(sx, sy));
  d[sx][sy] = 0;
  
  while(que.size()){
    P p = que.front(); que.pop();
    
    if(p.first==gx && p.second==gy) break;
    
    rep(i, 4){ 
      int nx = p.first + dx[i], ny = p.second + dy[i];
      
      if(0<nx && nx<=h && 0<ny && ny<=w && maze[nx][ny]!='#' && d[nx][ny]==INF){
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  return d[gx][gy];
}

int main() {
  cin >> h >> w;
  sx = 1, sy = 1, gx = h, gy = w;
  int white = 0;
  rep1(i, h){ 
    rep1(j, w){ 
      cin >> maze[i][j];
      if(maze[i][j] == '.') white++; 
    }
  }
  
  int min_d = bfs();
  int res = white -  1 - min_d;
  
  // show_maze(); cout << endl;
  // show_maze2(); cout << endl;
  
  cout << (min_d!=INF ? res : -1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){if((ll)(a)==inf)cout<<"inf"<<'\n';else if((ll)(a)==-inf)cout<<"-inf"<<'\n';else cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';if((ll)(v[i])==inf)cout<<"inf";else if((ll)(v[i])==-inf)cout<<"-inf";else cout<<(ll)(v[i]);}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    string s;cin>>s;
    YesNo(s!="AAA"&&s!="BBB");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int n;
    cin >> n;
    int h[n];
    rep(i, 0, n) cin >> h[i];

    ll dp[n + 1];
    rep(i, 0, n + 1) dp[i] = INF;
    dp[0] = dp[1] = 0;

    rep(i, 1, n) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i - 1] - h[i]));
        if(i + 2 <= n) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i - 1] - h[i + 1]));
        }
    }

    cout << dp[n] << endl;


}


Measured memory_bytes: 1408
object Main {
  def main(args: Array[String]): Unit = {
    var max_acgt_length = 0
    val input_str = io.StdIn.readLine()

    (0 until input_str.length).foreach{ i =>
      var acgt_length = 0
      var flag        = true

      while(flag) {
        if("ACGT".contains(input_str(i + acgt_length))) {
          acgt_length += 1
        }
        else {
          flag = false
        }

        if(i + acgt_length >= input_str.length) {
          flag = false
        }
      }
      if(acgt_length > max_acgt_length) max_acgt_length = acgt_length
    }
    println(max_acgt_length)
  }
}

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

using namespace std;

int main(){
	int i,n;
	char s[101];
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2 == 1){
		printf("No\n");
		return 0;
	}
	else{
		for(i=0;i<n/2;i++){
			if(s[i] != s[n/2+i]){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

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

    return 0;
}

Measured memory_bytes: 3440
#include<stdio.h>

main(){

int a,b,r,d;
double f1,f2;

scanf("%d %d",&a,&b);

r = a / b;
d = a % b;

f1 = 1.0 * a;
f2 = f1 / b;

printf("%d %d %.8lf\n",r,d,f2);

return 0;
} 


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n; cin>>n;
int a[n];
rep(i,n) cin>>a[i];
//入力
map<int,bool> m;
int count = 0;
int MI=0,MX=0,ans=0;
rep(i,n){
    if(a[i] >=3200) count++;//3200以上の数
    else if(!m[a[i]/400]) ans++;//各色の数 
    m[a[i]/400] =true;//重複避け
}
if(ans==0){
    cout<<1<<" ";
}else
{
    cout<<ans<<" ";
}//3200以上のみだったら1それ以外ならいる色の数が最小

cout<<ans+count<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int len;

void funcJ(){
  if(len==1)return;
  char tmp=s[len-1];
  for(int i=len-1;i>0;i--)s[i]=s[i-1];
  s[0]=tmp;
}

void funcC(){
  if(len==1)return;
  char tmp=s[0];
  for(int i=0;i+1<len;i++)s[i]=s[i+1];
  s[len-1]=tmp;
}

void funcE(){
  if(len==1)return;

  if(len%2){
    s=s.substr(len/2+1,len/2)+s[len/2]+s.substr(0,len/2);
  }else{
    s=s.substr(len/2,len/2)+s.substr(0,len/2);
  }
}

void funcA(){
  reverse(s.begin(),s.end());
}

void funcP(){
  for(int i=0;i<len;i++){
    if(s[i]=='0'){
      s[i]='9';
    }else if('1'<=s[i]&&s[i]<='9'){
      s[i]--;
    }
  }
}

void funcM(){
  for(int i=0;i<len;i++){
     if(s[i]=='9'){
       s[i]='0';
     }else if('0'<=s[i]&&s[i]<='8'){
       s[i]++;
     }
  }
}

int main(){
  int n;
  string A;
  cin>>n;
  while(n--){
    cin>>A>>s;
    len=s.size();
    reverse(A.begin(),A.end());
    for(int i=0;i<(int)A.size();i++){
      if(A[i]=='M')funcM();
      if(A[i]=='P')funcP();
      if(A[i]=='A')funcA();
      if(A[i]=='E')funcE();
      if(A[i]=='C')funcC();
      if(A[i]=='J')funcJ();
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int a, b, c, k; cin >> a >> b >> c >> k;
  if(k < a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else cout << a - (k-a-b) << endl;
  return 0;
}

Measured memory_bytes: 3624
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())

class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(N+M)
for i in range(N):
    KL = list(map(int,input().split()))
    for L in KL[1:]:
        uf.unite(i,L+N-1)
ans = "YES"
for i in range(1,N):
    if not uf.same(0,i):
        ans = "NO"
print(ans)

Measured memory_bytes: 76932
#include<iostream>
#include<vector>
#include<complex>
#include<cstdio>

using namespace std;

#define X real()
#define Y imag()

int main(){
	typedef complex<double> P;
	
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	P padding = P(a,b);
	P p1 = P(0,0);
	P p2 = P(c-a, d-b);
	
	P e = p2 / abs(p2);
	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int g,h;
		cin>>g>>h;
		
		P q = P(g,h) - padding;
		
		double len = q.X*e.X + q.Y*e.Y;
		P ans = (e*len + padding);
		
		printf("%.10lf %.10lf\n",ans.X, ans.Y);
		
	}
	
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n;
    ll t;
    cin >> n >> t;
    ll sum = 0, ma = 0;
    for(int i = 0; i < n; i++){
        ll x;   cin >> x;
        ma = max(ma, x);
        sum += x;
        if(t < sum){
            cout << 1 << endl;
        }else{
            cout << (t-sum)/ma+1+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  double t,a;
  double h,sa;
  double min = 1000000001.0;
  int min_i;
  cin >> n >> t >> a;
  for(int i=0; i<n; i++){
    cin >> h;
    h = t - (h * 0.006);
    sa = abs(a - h);
    if(sa < min) {
      min = sa;
      min_i = i + 1;
    }
  }
  cout << min_i << endl;
  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<char> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> S;
    fi(i, 0, S.size(), 1) {
    	s.insert(S[i]);
    }
    if(s.size() == S.size()) {
    	cout << "yes\n";
    	quit;
    }
    cout << "no\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////


int main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,n){
        if((i+1)%2==0)continue;
        if(a[i]%2==1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> A, B;
	for (int i = 0; i < N; i++){
		int At, Bt;
		cin >> At >> Bt;
		A.push_back(At);
		B.push_back(Bt);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	if (N % 2){
		cout << B[N/2] - A[N/2] + 1 << endl;
	} else {
		cout << B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 4924
/*author:revolIA*/
/*明日を変えるなら今日変えなきゃ*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
int A[maxn];
int vis[maxn];
int n,ans = 1;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&A[i]);
    vis[0] = 3;
    for(int i=1;i<=n;i++){
        ans = (1LL*ans*(vis[A[i]]-vis[A[i]+1]))%mod;
        vis[A[i]+1]++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
d = {}
for i in range(n):
    s = sorted(list(input()))   
    s = ''.join(s)
    d[s] = d.get(s, 0) + 1

cnt = 0
for k,v in d.items():
    if v >= 2:
        cnt += v * (v - 1) // 2 # 組の個数

print(cnt)


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
int N;
VL a, b, p;

int main() {
    cin >> N;
    p.resize(N);
    a.resize(N);
    b.resize(N);
    VECCIN(p);
    REP(i, N) a[i] = 20000 * i + 1;
    REP(i, N) {
        b[N - 1 - i] += 20000 * i + 1;
        b[p[i] - 1] += i;
    }
    FOREACH(x, a) cout << x << " ";
    cout << "\n";
    FOREACH(x, b) cout << x << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1152
N = int(input())
red = []
blue = []
for i in range(N):
    red.append(list(map(int, input().split()))+[0])
for i in range(N):
    blue.append(list(map(int, input().split())))
blue.sort()
res = 0
for x in blue:
    tar = [-1, -1, 0]
    for y in red:
        if y[2] == 0 and y[0] < x[0] and y[1] < x[1] and y[1] > tar[1]:
            tar = y

    if tar[0] >= 0:
        res += 1
        for i in range(N):
            if red[i] == tar:
                red[i][2] = 1
                break

print(res)


Measured memory_bytes: 3064