akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> res,a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n-1){
        if(a[i] < a[i+1])res.push_back(0);
        else res.push_back(1);
    }
    int ret = 0;
    n--;
    for(int i = 0,j;i < n;i = j){
        for(;i < n &&res[i] == 0;i++);
        if(i == n)break;
        for(j = i+1;j < n && res[j] == 1;j++);
        ret = max(ret,j-i);
        // trace(i,j);

    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
 
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);
 
using namespace std;
 
int main()
{
	IOS;
	int k,n;
	cin>>k>>n;
	int ma=0;
	for (int j=1;j<=n;++j)
	{
		int x;
		cin>>x;
		ma=max(ma,x);
	}
	int ans=max(0,ma-(k-ma)-1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N; cin >> N;
    string ans;
    do {
        if(N%2) {
            ans = "1"+ans;
            N -= 1;
        } else {
            ans = "0"+ans;
        }
    } while(N/=-2);
    cout << ans;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  
  for (int j=0;j<N;j++) {
    int x=0;
  
    for (int i=0;i<M;i++) {
      cin >> a.at(i) >> b.at(i);
      
      if(a.at(i)==j+1||b.at(i)==j+1) {
        x++;
      }
    }
      cout << x << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();
            int n = cin.NextInt();
            int[] a = cin.ArrayInt(n);
            int x = 0;
            for(int i = 0; i < n; i++)
            {
                if (a[i] % 2 == 0)
                {
                    a[i] /= 2;
                    if (i == n - 1)
                    {
                        i = 0;
                        x++;
                    }
                }
                else
                {
                    Console.WriteLine(x);
                    break;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



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

int main() {
	int r, c;
	int temp;
	int matrix[100][100], row_sum[100], col_sum[100];

	for(int i=0; i<100; i++) {
		for(int j=0; j<100; j++) {
			matrix[i][j] = 0;
		}
		row_sum[i] = 0;
		col_sum[i] = 0;
	}

	cin >> r >> c;
	for(int i=0; i<r; i++) {
		for(int j=0; j<c; j++) {
			cin >> temp;

			row_sum[i] += temp;
			col_sum[j] += temp;
			matrix[i][j] = temp;
		}
	}

	for(int i=0; i<r; i++) {
		for(int j=0; j<c; j++) {
			cout << matrix[i][j] << " ";
		}
		col_sum[c] += row_sum[i];
		cout << row_sum[i] << endl;
	}

	for(int i=0; i<=c; i++) {
		if(i==c) {
			cout << col_sum[i] << endl;
		}else{
			cout << col_sum[i] << " ";
		}
	}

	return 0;
}


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


int main() {
  int N ;
  cin >> N ; 
  vector<int> vec(N)  ;
  vector<int> vec2(N) ; 
  
  for (int i = 0 ; i < N ; i++){
    cin >> vec.at(i) ; 
    vec2.at(i) = vec.at(i) ; 
  }
 
  sort(vec.begin(), vec.end()) ; 

  
  for(int i = 0 ; i < N ; i++){
    
    if(vec2.at(i) == vec.at(N-1)){
      cout << vec.at(N-2) << endl ; 
    }
    else {
      cout << vec.at(N-1) << endl ; 
    }
    
  }
  
}

Measured memory_bytes: 4840
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
//  配列の最大の大きさ
#define MAX_LENGTH  200010

typedef struct{
    int array[MAX_LENGTH];
    int first;
    int last;
}QUEUE;

void init(QUEUE*);
int enqueue(QUEUE*,int);
int dequeue(QUEUE*,int*);
struct touple { int a; int b; };
int cmp_touple(const void*n1, const void*n2);
int bisect_left(int x,struct touple a[],int left,int right);

int main(void){
    int N,M;
    scanf("%d%d", &N,&M);
    struct touple *ts = (struct touple *)malloc((M*2)*sizeof(struct touple));
    for (int i = 0; i < M; i++) {
        int x,y;
        scanf("%d%d", &x,&y);
        ts[i].a = x;ts[i].b = y;
        //逆辺も入れとく
        ts[i+M].a = y;ts[i+M].b = x;
    }
    //ts[i][0] の値(toupleの左側の値でソート)
    qsort(ts,2*M,sizeof (ts), cmp_touple);
    // その部屋が指し示してる方向
    int *direction = (int *)malloc((N+1) * sizeof(int));
    //全部　-1 にセット, -1なら未到達　それ以外は到達の意味
    memset(direction,0xFF,sizeof(int)*(N+1));
    //以下bfs やる
    //queueには処理する部屋の順(頂点)が詰まってる
    QUEUE q;
    //初期設定
    init(&q);
    enqueue(&q,1);
    //1番目の部屋には到達した
    direction[1] = 0;
    while (q.first != q.last){
        //queueの頭から一個取り出す
        int v;
        dequeue(&q,&v);
        //tsから 左側が vとなっているindexをサーチして下のforで使う
        int index1 = bisect_left(v,ts,0,(2*M)-1); 
        int index2 = bisect_left(v+1,ts,0,(2*M)-1); 
        //printf("%d %d index\n",index1,index2);
        // 計算量は一番深いのがこの一個したのネストでO(Mlog(M)+N)
        for (int index = index1; index < index2; index++) {
            int nv = ts[index].b;
            // nvは新しい頂点(行ける頂点)
            if (direction[nv] != -1) continue;//到達しているのでいらん
            direction[nv] = v;//普通 direction[nv] = direction[v] + 1で距離見る
            enqueue(&q,nv);
        }
    }
    // direction をうまいこと出力
    printf("Yes\n");
    for (int i = 2; i <= N; i++) {
        printf("%d\n",direction[i]);
    }
}

int bisect_left(int x,struct touple a[],int left,int right){
    //二分して挿入点を ts[i].a  から探す, できるだけ左のindexを返す
    // 1,2,2,3,4 に2をいれるなら 1,here,2,2,3,4 と挿入点を見つける.
    int mid; right++;
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid].a < x) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}

int cmp_touple(const void*n1, const void*n2){
    return ((struct touple*)n1)->a - ((struct touple*)n2)->a;
    // toupleのaの方でソート
}

//  スタックの初期化
void init(QUEUE* pQueue)
{
    int i;
    for(i = 0; i < MAX_LENGTH; i++){
        pQueue->array[i] = 0;
    }
    //  最初と最後の位置を先頭に。
    pQueue->first = 0;
    pQueue->last = 0;
}
//  値のプッシュ
int enqueue(QUEUE* pQueue,int value)
{
    pQueue->array[pQueue->last] = value;          // キューに新しい値を入れる
    pQueue->last = (pQueue->last + 1) % MAX_LENGTH;   // lastの更新
    return 1;
}
//  値のポップ
int dequeue(QUEUE* pQueue,int* pValue)
{
    *pValue = pQueue->array[pQueue->first];           // いちばん先頭のキューを返す準備
    pQueue->first = (pQueue->first+1) % MAX_LENGTH;   // キューの先頭を次に移動する
    return 1;
}



Measured memory_bytes: 7704
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int q; cin >>q;
  vector<vector<int>> dp;
  rep(query, q){
    string s,t; cin >>s >>t;
    int n = s.size(), m = t.size();
    dp.assign(n+1, vector<int>(m+1, 0));
    // dp[i][j]...sのi文字目まで、tのj文字目までの最長共通部分列の長さ
    for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
        if (s.at(i) == t.at(j)) chmax(dp[i+1][j+1], dp[i][j] + 1);
        chmax(dp[i+1][j+1], dp[i][j+1]);
        chmax(dp[i+1][j+1], dp[i+1][j]);
      }
    }
    cout <<dp[n][m] <<endl;
  }
}



