akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int num = 0;
		for(int i = 0; i < n ; i++) {
			int pre[] = new int[26];
			int suf[] = new int[26];
			for (int j = 0; j < i; j++) {
				pre[(int)s.charAt(j) - (int)'a'] = 1;
			}
			for(int j = i; j < n; j++) {
				suf[(int)s.charAt(j) - (int)'a'] = 1;
			}
			int rec = 0;

			for (int j = 0; j < 26; j++) {
				if(pre[j] == 1 && suf[j] == 1) {
					rec++;
				}
			}
			num = Math.max(num, rec);
		}
		System.out.println(num);

	}

}


Measured memory_bytes: 23764
# coding:utf-8

# ユークリッドの互除法
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

# 標準入力から取得
a, b = map(int, raw_input().split())
c = map(int, raw_input().split())
# print c 
c = [abs(c[i]-b) for i in range(a)] 
# print c

g = c[0]
for z in c:
    g = gcd(g,z)
print g



Measured memory_bytes: 12344
N, K = map(int, input().split())

if K%2 == 1:
    num = 0
    for i in range(1,N+1):
        if i%K == 0:
            num+=1

    print(num**3)

else:
    num1 = 0
    for i in range(1, N + 1):
        if i % K == 0:
            num1 += 1

    num2 = 0
    for i in range(1, N + 1):
        if i % K == K/2:
            num2 += 1

    print(num1**3+num2**3)

Measured memory_bytes: 39024
#include <stdio.h>

int main(){
    int R, G, B, N;
    scanf("%d %d %d %d", &R, &G, &B, &N);

    int i, j, k, ans = 0;
    for (i=0; ; i++){
        if (i*R == N){
            ans++;
        }        
        if (i*R >= N){
            break;
        }

        for (j=0; ; j++){
            if (i*R + j*G == N){
                ans++;
            }
            if (i*R + j*G >= N){
                break;
            }

            if ((N - (i*R + j*G))%B == 0  ){
                ans++;
            }
        }
    }


    printf("%d",  ans);

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
#define int ll
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second
const int MM = 1e7+5;
int n;
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	//freopen("in.txt","r", stdin);
    cin >> n;
    vector<int> div(MM,1);
    for(int i = 2; i<= n; i++){
        for(int j = i; j <= n; j += i)
            div[j]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n;i++){
        ans += (i * div[i]);
    }
    cout << ans << "\n";

}


Measured memory_bytes: 81320
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		string s = Console.ReadLine();
		List<int> answers = new List<int>();
    int minNumBefore = n;
    int minNum = n;
    int leftNum = n;
    bool answer = true;

    while(true)
    {
      for(int i = leftNum-1; (i >= minNumBefore-m && i >= 0); i--)
      {
        if(s[i] == '0') minNum = i;
        leftNum--;
      }
      //Console.WriteLine(minNum);
      
      if(minNum == minNumBefore)
      {
        answer = false;
        break;
      }else
      {
        answers.Add(minNumBefore -minNum);
        minNumBefore = minNum;
        if(minNum == 0) break;
      }
    }

		if(!answer) Console.WriteLine(-1);
    else
    {
      int answerCount = answers.Count();
      int[] answersSub = new int[answerCount];
      for(int i = 0; i < answerCount; i++)
      {
        answersSub[i] = answers[answerCount-1-i];
      }
      Console.WriteLine(string.Join(" ", answersSub));
    }
	}
}

Measured memory_bytes: 14176
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n,m;
int ok[200005]={};

int main(void){
	scanf("%d%d",&n,&m);
	
	bool ans=false;
	rep(i,m){
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		if(a==0){
			if(ok[b])ans=true;
			ok[b]=1;
		}
		if(b==n-1){
			if(ok[a])ans=true;
			ok[a]=1;
		}
	}
	puts(ans?"POSSIBLE":"IMPOSSIBLE");
		
	return 0;
}






Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, x;
    cin >> n >> x;

    int c = 1;
    int prev = 0;
    for(int i=0; i<n; i++) {
        int l;
        cin >> l;
        int d = prev + l;
        if ( d<=x ) c++;
        prev = d;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll H,W;
vector<vector<ll>> gr;
vector<vector<ll>> dp;

int input(){
  cin >> H >> W;
  
  REP(i,H){
    gr.push_back(vector<ll>());
    REP(j,W) gr[i].push_back(0);
    dp.push_back(vector<ll>());
    REP(j,W) dp[i].push_back(0);
  }
  
  REP(i,H) {
   string st = inp<string>();
   REP(j,W) gr[i][j] = (st[j] =='.')?1:0;
  }
}

int main()
{
  input();
  
  dp[0][0] = 1;
  
  REP(i,H){
    REP(j,W){
      ll co = 0;
      if (gr[i][j]==0)continue;
      if (i==0 & j==0)continue;
      if (i>0) co += dp[i-1][j];
      if (j>0) co += dp[i][j-1];
      dp[i][j] = co%1000000007;
    }
  }
  
  REP (i,H){
    //REP(j,W) cout << dp[i][j] << ",";
    //cout << endl;
  }
  cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 16384
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}

		for(int k =0; k<n-1 ;k++) {
			System.out.print(A[k] + " ");
		}
		System.out.println(A[n-1]);

		for(int i = 1; i < n; i++) {
			int key = A[i];

			int j = i - 1;
			while( j>=0 && A[j] > key) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = key;

			for(int k =0; k<n-1 ;k++) {
				System.out.print(A[k] + " ");
			}
			System.out.println(A[n-1]);
		}
	}
}


Measured memory_bytes: 31492
//2011
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
	int i,W,H,N,x,y,a,b,c,d,ans=0;
	cin>>W>>H>>N;
	cin>>x>>y;
	for(i=1;i<N;i++){
		cin>>a>>b;
		c=x-a;
		d=y-b;
		while(c>0&&d>0){
			c--;d--;ans++;
		}
		while(c<0&&d<0){
			c++;d++;ans++;
		}
		ans+=abs(c);
		ans+=abs(d);
		x=a;y=b;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

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

bool getpath(int u, const int v, vector<int> &path, int p = -1) {
    if (u == v) { return true; }

    for (auto &e: g[u]) {
        if (e.first == p) continue;
        if (getpath(e.first, v, path, u)) {
            path.push_back(e.second);
            return true;
        }
    }

    return false;
}

vector<int> pathc[50][50];

int main() {
    int n;
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }

    int m;
    cin >> m;
    vector<pair<int, int>> cons(m);
    for (auto &e: cons) {
        cin >> e.first >> e.second;
        --e.first; --e.second;
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            getpath(i, j, pathc[i][j]);
        }
    }


    ll coans = 0;
    vector<bool> used(n-1);
    for (ll i = 1; i < (1LL << m); ++i) {
        fill(used.begin(), used.end(), false);
        for (int j = 0; j < m; ++j) {
            if (((i >> j) & 1) == 0) continue;
            for (auto &e: pathc[cons[j].first][cons[j].second]) used[e] = true;
        }

        ll cnt = count(used.begin(), used.end(), false);
        ll t = (1LL << cnt) - 1;
        if (bitset<64>(i).count() % 2) {
            coans += t;
        } else {
            coans -= t;
        }
    }

    ll ans = (1LL << (n-1)) - 1 - coans;
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    vector< T > m_data;
    CumulativeSum() {};
    CumulativeSum(int sz) : m_data(sz, 0) {};

    // k に x を加える O(1)
    void Add(int k, int x) {
        assert(m_data.size() >= k);
        if(m_data.size() <= k) { m_data.push_back(x); }
        else { m_data[k] += x; }
    }

    // 累積和の構築 O(m_data.size())
    void Build() { for(int i = 1; i < m_data.size(); i++) { m_data[i] += m_data[i - 1]; } }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return 0; }
        return (m_data[min(k, (int) m_data.size() - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) { return this->Query(h) - this->Query(l-1); }
};

ll N;
vector<ll> A;

signed main()
{
    cin >> N;
    A.assign(N, 0);
    REP(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end(), greater<ll>());

    CumulativeSum<ll> cs;
    REP(i, N) {
        cs.Add(i, A[i]);
    }
    cs.Build();

    ll ans = 1;
    for(ll i = 1; i < N; ++i) {
        if(A[i-1] > cs.Query(i, N-1) * 2) { break; }
        ans++;
    }
    printf("%lld\n", ans);

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int P;
int A[3030];
ll from[3030],to[3030],hoge[3030],B[3030];
ll mo;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>P;
	mo=P;
	
	FOR(i,P) cin>>A[i];
	
	from[0]=1;
	FOR(i,P) {
		ZERO(to);
		FOR(j,3000) to[j+1]=from[j];
		FOR(j,3000) {
			to[j]-=i*from[j];
			to[j]=(to[j]%P+P)%P;
		}
		swap(from,to);
	}
	
	
	for(i=0;i<P;i++) if(A[i]) {
		memmove(to,from,sizeof(from));
		ZERO(hoge);
		for(j=3000;j>=1;j--) {
			hoge[j-1]=to[j];
			to[j-1]=(to[j-1]+to[j]*i)%mo;
		}
		
		ll Q=1;
		for(j=0;j<P;j++) if(j!=i) Q=Q*(i-j)%mo;
		Q=(Q%mo+mo)%mo;
		Q=modpow(Q);
		
		for(j=0;j<P;j++) {
			(B[j]+=hoge[j]*Q)%=P;
		}
	}
	FOR(i,P) cout<<B[i]%P<<" ";
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

vector<ll> size(51),patty(51);

ll dfs(ll N,ll X){
  if(N == 0) return 1;
  if(X <= 1) return 0;
  if(X <= 1+size[N-1]) return dfs(N-1,X-1);
  if(X == 2+size[N-1]) return patty[N-1] + 1;
  if(X < 2*size[N-1]+3) return patty[N-1] + 1 + dfs(N-1,X-2-size[N-1]);
  return patty[N-1]*2 + 1;
}

int main(){
  ll N,X;
  cin >> N >> X;
  size[0] = 1;
  patty[0] = 1;
  for(int i=1; i<=50; i++){
    size[i] = size[i-1]*2 + 3;
    patty[i] = patty[i-1]*2 + 1;
  }
  cout << dfs(N,X) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var p = cin.SplitRead();
            int N = p[0];
            int M = p[1];
            var d = new long[N, N];
            for (var i = 0; i < N; i++) for (var j = 0; j < N; j++) d[i, j] = i == j ? 0 : SINF;

            var a = new int[M];
            var b = new int[M];
            var c = new long[M];

            
            for(var i = 0; i < M; i++)
            {
                var input = cin.SplitRead();
                a[i] = input[0] - 1;
                b[i] = input[1] - 1;
                
                c[i] = input[2];

                
                d[a[i], b[i]] = c[i];
                d[b[i], a[i]] = c[i];
            }

            Warshall_floyd(N, d);

            int ans = M;
            for(var i = 0; i < M; i++)
            {
                bool nouse = true;
                for(var j = 0; j < N; j++)
                {
                    if (d[j, a[i]] + c[i] == d[j, b[i]])
                    {
                        nouse = false;
                    }
                }
                ans -= nouse ? 0 : 1;
            }
            Console.WriteLine(ans);
            
            

        }

        static public void Warshall_floyd(int n, long[,] dist)
        {
            for (var k = 0; k < n; k++)
            {
                for (var i = 0; i < n; i++)
                {
                    for (var j = 0; j < n; j++)
                    {
                        dist[i, j] = Min(dist[i, j], dist[i, k] + dist[k, j]);
                    }
                }
            }
        }

    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 13396
package main

import (
    "fmt"
)

func main() {
    var s int 
    fmt.Scan(&s)

    mem := map[int]bool{}
    mem[s] = true
    i := 1
    for {
        //fmt.Println(i, s)
        i++ 
        if s%2 == 0 { 
            s = s / 2 
        } else {
            s = 3*s + 1 
        }   
        if mem[s] == true {
            fmt.Println(i)
            break
        }   
        mem[s] = true
    }   
}


Measured memory_bytes: 512
#include<stdio.h>

int n, A[50];

int Ex_search (int i, int m);

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i = 0; i < n; i++ )scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i = 0; i< q; i++){
    scanf("%d",&M);
    if(Ex_search(0,M))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int Ex_search (int i, int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res= Ex_search(i+1,m)||Ex_search(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2104
using System;


namespace ABC172Test
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine().Trim());
            long result = 0;
            result = abc172_f3(N);
            Console.WriteLine(result);
        }
        
        static long abc172_f3(int k)
        {
            long sum = 0;
            for (int i = 1; i <= k; i++)
            {
                int max = k / i;
                sum += (((long)max * ((long)max + 1) / 2) * (long)i);
            }
            return sum;
        }

    }

}