Measured memory_bytes: 6788
program ABC174C
    implicit none
    integer(8)::K,L,i,mod0,mod_ans,flg=0,larger=0
    read*,K
    if(mod(K,2)==0.or.mod(K,5)==0)then
        print'(i0)',-1
    else
        if(mod(K,7)==0)then
            L=9*K/7
        else
            L=9*K
        end if

        do i=0,9000000
            if(10**i>=L.and.larger==0)larger=1
            if(i==0)then
                mod_ans=mod(1,L)
            else
                mod_ans=mod(mod0*10,L)
            end if
            if(larger==1.and.mod_ans==1)then
                flg=1
                exit
            end if
            mod0=mod_ans
        end do
        if(flg==1)print'(i0)',i
        if(flg==0)print'(i0)',-1
    end if
end program ABC174C

Measured memory_bytes: 2904
#include<queue>
#include<cstdio>
using namespace std;
const int maxn = 1e5 + 5;

queue<int>que;
vector<int>vec[maxn];
int in[maxn],ans[maxn];

int main(){
	int n, m;
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i = 1 ; i <= m ; i++){
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		in[v]++;
	}
	for(int i = 1 ; i <= n ; i++){
		if(in[i] == 0){
			que.push(i);
			ans[i] = 0;
		}
	}
	int now;
	while(!que.empty()){
		now = que.front();que.pop();
		int len = vec[now].size();
		for(int i = 0 ; i < len ; i++){
			in[vec[now][i]]--;
			if(in[vec[now][i]] == 0){
				que.push(vec[now][i]);
				ans[vec[now][i]] = ans[now] + 1;
			}
		}
	}
	int cnt = 0;
	for(int i = 1 ; i <= n ; i++)cnt = max(cnt, ans[i]);
	printf("%d\n",cnt);
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, m, arr[nax], ans=0;
vector<ll>v;
	