Measured memory_bytes: 27496
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, res;
string s;

signed main() {
    cin >> s;
    n = s.size();
    s += "OOO";
    int a = 0;
    rep(i,n) {
        if (s[i]=='A') a++;
        else if (s[i]=='B' && s[i+1]=='C') res += a, i++;
        else a = 0;
    }
    cout << res << endl;
}


Measured memory_bytes: 720
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int eki; cin >> eki;
	vector<vector<int>> arr(eki + 10, vector<int>(3, 0));
	//次の駅までの時間 最初に出る時間 間隔
	for (int i = 1; i < eki; ++i)
	{
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	for (int i = 1; i < eki; i++)
	{
		int count = 0;//j駅目に着くまで(1~)
		for (int j = i; j < eki; j++)
		{
			if (count < arr[j][1])
			{
				count = arr[j][1] + arr[j][0];
			}
			else if ((count - arr[j][1]) % arr[j][2] == 0)
			{
				count = (((int)(count - arr[j][1]) / arr[j][2]))*arr[j][2] + arr[j][1] + arr[j][0];
			}
			else
			{
				count = (((int)(count - arr[j][1]) / arr[j][2]) + 1)*arr[j][2] + arr[j][1] + arr[j][0];
			}
		}
		cout << count << "\n";
	}
	cout << 0 << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

int const N = 12;
int const M = 1e3 + 5;
long long dp[1 << N];
int dat[M], a[M], b[M];
int const INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        int cur_m = 0;
        for (int j = 0; j < b[i]; ++j) {
            int c;
            cin >> c;
            cur_m += (1 << (c - 1));
        }
        dat[i] = cur_m;
    }
    fill(dp, dp + (1 << N), INF);
    dp[0] = 0;
    for (int musk = 0; musk < (1 << n); ++musk) {
        for (int i = 0; i < m; ++i)
            dp[musk | dat[i]] = min(dp[musk | dat[i]], dp[musk] + a[i]);
    }
    if (dp[(1 << n) - 1] >= INF) {
        cout << -1 << '\n';
    }
    else {
        cout << dp[(1 << n) - 1] << '\n';
    }
}


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

int main()
{
    int a, b, k; cin >> a >> b >> k;
    int ans;

    for(int i = max(a, b); k > 0; i--){
        if(!(a % i) && !(b % i)){
            ans = i;
            k--;
        }
    }

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

Measured memory_bytes: 3600
#include<stdio.h>

#define N 100

void selectionSort(int*Sort,int n){

  int i,j,min,tmp,cnt=0;

  for(i = 0;i < n;i++){
    min = i;
    for(j = i;j < n;j++){

      if(Sort[j] < Sort[min]){
	min = j;

      }
    }   
    if(Sort[i] != Sort[min]){ 
      tmp = Sort[i];
      Sort[i] = Sort[min];
      Sort[min] = tmp;
      cnt++;
    }
    
  }

  for(i = 0;i < n-1;i++)
    printf("%d ",Sort[i]);
  printf("%d\n",Sort[n-1]);
  printf("%d\n",cnt);
}

int main(){

  int n,i;
  int Sort[N];

  scanf("%d",&n);

  for(i = 0;i < n; i++)
    scanf("%d",&Sort[i]);

  selectionSort(Sort,n);

  return 0;
}

Measured memory_bytes: 600
import Control.Applicative
import Control.Monad
import Data.List

isPrime 1 = False
isPrime 2 = True
isPrime 3 = True
isPrime n = all ((/=0).mod n) [2..(truncate.sqrt.fromIntegral) n]

main = do 
    n <- readLn ::IO Int
    q <- replicateM n readLn ::IO[Int]
    putStrLn $ show((length.filter(id)) (map isPrime q))

Measured memory_bytes: 8220
#include <stdio.h>
 
int main () 
{
int a,b,c,x;
int tmp = 0;
int count = 0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&x);


for(int p=0;p<=a;p++)
{
    for(int q=0;q<=b;q++)
    {
        for(int r=0;r<=c;r++)
        {
            tmp = 500*p + 100*q + 50*r;
            if(tmp == x)
            {
                count++;
            } 
        }
    }
}

printf("%d",count);
return 0;
}

Measured memory_bytes: 128
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []

for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