bool cmp(ll a, ll b){
		return a>b;
	}	
	
int main(){
	IOS
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> arr[i];
	}
	if(n>=m){
		cout << 0 << '\n';
		return 0;
	}
	sort(arr, arr+m);
	for(int i=1;i<m;i++){
		v.pb(arr[i]-arr[i-1]);
		ans+=arr[i]-arr[i-1];
	}
	if(v.empty()){
		cout << 0 << '\n';
		return 0;
	}
	sort(v.rbegin(), v.rend());
	for(int i=0;i<n-1;i++){
		ans-=v[i];
	}
	if(ans<0){
		cout << 0 << '\n';
		return 0;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5052
n,a=int(input()),sorted(list(map(int,input().split())))
m,s=a[-1],[0]*(a[-1]+1)
for i in a:s[i]+=1
for i in set(a):
	if s[i]:
		for j in range(i*2,m+1,i):s[j]=0
print(s.count(1))

Measured memory_bytes: 40036
#include <stdio.h>
#include <array>
#include <vector>
using lli = long long int;

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

constexpr int mod = 1e9 + 7;
constexpr int N = 60;
std::vector<lli> A;
std::array<int, N> Count;

inline bool bitUP(lli bit, int k){
    return (bit >> k) & 1;
}

int main(void){
    int n; scanf("%d", &n);
    A.resize(n);
    REP(i, n) scanf("%lld", &A[i]);
    lli res = 0;
    REP(i, n){
        REP(j, N){
            lli p = (1LL << j) % mod;
            if(bitUP(A[i], j)){
                (res += (i - Count[j]) * p) %= mod; Count[j]++;
            }
            else (res += Count[j] * p) %= mod;
        }
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 2560
N, K = map(int, raw_input().split())
x = map(int, raw_input().split())
ans = 10**9
for y in range(N-K+1):
    left = x[y]
    right = x[y+K-1]
#    print left, right                                                                                                                                    

    if left < 0 and right <= 0:
        ans = min(ans, -left)
    elif left <= 0 and right >= 0:
        ans = min(ans, -2*left+right, -left+2*right)
    else:
        ans = min(ans, right)

if ans == 10**9:
    print 0
else:
    print ans





Measured memory_bytes: 11344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[3];
    rep(i,3)cin>>a[i];
    int l[n];
    rep(i,n)cin>>l[i];
    int all=pow(4,n);
    int ans=inf;
    rep(i,all){
        int cur=i;
        int use[n];
        rep(j,n){
            use[j]=cur%4;
            cur/=4;
        }
        vector<int> sum(3),cnt(3);
        rep(j,n){
            if(use[j]!=3){
                sum[use[j]]+=l[j];
                cnt[use[j]]++;
            }
        }
        int ret=0;
        rep(j,3){
            ret+=abs(a[j]-sum[j]);
            ret+=(cnt[j]-1)*10;
            if(!cnt[j])ret+=1e7;
        }
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll fact[220010];


ll rev(int a){
	ll ans=1;
	ll b=a;
	ll n=MOD-2;
	while(n){
		if(n&1)
			ans=(ans*b)%MOD;
		b=(b*b)%MOD;
		n >>=1;
	}
	return (ans+MOD)%MOD;
}

ll com(ll n,ll m){
	ll ans=1;
	//while(m){
	//	ans=((ans*n%MOD)*rev(m))%MOD;
	//	n--;
	//	m--;
	//}
	ans=(fact[n]*rev(fact[m]))%MOD*rev(fact[n-m])%MOD;
	return (ans+MOD)%MOD;
}
int main(void){
	fact[0]=1;
	for(int i=1;i<=220000;i++)
		fact[i]=(fact[i-1]*i)%MOD;
	int N,M,K;
	cin >> N >> M >> K;
	ll ans=0;
	for(int p=0;p<=K;p++){
		int q=K-p;
		ll a=((com(N+2*p,p)*(N+1))%MOD*rev(N+p+1))%MOD;
		ll b=((com(M+2*q,q)*(M+1))%MOD*rev(M+q+1))%MOD;
		ll c=(com(M+N+2*K,N+2*p))%MOD;
		ans=(ans+((a*b)%MOD*c)%MOD)%MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2884
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  while(cin >> n){
    int res = 0;
    rep(i, 10){
      rep(j, 10){
        rep(k, 10){
          rep(l, 10){
            if(i + j + k + l == n)res++;
          }
        }
      }
    }
    cout << res << endl;
  }
	return 0;
}



Measured memory_bytes: 3008
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);

        String[][] box = new String[3][3];

        for(int i=0; i<3; i++) {
        	String[] line = sc.next().split("");
        	for(int j=0; j<3; j++) {
        		box[i][j] = line[j];
        		if(i==j) {
        			System.out.print(box[i][j]);
        		}
        	}
        }

        sc.close();
    }
}

Measured memory_bytes: 22996
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

def main():
    N, A, B, C, D = map(int, input().split())

    for i in range(1,N):
        if C*(N-1-i) - D*i <= B - A <= D*(N-1-i) - C*i:
            print("YES")
            return

    print("NO")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from collections import Counter
n=int(input())
v = list(map(int,input().split()))

# count value
oc = Counter(v[::2]).most_common(2)
ec = Counter(v[1::2]).most_common(2)

# oとeの最頻値が異なる場合、n-各最頻値の数が答え
if oc[0][0] != ec[0][0]:
    print(n - oc[0][1] - ec[0][1])
else:
    if len(oc) == 1 or len(ec) == 1:
        print(n//2)
    else:
        print(n - max((oc[0][1] + ec[1][1]), (ec[0][1] + oc[1][1])))


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 2000011

signed main()
{
  int n;
  cin >> n;
  int n1 = n % 10;
  n = n / 10;
  int n2 = n % 10;
  n = n / 10;
  int n3 = n % 10;
  n = n / 10;
  (n1 == 7 || n2 == 7 || n3 == 7) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}

Measured memory_bytes: 3636
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;
int main(void){
  int n,k;
  cin >> n >> k;

  long double sum=0;
  for(int i=1;i<=n;i++){
    int p=0;
    while(i*powl(2,p)<=(k-1)){
      p++;
    }
    //cout << i << ":"<<p <<"\n";
    sum=sum+pow(1.0/2,p);
    //cout <<"sum " <<  i << ":" << sum << "\n";
  }
  long double ans=1.0*sum/n;
  cout << std::setprecision(10)<<ans;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <bitset>
#include <set>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll k;
	set<ll> st;
	for(ll i=0; i<n; i++){
		cin >> k;
		auto it = st.find(k);
		if(it == end(st))
			st.insert(k);
		else
			st.erase(k);
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 8248
import sys


def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    di = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

    for _ in range(N):
        di[input()] += 1

    for k, v in di.items():
        print(f"{k} x {v}")


if __name__ == "__main__":
    main()


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

int main(void) {
	int n,i,j,lp,ap;
	int id,cost,number,ef;
	long s;

	while (scanf("%d",&n)!=EOF) {
		if (!n) break;
		int *list = (int *)calloc(n,sizeof(int));
		long *sum = (long *)calloc(n,sizeof(long));
		int *all = (int *)calloc(n,sizeof(int));
		long *asum = (long *)calloc(n,sizeof(long));
		ap = lp = 0;
		for (i=0;i<n;i++) {
			scanf("%d %d %d",&id,&cost,&number);
			ef = 0;
			s = 0;
			for (j=ap-1;j>=0;j--) {
				if (all[j]==id) {
					if (asum[j]>=1000000) {
						ef = 1;
						break;
					}
					s = asum[j];
					break;
				}
			}
			if (ef) continue;
			for (j=0;j<number;j++) {
				s += cost;
				if (s>=1000000) {
					list[lp] = id;
					sum[lp++] = s;
					break;
				}
			}
			all[ap] = id;
			asum[ap++] = s;
		}
		if (lp) {
			for (i=0;i<lp;i++) printf("%d\n",list[i]);
		} else {
			puts("NA");
		}
		free(asum);
		free(all);
		free(sum);
		free(list);
	}
	
	return 0;
}

Measured memory_bytes: 644
s=str(input())
t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if len(s)!=26:
  s=list(s)
  for i in range(26):
    if t[i] not in s:
      s.append(t[i])
      break
  print("".join(s))
else:
  if "".join(s)=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
  else:
    a=[]
    for i in range(26):
      a.append(s[25-i])
      for j in a:
        if s<s[:25-i]+j:
          print(s[:25-i]+j)
          exit()

Measured memory_bytes: 9116
#include<stdio.h>

void trace(int A[],int N){
	int i;
	for (i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");		 
}
void insertionsort(int A[],int N){
	int i,j,t;
	for(i=0;i<N;i++){
		t=A[i];
		j=i;
		while(j>0&&A[j-1]>t){
			A[j]=A[j-1];
			j--;
		}
	A[j]=t;
	trace(A,N);
	}
}

int main(){
	int N,i,j;
	int A[100];
	
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	insertionsort(A,N);
	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
const int N = 303030;
#define ll long long
#define fi first
#define se second
const ll mod = 1e9 + 7;
typedef pair<int, int> ii;
ll m, n, k, t, fact[N], invfact[N];
ii a[N];

ll power(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * x) % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return res;
}

ll cnk(ll n, ll k)
{
    return (((fact[n] * invfact[k]) % mod) * invfact[n - k]) % mod;
}

int main()
{
    //freopen("DPGRRB2.inp", "r", stdin);
    //freopen("DPGRRB2.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin >> m >> n >> k;
    //chuan bi mang fact[] va invfact[] de phuc vu tinh c(n, k) trong O(1)
    t = m + n + 1;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= t; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = power(fact[i], mod - 2, mod);
    }
    //so cach di tu o (0,0) den o (x,y) se bao gom x lan di xuong va y lan sang phai
    //nen so cach di se la chon ra x lan di xuong bat ky trong x+y buoc di
    //nen dap an theo toan TO HOP se la C(x+y, x)
    for (int i = 1; i <= k; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + 1 + k);
    a[++k] = {m, n};
    vector<ll> dp(k + 2, 0);
    for (int i = 1; i <= k; i++)
    {
        dp[i] = cnk(a[i].fi + a[i].se - 2, a[i].fi - 1);
        //Neu co mot o j nam tren duong di tu o (0,0) den o i
        //thi duong di den o i se bi giam di mot luong la so duong di ma di qua o j
        //so duong di qua o j nay  = soduongdi_deno_j * soduongdituo_j_deno_i;
        for (int j = 1; j < i; j++)
            if (a[j].se <= a[i].se)
            {
                int x = a[i].first - a[j].first;
                int y = a[i].second - a[j].second;
                dp[i] = (dp[i] - dp[j] * cnk(x + y, x) + mod * mod) % mod;
            }
    }
    cout << dp[k];
    return 0;
}

Measured memory_bytes: 4608
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let x:Vec<f64> = (0..n).map(|_| read()).collect();
    let y:Vec<f64> = (0..n).map(|_| read()).collect();
    let xy: Vec<_> = x.iter().zip(y.iter()).collect();
    for &p in [1.0, 2.0, 3.0].iter() {
        println!("{}", xy.iter().fold(0.0, |acc, &(x,y)| acc + (x - y).abs().powf(p)).powf(1.0 / p));
    }
    println!("{}", xy.iter().fold(0.0, |acc, &(x, y)| if acc > (x - y).abs() { acc } else { (x - y).abs() }));
}


Measured memory_bytes: 5204
n = gets.to_i
v = gets.chomp.split(' ').map{ |v| v.to_i }
c = gets.chomp.split(' ').map{ |v| v.to_i }

diff = 0
n.times {|i|
    diff += v[i] - c[i] if v[i] > c[i]
}

puts diff

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int s,w;
	cin >> s >> w;
	print1(w>=s?"unsafe":"safe");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    pair<int,int> cnt[2][100001];
    cin >> n;

    for(int i=0;i<=100000;i++) cnt[0][i]=cnt[1][i]=make_pair(0,i);
    for(int i=0;i<n;i++){
        int v;
        cin >> v;
        cnt[i%2][v].first--;
    }
    sort(cnt[0],cnt[0]+100001);
    sort(cnt[1],cnt[1]+100001);
    if(cnt[0][0].second!=cnt[1][0].second){
        cout << n+cnt[0][0].first+cnt[1][0].first << endl;
    }else{
        cout << min(n+cnt[0][0].first+cnt[1][1].first,n+cnt[0][1].first+cnt[1][0].first) << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    if (A == B &&B== C)cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>

class edge{
public:
  int u, v;
  edge(int u, int v): u(u<v?u:v), v(u<v?v:u){};
  bool operator< (const edge& o)const{
    if(u!=o.u) return u<o.u;
    return v<o.v;
  }
  bool operator== (const edge& o)const{
    return u==o.u && v==o.v;
  }
};

int main(void){

  int n;
  std::cin >> n;
  std::vector<std::vector<std::pair<int, bool> > > edges(n+2, std::vector<std::pair<int, bool> >());
  for(int i=1; i<n; i++){
    int u,v;
    long w;
    std::cin >> u >> v >> w;
    edges[u].push_back(std::make_pair(v, w%2==0));
    edges[v].push_back(std::make_pair(u, w%2==0));
  }

    int now = -1;
  for(int i=1; i<=n; i++){
    if(edges[i].size() == 1){
      now = i;
      break;
    }
  }

  std::vector<int> color(n+2, -1);

  std::queue<std::pair<int, int> > q;

  color[now] = 0;
  q.push(std::make_pair(now, 0));
  while(q.size() != 0){
    std::pair<int, int> temp = q.front();
    q.pop();

    for(auto elem: edges[temp.first]){
      if(color[elem.first] == -1){
        color[elem.first] = elem.second?temp.second:(temp.second+1)%2;
        q.push(std::make_pair(elem.first, color[elem.first]));
      }
    }
  }

  for(int j=1; j<=n; j++){
    std::cout << color[j] << std::endl;
  }



  return 0;
}


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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int c, x, ans;
    x = 0;
    ans = 0;
    c = fmin(a, b);
    while (x < k){
        if (a % c == 0 & b % c == 0){
            x += 1;
            ans = c;
        }
        c--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
struct SegmentTree
{
  vector< int > seg, lazy;
  int sz;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, -114514);
  }
 
  void push(int k, int l, int r)
  {
    if(lazy[k] != -114514) {
      seg[k] = lazy[k] * (r - l);
      if(k < sz - 1) lazy[2 * k + 1] = lazy[2 * k + 2] = lazy[k];
      lazy[k] = -114514;
    }
  }
 
  void update(int a, int b, int x, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      push(k, l, r);
      return;
    }
    update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
  }
 
  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }
 
  int query(int a, int b, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) + query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }
 
  int query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};
 
int main()
{
  int N;
  string S;
 
  cin >> N;
  cin >> S;
 
  SegmentTree tree1(N), tree2(N - 1);
  for(int i = 0; i < N; i++) {
    tree1.update(i, i + 1, S[i] == '1');
  }
  for(int i = 0; i < N - 1; i++) {
    tree2.update(i, i + 1, S[i] == '1' && S[i + 1] == '1');
  }
 
  int Q;
  cin >> Q;
  while(Q--) {
    int L, R, B;
    cin >> L >> R >> B;
    --L;
    tree1.update(L, R, B);
    tree2.update(L, R - 1, B);
    if(L > 0) {
      int64 get = tree1.query(L - 1, L);
      tree2.update(L - 1, L, get & B);
    }
    if(R < N) {
      int64 get = tree1.query(R, R + 1);
      tree2.update(R - 1, R, get & B);
    }
    cout << tree1.query(0, N) - tree2.query(0, N) << endl;
  }
}

Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  int N,k;
  while(cin >> N >> k && (N!=0 || k!=0)){
    int sum[N+1]={};
    int ans=-1*INF;
    for(int i=1;i<=N;i++){
      int a;
      cin >> a;
      sum[i]=sum[i-1]+a;
    }
    rep(i,N-k){
      int res=sum[i+k]-sum[i];
      chmax(ans,res);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3784
#include <cstdio>
#include <vector>

int main(void){

	int n, count, next_node, num_neighbors, min_distance;
	std::vector< std::vector<int> > edges;
	std::vector< std::vector<int> > neighbors;
	std::vector<bool> isUsed;
	std::vector<int> distance;
	scanf("%d", &n);
	edges.resize(n);
	isUsed.resize(n);
	neighbors.resize(n);
	distance.resize(n);
	for(int i=0;i<n;i++){
		scanf("%d %d", &next_node, &num_neighbors);
		edges[next_node].resize(num_neighbors);
		neighbors[next_node].resize(num_neighbors);
		for (int j=0;j<num_neighbors;j++){
			scanf("%d %d", &neighbors[next_node][j], &edges[next_node][j]);
		}
		isUsed[next_node]=-false;
		distance[next_node]=-1;
	}
	isUsed[0] = true;
	distance[0] = 0;
	count=0;
	for(int i=0;i<neighbors[0].size();i++){
		distance[neighbors[0][i]] = edges[0][i];
	}
	int neighbor;
	while(count<n-1){
		min_distance = 100000;
		for(int i=0;i<n;i++){
			if(!isUsed[i] && distance[i] != -1 && distance[i]<min_distance){
				next_node = i;
				min_distance = distance[i];
			}
		}
		isUsed[next_node] = true;
		for(int i=0;i<neighbors[next_node].size();i++){
			neighbor = neighbors[next_node][i];
			if(distance[neighbor] > distance[next_node]+edges[next_node][i] || distance[neighbor] <0){
				distance[neighbor] = distance[next_node] + edges[next_node][i];
			}
		}
		count ++;
	}
	for(int i=0;i<n;i++){
		printf("%d %d\n", i, distance[i]);
	}
	return 0;
}

Measured memory_bytes: 2732
n = int(input())

rng = [0] * (n+1)

for i in range(1,99):
    for j in range(1,99):
        for k in range(1,99):
            buf = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if buf > n:
                break
            else:
                rng[buf] += 1

for i in range(1,n+1):
    print(rng[i])

Measured memory_bytes: 9300
#include<bits/stdc++.h>
using namespace std;
char c[60][60];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
	for(int j=1;j<=b;j++)
	cin>>c[i][j];
	for(int i=1;i<=a;i++)
	for(int j=1;j<=b;j++)
	if(c[i][j]=='#')
	if(c[i-1][j]!='#'&&c[i+1][j]!='#'&&c[i][j-1]!='#'&&c[i][j+1]!='#')
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int loop;
	cin >>loop;
	double ans;
	for(int i=0;i<loop;i++){
		double tmp;
		string hoge;
		cin >> tmp;
		cin >> hoge;
		if(hoge == "JPY") {
			ans += tmp/1.0;
		} else {
			ans += tmp * 380000.0;
		}
	}
	cout <<ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
       int N,K,D,ara[150]={},count=0,i,x;
       cin>>N;
       cin>>K;

       while(K--){
                cin>>D;
                while(D--){
                        cin>>x;
                        ara[x]++;
                }
       }
       for(i=1;i<=N;i++){
        if(ara[i]==0){
                count++;
        }
       }
       cout<<count<<endl;
       return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, k;
ll calc(const vector<ll> seq) {
  ll ret = 0;
  REP(s, n) {
    if (s + k > n) { continue; }
    ll mul = 1;
    REP(j, k) {
      mul *= seq[s + j];
    }
    ret = max(ret, mul);
  }
  return ret;
}

int main() {
  while (scanf("%d %d", &n, &k), n|k) {
    vector<ll> seq(n);
    REP(i, n) {
      scanf("%lld", &seq[i]);
    }
    ll start = calc(seq);
    ll best = 0;
    REP(i, n) {
      REP(j, i) {
        vector<ll> nseq = seq;
        swap(nseq[i], nseq[j]);
        best = max(best, calc(nseq));
      }
    }
    if (start <= best) {      printf("%lld\n", best - start);
    } else {
      puts("NO GAME");
    }
  }
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	unsigned long a,b;
	scanf("%lu %lu",&a,&b);
  unsigned long c[b],i,j,flag[a],l,k,sum=0;
  flag[0]=0;
  unsigned long A[b][100];
  for(i=0;i<b;i++){
    scanf("%lu",&c[i]);
    for(j=0;j<c[i];j++){
      scanf("%lu",&A[i][j]);
      k=0;
    for(l=0;l<sum+1;l++){
      if(flag[l]==A[i][j]){
        k=1;
        break;
      }
    }
      if(k==0){
        sum++;
        flag[sum]=A[i][j];
      }
    }
  }
  
  
  
  
  printf("%lu",a-sum);
	return 0;
}


Measured memory_bytes: 2180
// https://atcoder.jp/contests/abc145/tasks/abc145_c
// AtCoder Beginner Contest 145
// C - Average Length

/*
Problem.
座標平面上のN個の点について全点を訪れる時、
全通りの経路長の平均値

Point.
ある点同士のペアを考えた時、
ペアの並び方は２通り（ABorBA）。
ペアを一つの点として捉えた時、そのペアが採用される並びは(N-1)!通り。
=> その２点のペアが採用される並び：2 * (N-1)!
よって、答えは
全ての点同士のペアについて、|a-b| * 2 * (N-1)! / N! = |a-b| * 2 / N
の総和
*/

#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  double ans = 0;
  vector<pair<int, int>> point(n);
  for(int i = 0; i < n; i++){
    cin >> point[i].first >> point[i].second;
  }
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      ans += sqrt(pow(point[i].first - point[j].first, 2) + pow(point[i].second - point[j].second, 2));
    }
  }
  cout << fixed << setprecision(16) << 2.0 * ans / n << endl;

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

int main() {
  string s,t; cin >>s>>t;
  int sn = s.size(), tn = t.size();
  int mcnt = 0;
  rep(i,sn-tn+1) {
    int j = 0, cnt = 0;
    while(j<tn) {
      if (s[i+j] == t[j]) {
        cnt++;
      }
      j++;
    }
    mcnt = max(mcnt,cnt);
  }
  cout << tn-mcnt << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main
{
    public static void main(String [] args)
    {
        Map<String,Integer> map =new HashMap<>();
        Scanner  sc =new Scanner(System.in);
        int red = sc.nextInt();
        int green = sc.nextInt();
        int  blue = sc.nextInt();
        int k = sc.nextInt();
        int time = (int)(Math.pow(2,k));
        if(green > red && blue >green)
        {
            System.out.println("Yes");
        }
        else
        {
            int total = 0;
           if(green<=red)
            {
                while(!(green>red))
                {
                    green = green*2;
                    total++;
                }
            }
            if(blue<=green)
            {
                while(!(blue>green))
                {
                    blue = blue*2;
                    total++;
                }
            }
            if(total<=k)
            {
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }

    }
}

Measured memory_bytes: 35296
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep (i, n) cin >> p[i];
  double sum = 0;
  int now = accumulate(p.begin(), p.begin() + k, 0), maxi = now;
  rep (i, k, n) {
    now  = now + p[i] - p[i - k];
    maxi = max(maxi, now);
  }
  cout << (maxi + k) / 2.0 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
    int s,m,h,a,b;
    scanf("%d",&s);
    a=s/60;
    b=s%60;
    h=a/60;
    m=a%60;
    s=b;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2700
//https://atcoder.jp/contests/abc143/tasks/abc143_d
//2019-11-27
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    vector<int> v;
    int current;
    for(int i=0;i<num;i++){
        cin >> current;
        v.push_back(current);
    }
    sort(v.begin(),v.end());
    vector<int> second;
    for(int i=0;i<=num+1;i++){
        second.push_back(2);
    }
    long ans = 0;
    for(int i=0;i<num;i++){
        for(int j=i+1;j<num;j++){
            if(second[j]<j+1){
                second[j] = j+1;
            }
            while((v[i]+v[j]>v[second[j]])&&(second[j]<num)){
                second[j] ++;
            }
            ans += second[j] - j - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, b, f, r, v, count[4][3][10];
    
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                count[i][j][k] = 0;
            }
        }
    }
    
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1] += v;
    }
    
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                printf(" %d", count[i][j][k]);
            }
            printf("\n");
        }
        if(i<3){
            printf("####################\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

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

int main(){
    int n;
    cin >> n;
    set<string> words;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        words.insert(s);
    }
    cout << words.size() << endl;
    return 0;
}


Measured memory_bytes: 19204
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n,d;
  cin >> n>>d;

  int ans = 0;
  rep(i,0,n){
    ll x,y;cin>>x>>y;
    double t = sqrt(x*x+y*y);
    if(t<=d)ans++;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3668
from heapq import heappop, heappush
from operator import itemgetter


def branchAndBound(N: int, M: int, V: list, W: list, R: list) -> int:
    def upperbound(w, v, i):
        rest = M - w
        _v = v
        for j in range(i + 1, N):
            if W[j] >= rest:
                rest -= W[j]
                v += V[j]
                _v = v
            else:
                _v += R[j] * rest
                break
        return v, _v

    prov, tmp = upperbound(0, 0, -1)
    h = [(tmp, W[0], V[0] * (W[0] >= M), 0), (upperbound(0, 0, 0)[1], 0, 0, 0)]
    while h:
        _v, w, v, cur = heappop(h)
        if _v > prov or cur == N - 1:
            continue
        nxtw, nxtv = w + W[cur + 1], v + V[cur + 1]
        if nxtw >= M:
            heappush(h, (_v, nxtw, nxtv, cur + 1))
        _prov, ub = upperbound(w, v, cur)
        if _prov < prov:
            prov = _prov
        if ub < prov:
            heappush(h, (ub, w, v, cur + 1))
    return -prov


def main():
    N, M, *L = map(int, open(0).read().split())
    t = [(v, w, v / w) for w, v in zip(*[iter(L)] * 2)]
    t.sort(key=itemgetter(2), reverse=True)
    V, W, R = [], [], []
    for v, w, r in t:
        V += [-v]
        W += [-w]
        R += [r]
    ans = branchAndBound(N, -M, V, W, R)
    print(ans)
    
if __name__=="__main__":main()


Measured memory_bytes: 3444
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long N, L, T;
  cin >> N >> L >> T;
  vector<long> xs(N, 0), ws(N, 0);
  for (long i = 0; i < N; ++i) {
    cin >> xs[i] >> ws[i];
  }

  vector<long> last_poses(N, 0);
  long counter = 0;
  for (long i = 0; i < N; ++i) {
    if (ws[i] == 1) {
      last_poses[i] = (xs[i] + T) % L;
      counter += (xs[i] + T) / L;
    } else {
      if (xs[i] - T >= 0) {
        last_poses[i] = xs[i] - T;
        // counterは変化なし
      } else {
        last_poses[i] = (((xs[i] - T) % L) + L) % L;
        counter = counter - abs(xs[i] - T + 1) / L - 1;
      }
    }
  }

  sort(last_poses.begin(), last_poses.end());
  counter = (counter % N + N) % N;

  vector<long> res(N, 0);
  for (long i = 0; i < N; ++i) {
    res[i] = last_poses[(i + counter) % N];
  }

  for (auto &e : res) {
    cout << e << endl;
  }
  return 0;
}

Measured memory_bytes: 4352