for i in range(M):
    T2 = T.copy()
    T2[P[i]-1] = X[i]
    print(sum(T2))


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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll arr[n];
    for(int i=0;i<n;++i){
    	cin >> arr[i];
    }

    sort(arr,arr+n);
    for(int i=n-1;i>= max((ll)0,n-k);--i ){
    	arr[i] = 0;
    }
    ll ans = 0;
    for(int i=0;i<n;++i){
    	ans+=arr[i];
    }
    cout << ans << endl;

    

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
string buf,tp;
stringstream tmp;
inline int Get(string s){
	tmp.clear();
	tmp<<s;
	int ret;
	tmp>>ret;
	return ret;
}
int main(){
	cin>>n;
	tmp.clear();
	tmp<<n;tmp>>buf;
	int e=Get(buf.substr(1,SZ(buf)-2));
	if(SZ(buf)==1){
		cout<<n<<endl;
		return 0;
	}
	if(SZ(buf)==2){
		int ans=9;
		for(int i=10;i<=n;i++){
			if(i%10==0)continue;
			int r=i%10;
			r*=10;r+=i/10;
			if(r<=n)ans++;
			if(r/10==r%10)ans+=2;
		}
		cout<<ans<<endl;
		return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int st=i%10,ed=-1;
		for(int j=5;j>=0;j--){
			if(i/int(pow(10,j))){
				ed=i/int(pow(10,j));
				break;
			}
		}
		int pre=ans;
		
		if(st==0)continue;
		if(st==ed)ans++;
		for(int j=2;j<SZ(buf);j++){
			ans+=int(pow(10,j-2));
		}
		if(st<n/int(pow(10,SZ(buf)-1))){
			ans+=int(pow(10,SZ(buf)-2));
		}else if(st==n/int(pow(10,SZ(buf)-1))){
			ans+=e+1;
			if(ed>n%10){
				ans--;
			}
		}
//		cout<<i<<' '<<st<<' '<<ed<<' '<<ans-pre<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let m: usize = sc.next().unwrap();
    let mut xy: Vec<(usize, usize)> = vec![];
    for _ in 0..m {
        let x: usize = sc.next().unwrap();
        let y: usize = sc.next().unwrap();
        xy.push((x - 1, y - 1));
    }
    let mut bads = vec![false; n];
    let mut bs = vec![];
    for i in 0..n {
        let mut b = vec![-1; n];
        b[i] = m as i32;
        let mut bad = false;
        for i in (0..m).rev() {
            let (x, y) = xy[i];
            if b[x] >= 0 && b[y] >= 0 {
                bad = true;
            }
            if b[x] >= 0 {
                b[y] = i as i32;
            } else if b[y] >= 0 {
                b[x] = i as i32;
            }
        }
        for i in 0..m {
            let (x, y) = xy[i];
            if b[x] >= 0 && b[x] < i as i32 && b[y] == -1 {
                b[y] = i as i32;
            } else if b[y] >= 0 && b[y] < i as i32 && b[x] == -1 {
                b[x] = i as i32;
            }
        }
        bs.push(b);
        bads[i] = bad;
    }
    let mut res = 0;
    for i in 0..n {
        for j in 0..i {
            if !bads[i] && !bads[j] {
                if bs[i][j] == -1 && bs[j][i] == -1 {
                    res += 1;
                }
            }
        }
    }
    println!("{}", res);
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next().unwrap());
/// assert_eq!(3.5, sc.next().unwrap());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 6396
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m;
  rd(n, m);
  struct T {
    int a, b;
  }

  auto es = new T[](m);
  foreach (i; 0 .. m)
    rd(es[i].a, es[i].b);

  sort!"a.b<b.b"(es);
  int last = -1, cnt = 0;
  foreach (e; es) {
    if (last <= e.a) {
      last = e.b;
      cnt++;
    }
  }
  writeln(cnt);

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 3964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		String anser = "";

		try {
			//??\?????????
			sc = new Scanner(System.in);
			String line = sc.nextLine();

			char[] check = line.toCharArray();

			//?????????????????\????????§??????
			for (int i = 0; i < check.length; i++) {
				if (Character.isUpperCase(check[i])) {
					//?°????????????????
					check[i] = Character.toLowerCase(check[i]);
				}else {
					//??§???????????????
					check[i] = Character.toUpperCase(check[i]);
				}
			}

			System.out.println(check);

		} finally {
			sc.close();
		}

	}

}

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

using namespace std;

int Match[] = {0,2,5,5,4,5,6,3,7,6};
int N,M;
void traceback(vector<int> A, vector<int> dp){
    int pos = N;
    int dig = dp[N];
    while(pos != 0){
        for(int i = A.size()-1; i >= 0; i--){
            if(pos - Match[A[i]] < 0) continue;
            if(dp[pos - Match[A[i]]] != (dig - 1)) continue;
            cout << A[i] ;
            dig -=1;
            pos -= Match[A[i]];
            break;
        }
    }
    cout << endl;
    return;
}

void dfs(vector<int> A, vector<int> dp,int dig,int pos){
    //cout <<"pos : " << pos << " dig:  " << dig << endl;
    if(dig == 0) return;
    for(int i = M-1;i>=0;i--){
        //if(dig == 1) cout << i << " " << pos << " " << A[i] << endl;
		if(pos >= Match[A[i]] && dp[pos-Match[A[i]]]==dig-1){
			pos -=Match[A[i]];
			cout<<A[i];
			dfs(A,dp,dig-1,pos);
			return;
		}
    }
}

int main(){
    cin >> N >> M;
    vector<int> A(M);
    vector<int> B;
    vector<int> check(10);
    for(int i= 0;i < M;i++){
        cin >> A[i];
        check[A[i]] = 1;
    }
    sort(A.begin(),A.end());
    vector<int> dp(N+1);  //マッチをn本使った時の最大の桁数を格納dp(n)
    for(int i = 1; i< N+1; i++){
        dp[i] = -1e8;
    }
    for(int i= 0;i<N+1;i++){
        for(int j= 0; j< A.size() ; j++){
            if((i - Match[A[j]]) >= 0){
                dp[i] = max(dp[i],dp[i-Match[A[j]]]+1);
            }
        }
    }
    //traceback(A,dp);
    dfs(A,dp,dp[N],N);
    return 0;
}

Measured memory_bytes: 196480
# 2020/07/18
# AtCoder Beginner Contest 093 - C

# Input
abc = list(map(int,input().split()))
abc.sort()

ans = 0

s1 = abc[2] - abc[0]
s2 = abc[2] - abc[1]

# Calc
if s1 > 0:
    # even & even
    if s1 % 2 == 0 and s2 % 2 == 0:
        ans = s1 // 2 + s2 // 2
        
    # odd & odd
    elif s1 % 2 > 0 and s2 % 2 > 0:
        s1 = s1 - 1
        s2 = s2 - 1
        ans = s1 // 2 + s2 // 2 + 1
    # odd & even(eg:5 2 3)
    else:
        ans = s1 // 2 + s2 // 2 + 2

# Output
print(ans)


Measured memory_bytes: 9148
def answer(n, k, x):
    ans = 2 * (x[n - 1] - x[0])


    for i in range(0, n - k + 1):
        if abs(x[i]) < abs(x[i + k - 1]):
            temp = abs(x[i])
        else:
            temp = abs(x[i + k - 1])

        temp += abs(x[i + k - 1] - x[i])

        if temp < ans:
            ans = temp

    return ans


[n, k] = list(map(int, input().split()))
x = list(map(int, input().split()))    
print(str(answer(n, k, x)))

Measured memory_bytes: 14224
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    REP(i, N) cin >> a[i] >> b[i] >> c[i];

    int dp[100005][3];
    CLR(dp, 0);
    REP(i, N) {
        dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return 0;
}


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

using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
 vector<int> vec(n,-1);
  for(int i=0;i<m;i++){
    int s,c;
    cin>>s>>c;
    s--;
    if(n!=1&&s==0&&c==0){
      cout<<-1<<endl;
      return 0;
    }
    if(vec.at(s)==-1){
      vec.at(s)=c;
    }
    else if(vec.at(s)!=c){
      cout<<-1<<endl;
      return 0;
    }
  }
 for(int i=0;i<n;i++){
   if(n!=1&&i==0&&vec.at(i)==-1){
     vec.at(i)=1;
   }
   else if(vec.at(i)==-1){
     vec.at(i)=0;
   }
   cout<<vec.at(i);
 }
  cout<<endl;
  
  
  
}


Measured memory_bytes: 3560
nk = gets.chomp.split
n = nk[0].to_i
k = nk[1].to_i

h = gets.chomp.split
n.times do |i|
    h[i] = h[i].to_i
end

count = 0
n.times do |i|
    count += 1 if h[i] >= k
end

puts count

Measured memory_bytes: 7428
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int table[N];
	int compDate[N];

	for(int i = 0; i < N; i++){
		table[i] = 0;
		compDate[i] = 0;
	}

	vector<Info> V[N];

	int from,to,cost;

	for(int i = 0; i < M; i++){
		scanf("%d %d %d",&from,&to,&cost);
		table[to]++;
		V[from].push_back(Info(to,cost));
	}

	int current;

	queue<int> Q;

	for(int i = 0; i < V[0].size();i++){
		compDate[V[0][i].to] = max(compDate[V[0][i].to],V[0][i].cost);
		table[V[0][i].to]--;
		if(table[V[0][i].to] == 0){
			Q.push(V[0][i].to);
		}
	}

	while(!Q.empty()){
		current = Q.front();
		Q.pop();

		for(int i = 0; i < V[current].size();i++){
			compDate[V[current][i].to] = max(compDate[V[current][i].to],compDate[current]+V[current][i].cost);
			table[V[current][i].to]--;
			if(table[V[current][i].to] == 0){
				Q.push(V[current][i].to);
			}
		}
	}

	printf("%d\n",compDate[N-1]);

    return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b;
cin >> a >> b;
int ans=0;
int sum=1;
while(1) {
  if(sum>=b) break;
  sum += a-1;
  ans++;
}
cout << ans << endl;
return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;

    double p = 0;
    for (ll num_dice = 1; num_dice <= n; ++num_dice) {
        if (num_dice >= k) {
            p += (double) 1 / n;
            continue;
        }

        ll num_coin = ceil(log2((double)k/num_dice));
        p += (double)(1 / pow(2, num_coin)) / n;
    }

    cout << fixed << setprecision(10) << p << endl;
    return 0;
}

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

using namespace std;
#define LL long long 

int main(){
    int n;
    bool hf = false, cf = false, mf = false, sf = false, af = false;
    bool kf = false, of = false, akaf = false; 
    LL ans = 0;
    int mincnt = 0;
    int maxcnt = 0;
    cin >> n;
    vector<LL> a(n), b(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] < 400){
            if(!hf) mincnt++;
            hf = true;
        }else if(a[i] < 800){
            if(!cf) mincnt++;
            cf = true;
        }else if(a[i] < 1200){
            if(!mf) mincnt++;
            mf = true;
        }else if(a[i] < 1600){
            if(!sf) mincnt++;
            sf = true;
        }else if(a[i] < 2000){
            if(!af) mincnt++;
            af = true;
        }else if(a[i] < 2400){
            if(!kf) mincnt++;
            kf = true;
        }else if(a[i] < 2800){
            if(!of) mincnt++;
            of = true;
        }else if(a[i] < 3200){
            if(!akaf) mincnt++;
            akaf = true;
        }else{
            maxcnt++;
        }
    }
    cout << max(mincnt, 1) << " " << maxcnt + mincnt << endl;

}

Measured memory_bytes: 256
number = int(input())

input = [input() for i in range(number)]

result = 0

for i in range(number):
	otoshidama = input[i].split()
	if otoshidama[1] == "JPY":
		result = result + float(otoshidama[0])
	elif otoshidama[1] == "BTC":
		result = result + float(otoshidama[0]) * 380000.0

print(result)

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a + b == 15) {
        cout << "+\n";
        return 0;
    }
    if(a * b == 15){
        cout << "*\n";
        return 0;
    }
    cout << "x\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
typedef long long ll;

int lary[4010][4010],rary[4010][4010];
bool iswa[4010][4010];
stack<int> sta[4010];
int bit[4010];
int H,W,L,P,Bitmax;

//BIT

int init(int ma){
	Bitmax=ma;
	fill(bit,bit+ma+1,0);
}

int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=(i&-i);
	}
	return s;
}

void add(int i,int x){
	while(i<=Bitmax){
		bit[i]+=x;
		i+=(i&-i);
	}
}

int query(int l,int r){
	if(l>r) return 0;
	else return sum(r)-sum(l-1);
}

int main(){
	cin>>H>>W>>L>>P;
	int a,b;
	for(int i=1;i<=P;i++){
		cin>>a>>b;
		iswa[a][b]=true;
	}

	for(int i=1;i<=H;i++){
		int cnt=0;
		for(int j=1;j<=W;j++){
			if(iswa[i][j]){
				cnt=0;
			}
			else{
				cnt++;
			}
			rary[i][j]=cnt;
		}
	}
	for(int i=1;i<=W;i++){
		int cnt=0;
		for(int j=1;j<=H;j++){
			if(iswa[j][i]){
				cnt=0;
			}
			else{
				cnt++;
			}
			rary[j][i]=min(rary[j][i],cnt);
		}
	}
	for(int i=H;i>=1;i--){
		int cnt=0;
		for(int j=W;j>=1;j--){
			if(iswa[i][j]){
				cnt=0;
			}
			else{
				cnt++;
			}
			lary[i][j]=cnt;
		}
	}
	for(int i=W;i>=1;i--){
		int cnt=0;
		for(int j=H;j>=1;j--){
			if(iswa[j][i]){
				cnt=0;
			}
			else{
				cnt++;
			}
			lary[j][i]=min(lary[j][i],cnt);
		}
	}
	
	ll res=0;
	for(int i=-H+1;i<=W-1;i++){
		int num,xx,yy;
		if(i>max(0,W-H)) num=W-i;
		else if(i<min(0,W-H)) num=H+i;
		else num=min(W,H);
		
		if(i>=0){
			xx=i+1;yy=1;
		}
		else{
			xx=1;yy=-i+1;
		}

		init(num);
		int cnt=0;
		for(int j=1;j<=num;j++){
			if(j+lary[yy][xx]<=num)sta[j+lary[yy][xx]].push(j);
			add(j,1);
			while(!sta[j].empty()){
				add(sta[j].top(),-1);
				sta[j].pop();
			}
			cnt+=query(j-rary[yy][xx]+1,j-L+1);
			xx++;yy++;
		}
		res+=(ll)cnt;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 145580
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

struct Node {
  Node* child[26];
};

const int N = 5000 + 10;
Node pool[N * 5], *last;
char s[N];

Node* new_node() {
  Node* ret = last++;
  fill(ret->child, ret->child + 26, nullptr);
  return ret;
}

void insert(Node* root, char *s) {
  int n = strlen(s);
  Node* p = root;
  for (int i = 0; i < n && i < 5; ++i) {
    int k = s[i] - 'a';
    if (!p->child[k]) p->child[k] = new_node();
    p = p->child[k];
  }
}

char ret[N];
int rem;
bool DFS(Node* p, int dep) {
  // trace(dep, rem);
  if (rem == 0) {
    ret[dep] = 0;
    puts(ret);
    return true;
  }
  --rem;
  for (int k = 0; k < 26; ++k) {
    if (p->child[k]) {
      ret[dep] = 'a' + k;
      if (DFS(p->child[k], dep + 1)) return true;
    }
  }
  return false;
}

int main() {
  scanf("%s", s);
  last = pool;
  Node* root = new_node();
  for (int i = 0; s[i]; ++i) {
    insert(root, s + i);
  }
  scanf("%d", &rem);
  DFS(root, 0);
  return 0;
}


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

int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){

char s[11];
char t[12];


scanf("%s", s);
scanf("%s", t);

int scounter = 0;
int a;
for(a = 0; s[a] != '\0';a++){
    scounter++;
}

int flag = 0;
int i;

for(i = 0; i < scounter ;i++){
    if(s[i] != t[i]){
        flag = 1;
    }
}

if (t[scounter] == '\0'){
    flag = 1;
}


if(flag == 1){
    printf("%s", "No");
}else {
    printf("%s", "Yes");
}

}

Measured memory_bytes: 1692
n,k=map(int,input().split())
ans=max(n-k+1,0)
a,b,c=k,k,1
while a!=1:
  b=(a+1)>>1
  ans+=(min(a,n+1)-min(b,n+1))/(2**c)
  c+=1
  a=b
print(ans/n)

Measured memory_bytes: 38256
import std.stdio, std.string, std.conv;

int[] factors(int x) {
    int[] result;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            result ~= i;
            if (i * i != x) result ~= x / i;
        }
    }
    return result;
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    int[] b;
    foreach_reverse (i; 0 .. n) {
        if (a[i]) {
            b ~= i + 1;
            int[] tmp = factors(i+1);
            foreach (x; tmp) {
                a[x-1] = !a[x-1];
            }
        }
    }
    b.length.writeln;
    if (b.length) b.to!(string[]).join(" ").writeln;
}

Measured memory_bytes: 11928
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCore {
	public class Program {
		private const int MOD = 1000000007;

		static void Main (string[] args) {
			int[] nm = Console.ReadLine ().Split (' ').Select (x => int.Parse (x)).ToArray ();
			int n = nm[0];
			int m = nm[1];
			AB[] ab = new AB[n];
			for(int i = 0; i < n; ++i){
				int[] temp = Console.ReadLine ().Split (' ').Select (x => int.Parse (x)).ToArray ();
				ab[i] = new AB{A = temp[0], B = temp[1]};
			}

			var ab2 = ab.OrderBy(x => x.A).ToArray();
			long ans = 0;
			for(int i = 0; i < n; ++i){
				if(m >= ab2[i].B){
					m -= ab2[i].B;
					ans += (long)ab2[i].A * ab2[i].B;
				}else {
					ans += (long)ab2[i].A * m;
					m = 0;
				}

				if(m <= 0){
					break;
				}
			}

			Console.WriteLine(ans);
		}

		public class AB
		{
			public int A {get; set;}
			public int B {get; set;}
		}
	}
}

Measured memory_bytes: 26804
#include <stdio.h>

typedef struct {
    int id;
    long long total;
} sales_t;

int main (void) {
    sales_t sales[4000], *s, *employee[4000];
    int eid, p, q, n, i, sales_idx, pcnt;

    while (scanf("%d", &n) != EOF && n) {
        sales_idx = 0;
        for (i = 0; i < 4000; i++) {
            employee[i] = NULL;
        }
        for (i = 0; i < n; i++) {
            scanf("%d%d%d", &eid, &p, &q);
            if (employee[eid] == NULL) {
                s = &sales[sales_idx++];
                s->id = eid;
                s->total = (long long)p * q;
                employee[eid] = s;
            }
            else {
                employee[eid]->total += (long long)p * q;
            }
        }
        for (i = 0, pcnt = 0; i < sales_idx; i++) {
            if (sales[i].total >= 1000000) {
                printf("%d\n", sales[i].id);
                pcnt++;
            }
        }
        if (!pcnt) {
            puts("NA");
        }
    }
    return 0;
}

Measured memory_bytes: 660
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
	int a,b;
	scanf("%i%i",&a,&b);
	if(a>9)	printf("%i",b);
	else printf("%i",b+100*(10-a));
	return 0;
}


Measured memory_bytes: 256