akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll l[n],r[n];
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i==0){l[i]=0;}else{l[i]=__gcd(a[i-1],l[i-1]);}
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){r[i]=0;}else{r[i]=__gcd(a[i+1],r[i+1]);}
  }
  for(int i=0;i<n;i++){
    chmax(ans,__gcd(l[i],r[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 5972
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,ans=0; cin>>n>>k;
    int items[n];
    for(int i = 0; i<n; i++){
        cin >> items[i];
    }
    int a = sizeof(items)/sizeof(items[0]);
    sort(items, items+a);
    for(int i = 0; i<k; i++){
        ans=ans+items[i];
    }
    cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
string s[14],st[14],add[14][14];
int sz[14][14],dp[1<<14][14];
bool iran[14];
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		rep(i,n) iran[i]=0;
		rep(i,n) cin>>s[i];
		rep(i,n){
			rep(j,n){
				if(i==j) continue;
				string x=s[i],y=s[j];
				if(x.size()>y.size()) continue;
				int xs=x.size(),ys=y.size();
				rep(k,ys-xs+1) if(x==y.substr(k,xs)) iran[i]=true;
			}
		}
		int it=0;
		rep(i,n) if(!iran[i]) st[it]=s[i],it++;
		n=it;
		int a[14];
		rep(i,n) a[i]=i;
		rep(i,n) rep(j,n){
			if(i==j) continue;
			string x=st[i],y=st[j];
			int xs=x.size(),ys=y.size(),mx=min(xs,ys);
			bool ok=0;
			for(int m=mx;m>0;m--){
				if(x.substr(xs-m,m)==y.substr(0,m)){
					add[i][j]=y.substr(m,ys-m);
					ok=true;
					break;
				}
			}
			if(!ok) add[i][j]=y;
			sz[i][j]=add[i][j].size();
		}
		int ms=1000000;
		rep(i,1<<n) rep(j,n) dp[i][j]=1e8;
		rep(i,n) dp[1<<i][i]=st[i].size();
		rep(i,1<<n){
			rep(j,n){
				if(((i>>j)&1)==0) continue;
				rep(k,n){
					if((i>>k)&1) continue;
					dp[i+(1<<k)][k]=min(dp[i+(1<<k)][k],dp[i][j]+sz[j][k]);
				}
			}
		}
		rep(i,n) ms=min(ms,dp[(1<<n)-1][i]);
		cout << ms << endl;
	}
}

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

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	string s, t;

	cin >> s;
	cin >> t;

	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int a,b,ans=-1;
  cin >> a >> b;
  rep(i,10000000){
    if (i*8/100==a && i*10/100==b){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ0004
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                var values = line.Split(' ').Select(double.Parse).ToArray();
                var x = (values[4]*values[2] - values[1]*values[5])/(values[0]*values[4] - values[1]*values[3]);
                var y = (values[0]*values[5] - values[3]*values[2])/(values[0]*values[4] - values[1]*values[3]);

                Console.WriteLine("{0:f3} {1:f3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 6056
input = readlines()
r, g, b = input.shift.chomp.split("\s").map{|x| x.to_i}
k = input.shift.chomp.to_i

patterns = [['r'], ['g'], ['b']]

def addNext(current)
  tmp = []
  current.each do |c|
    ['r', 'g', 'b'].each do |n|
      nc = c.clone
      nc.push(n)
      tmp.push(nc)
    end
  end
  return tmp
end

(2..k).each do |t|
  patterns = addNext(patterns)
end


patterns.each do |pattern|
  tmp = {'r' => r, 'g' => g, 'b' => b}
  pattern.each do |target_color|
    tmp[target_color] = tmp[target_color] * 2
  end
  if tmp['g'] > tmp['r'] && tmp['b'] > tmp['g']
    puts 'Yes'
    exit()
  end
end

puts 'No'


Measured memory_bytes: 14928
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
s = gets.chomp
stack = []
ans = 0
s.each_char do |c|
  if(stack != [])
    if c != stack[-1]
      stack.pop
      ans += 2
    else
      stack.push(c)
    end
  else
    stack.push(c)
  end
end
p ans

Measured memory_bytes: 7932
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    string s;
    cin>>s;
    for (int i=0;i<s.length();i++)
    {
        s[i]=(char)(((s[i]-65+n)%26)+65);
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    ll a,b; cin >> a >> b;
    ll x; cin >> x;
    if(b % x != 0) b = (b/x) * x;
    if(a % x != 0) a = (a/x + 1) * x;
    cout << max(b/x - a/x + 1, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
	long long  n,a[100];
	cin>>n;
	a[0]=2;
	a[1]=1;
	for(int i=0;i<n-1;i++){
		a[i+2]=a[i]+a[i+1];
	}
	cout<<a[n]<<endl;
      return(0);
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> i_i;

int f(int W, vector<vector<int> >& dp, int x) {
	vector<int> a, b;
	for (int j = 1; j <= W; j++)
		for (int k = 0; k < 2; k++)
			if (dp[k][j] && dp[k][j] >= x) {
				a.push_back(k);
				b.push_back(j);
			}
	int mini = INT_MAX;
	for (int i = 0; i + 1 < a.size(); i++)
		if (a[i] != a[i + 1])
			mini = min(mini, b[i + 1] - b[i]);
	return mini;
}

int main() {
	vector<int> N(2);
	int W;
	cin >> N[0] >> N[1] >> W;
	vector<vector<int> > m(2), c(2);
	for (int k = 0; k < 2; k++) {
		vector<i_i> p(N[k]);
		for (int i = 0; i < N[k]; i++)
			cin >> p[i].second >> p[i].first;
		sort(p.begin(), p.end());
		for (int i = 0; i < N[k]; i++) {
			m[k].push_back(p[i].second);
			c[k].push_back(p[i].first);
		}
		c[k].push_back(INT_MAX);
	}
	vector<int> i(2);
	vector<vector<int> > dp(2, vector<int>(W + 1));
	int mini = INT_MAX;
	for (;;) {
		if (i[0] == N[0] && i[1] == N[1]) break;
		int k = (c[0][i[0]] > c[1][i[1]]);
		int M = m[k][i[k]], C = c[k][i[k]];
		for (int j = W - M; j > 0; j--)
			if (dp[k][j]) {
				int _j = j + M;
				dp[k][_j] = max(dp[k][_j], dp[k][j]);
			}
		if (M <= W) dp[k][M] = C;
		int lb = 0, ub = C;
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;
			if (f(W, dp, C - mid) < mid) ub = mid;
			else lb = mid;
		}
		mini = min(mini, max(f(W, dp, C - lb), lb));
		mini = min(mini, max(f(W, dp, C - lb - 1), lb + 1));
		i[k]++;
	}
	cout << mini << endl;
}

Measured memory_bytes: 1564
#include<cstdio>

const int MAX_N = 1e5;
int n;
char s[MAX_N + 1];

bool solve(char *t) {
    for (int i = 1; i < n - 2; i++) {
        if (s[i] == 'x') {
            if (t[i] == 'S') {
                if (t[i - 1] == 'S') t[i + 1] = 'W';
                else t[i + 1] = 'S';
            }
            else {
                if (t[i - 1] == 'S') t[i + 1] = 'S';
                else t[i + 1] = 'W';
            }
        }
        else {
            if (t[i] == 'S') {
                if (t[i - 1] == 'S') t[i + 1] = 'S';
                else t[i + 1] = 'W';
            }
            else {
                if (t[i - 1] == 'S') t[i + 1] = 'W';
                else t[i + 1] = 'S';
            }
        }
    }

    if (s[n - 2] == 'x') {
        if (t[n - 2] == 'S' && t[n - 3] == t[n - 1]) return false;
        if (t[n - 2] == 'W' && t[n - 3] != t[n - 1]) return false;
    }
    else {
        if (t[n - 2] == 'S' && t[n - 3] != t[n - 1]) return false;
        if (t[n - 2] == 'W' && t[n - 3] == t[n - 1]) return false;
    }
    if (s[n - 1] == 'x') {
        if (t[n - 1] == 'S' && t[n - 2] == t[0]) return false;
        if (t[n - 1] == 'W' && t[n - 2] != t[0]) return false;
    }
    else {
        if (t[n - 1] == 'S' && t[n - 2] != t[0]) return false;
        if (t[n - 1] == 'W' && t[n - 2] == t[0]) return false;
    }
    return true;
}


int main() {
    scanf("%d", &n);
    scanf("%s", s);

    char ans[4][n + 1];
    for (int i = 0; i < 4; i++) ans[i][n] = 0;
    if (s[0] == 'x') {
        ans[0][0] = 'S'; ans[1][0] = 'S';
        ans[2][0] = 'W'; ans[3][0] = 'W';
    }
    else {
        ans[0][0] = 'W'; ans[1][0] = 'W';
        ans[2][0] = 'S'; ans[3][0] = 'S';
    }
    ans[0][1] = 'S'; ans[0][n - 1] = 'W';
    ans[1][1] = 'W'; ans[1][n - 1] = 'S';
    ans[2][1] = 'S'; ans[2][n - 1] = 'S';
    ans[3][1] = 'W'; ans[3][n - 1] = 'W';

    for (int i = 0; i < 4; i++) {
        if (solve(ans[i])) {
            printf("%s\n", ans[i]);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <string>

int countAligned(std::map<char, std::set<int>> &char2pos,
                 const char a, const char b, const char c) {
  int ans = 0;
  for (int i : char2pos[a]) {
    for (int j : char2pos[b]) {
      if (((i + j) & 1) != 0) {
        continue;
      }
      int k = (i + j) >> 1;
      if (char2pos[c].find(k) != char2pos[c].end()) {
        ans += 1;
      }
    }
  }
  return ans;
}

int main() {
  int len;
  std::string s;
  std::cin >> len;
  std::cin >> s;
  std::map<char, std::set<int>> char2pos;
  for (int pos = 0; pos < s.size(); pos++) {
    char2pos[s[pos]].insert(pos);
  }
  long int ans = char2pos['R'].size() * char2pos['G'].size() * char2pos['B'].size();
  ans -= countAligned(char2pos, 'R', 'G', 'B');
  ans -= countAligned(char2pos, 'R', 'B', 'G');
  ans -= countAligned(char2pos, 'G', 'B', 'R');
  std::cout << ans << std::endl;
}



Measured memory_bytes: 3776
N,Y=map(int,input().split())

f=0
for i in range(N+1):
    for j in range(N+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y and N-i-j>=0:
            print(str(i)+(" ")+str(j)+(" ")+str(N-i-j))
            f=1
            break
    else:
        continue
    break
if f==0:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) a.begin(), (a).end()
#define inf = 9876543210
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    for(char c:n){
        if(c=='1'){
            cout<<9;
        }else{
            cout<<1;
        }
    }
return 0;
}

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

int main(){
  int N,M,X;
  cin >>N>>M>>X;
  
  vector<int> S(M,0);
  vector<vector<int>> A(N,vector<int>(M+1));
  for(int i=0;i<N;i++){
    for(int j=0;j<M+1;j++){
      cin >>A[i][j];
      S[j]+=A[i][j];
    }
  }
  
  int ans=10000000,e=0,cnt=0,d=0;
  for(int i=0;i<1<<N;i++){
    vector<int> S(M,0);
    int an=0;
    d=0;
    for(int j=0;j<N;j++){
      if(i>>j&1){
        an+=A[j][0];
        for(int k=1;k<M+1;k++){
          S[k-1]+=A[j][k];
        }
      }
      if(j==N-1){
        for(int k=1;k<M+1;k++){
            if(S[k-1]>=X){
              if(k==M){
                d=1;
                continue;
              }
             
            }
            else{
              break;
            }
        }
      }
          
      if(j==N-1 && d==1 ){
        ans=min(ans,an);
        e=1;
      }
    }
  }
  if(e){
  cout << ans <<endl;
  }
  else{
    cout << -1 <<endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-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;
} 


template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    T find(int a, int b) {
        ll val_left = def, val_right = def;
        for (a += (n - 1), b += (n - 1); a < b; a >>= 1, b >>= 1)
        {
            if ((a & 1) == 0){
                val_left = operation(val_left, data[a]);
            }
            if ((b & 1) == 0){
                val_right = operation(val_right, data[--b]);
            }
        }
        return operation(val_left, val_right);
    }
    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }
    void set(int i, T x) { data[i + n - 1] = x; }
    void build() {
        for (int k=n-2;k>=0;k--) data[k] = operation(data[2*k+1],data[2*k+2]);
    }
    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        //return _query(a, b, 0, 0, n);
        return find(a,b);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};



int main(){
    ll n,k;cin >> n >>k;
    SegTree<ll> al(n,0,[](ll a,ll b){return a+b;},[](ll a,ll b){return b;}),pl=al;
    rep(i,n){
        ll t;cin >> t;
        al.change(i,t);
        if(t>0)pl.change(i,t);
    }
    ll ans=0;
    rep(i,n-k+1){
        chmax(ans,pl.query(0,i)+pl.query(i+k,n));
        //cout << pl.query(0,i)+pl.query(i+k,n) <<endl;
    }
    rep(i,n-k+1){
        chmax(ans,pl.query(0,i)+pl.query(i+k,n)+al.query(i,i+k));
    }
    cout << ans <<endl;
}

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

#define MAX_N 300

int x[MAX_N][MAX_N];
int n, a, cx, cy, cnt;

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

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (i >= 1) { cout << endl; }
		cnt = 0;
		cin >> a;
		for (int j = 0; j < MAX_N; j++) {
			for (int k = 0; k < MAX_N; k++) {
				x[j][k] = 0;
			}
		}
		cx = 0; cy = a - 1;
		x[cy][cx] = 1;
		while (cnt < a) {
			while (true) {
				int Y1 = cy + dy[cnt % 4];
				int X1 = cx + dx[cnt % 4];
				int Y2 = cy + dy[cnt % 4] * 2;
				int X2 = cx + dx[cnt % 4] * 2;
				if (Y1 >= 0 && Y1 < a && X1 >= 0 && X1 < a) {
					if (Y2 >= 0 && Y2 < a && X2 >= 0 && X2 < a) {
						if (x[Y2][X2] == 1) {
							break;
						}
					}
				}
				else {
					break;
				}
				cx = X1; cy = Y1;
				x[cy][cx] = 1;
			}
			cnt++;
		}
		for (int j = 0; j < a; j++) {
			for (int k = 0; k < a; k++) {
				if (x[j][k] == 1) {
					cout << '#';
				}
				else {
					cout << ' ';
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] a = new String[h][w];
        boolean[][] b = new boolean[h][w];
        for (int i = 0 ; i < h ; i++) {
            String s = sc.next();
            for (int j = 0 ; j < w ; j++) {
                a[i][j] = s.substring(j, j + 1);
                b[i][j] = true;
            }
        }
// 白：.黒：#
        for (int i = 0 ; i < h ; i++) {
            boolean isAllWhite = true;
            for (int j = 0 ; j < w ; j++) {
                if (a[i][j].equals("#")) {
                    isAllWhite = false;
                }
            }
            for (int j = 0 ; j < w ; j++) {
                if (isAllWhite) {
                    b[i][j] = false;
                }
            }
        }

        for (int j = 0 ; j < w ; j++) {
            boolean isAllWhite = true;
            for (int i = 0 ; i < h ; i++) {
                if (a[i][j].equals("#")) {
                    isAllWhite = false;
                }
            }
            for (int i = 0 ; i < h ; i++) {
                if (isAllWhite) {
                    b[i][j] = false;
                }
            }
        }

        for (int i = 0 ; i < h ; i++) {
            boolean c = false;
            for (int j = 0 ; j < w ; j++) {
                if (b[i][j]) {
                    System.out.print(a[i][j]);
                    c = true;
                }
            }
            if (c) {
                System.out.println("");
            }
        }
    }

}

Measured memory_bytes: 25292
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> p;//あるかないかを高速判定
    set<int> sc;
    rep(i,n){
        cin>>a[i];
        p[a[i]]++;
    }
    all(a);
    int ans=0;
    int amax=a[n-1];
    vector<int> dp(amax+2,0);
    rep(i,n){
        if(dp[a[i]]==0){
            dp[a[i]]=1;
            int j=2;
            while(a[i]*j<=amax){
                dp[a[i]*j]=1;
                j++;
            }
            if(p[a[i]]==1){
            ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17096
from collections import defaultdict
n = int(input())
chars = [input() for _ in range(n)]
set_chars = set(chars[0])
d = defaultdict(lambda: 10**10)

# 候補となる文字を先に用意
for char in chars[1:]:
    set_chars = set_chars.intersection(set(char))


for i in range(n):
    for c in set(chars[i]):
        if c not in set_chars:
            continue
        cnt = chars[i].count(c)
        if cnt < d[c]:
            d[c] = cnt

s = ''
for c in 'abcdefghijklmnopqrstuvwxyz':
    if c in d:
        s += c * d[c]
print(s)


Measured memory_bytes: 3316
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
vector<ll> A,B;
int main(){
	cin>>N;
	string str;
	string hoge1,hoge2;
	int lef=0,rig=N-1;
	cout<<0<<endl;
	cin>>hoge1;
	if(hoge1=="Vacant")return 0;
	int fuga=N/2;
	if(fuga%2!=0)fuga++;
	cout<<fuga<<endl;
	cin>>hoge2;
	if(hoge2=="Vacant")return 0;
	string lefstr,rigstr;
	if(hoge1==hoge2){
		lef=fuga+1;
		rig=N-1;
		lefstr=hoge2;
		rigstr=hoge1;
	}else{
		lef=1;
		rig=fuga-1;
		lefstr=hoge1;
		rigstr=hoge2;
	}
	while(rig-lef>1){
		int mid=(lef+rig)/2;
		cout<<mid<<endl;
		cin>>str;
		if(str=="Vacant")return 0;
		int check=(mid-lef)%2;
		if(check==0){
			if(lefstr==str){
				rig=mid-1;
				rigstr=str;
			}else{
				lef=mid+1;
				lefstr=str;
			}
		}else{
			if(lefstr==str){
				lef=mid+1;
				lefstr=str;
			}else{
				rig=mid-1;
				rigstr=str;
			}
		}
	}
	for(int i=lef;i<=rig;i++){
		cout<<i<<endl;
		cin>>str;
		if(str=="Vacant")return 0;
	}
}


Measured memory_bytes: 852
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
 
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[];
        //String s = stdIn.next();
        int gomi = stdIn.nextInt();
        String s = stdIn.next();
        char c[] = s.toCharArray();
        int count = 0;
        //int sum = 0;
        //boolean flag = true;
        for(int i = 0; i < s.length() - 2; i++){
            if(c[i] == 'A' && c[i + 1] == 'B' && c[i + 2] == 'C'){
                count++;
            }
        }
 
        System.out.println(count);
 
        //System.out.println();
        //System.out.print();
 
        stdIn.close();
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

bool is_ok(ll num)
{
  for (int i = 2; i * i <= num; i++)
  {
    if (num % 5 != 1)
      return false;
    if (num % i == 0)
      return false;
  }

  return true;
}

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

  vector<ll> primes;
  primes.push_back(11);

  ll tmp = 31;
  int count = 1;
  while (count < n)
  {
    if (is_ok(tmp))
    {
      primes.push_back(tmp);
      count++;
    }
    tmp++;
  }

  for (ll num : primes)
  {
    cout << num << " ";
  }
  return 0;
}

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

inline long gl(void){
    long x = 0;
    for(;;){
        int c=getchar_unlocked();
        if('0'<= c && c <='9'){
            x = x*10 + c-'0';
        }else{
            break;
        }
    }
    return x;
}

int main(void){
    long n=gl();
    long h=gl();
    vector<long> b(n+1);
    long am=0;
    for(long i=0; i<n; i++){
        long a=gl();
        b[i] = gl();
        am = a>am ? a : am;
    }
    auto pos = partition(b.begin(), b.end(), [am](long x) { return x>am; });
    sort(b.begin(), pos, greater<long>());
    long m=0;
    for(;b[m]>am && h>0; m++){
        h-=b[m];
    }
    if(h>0){
        m+=(h+am-1)/am;
    }
    printf("%ld", m);
    return 0;
}


Measured memory_bytes: 1024
import collections

N = int(input())
a = list(map(int,input().split()))

c = collections.Counter(a)

max_value = -1
for ci in c.most_common():
    cnt = ci[1]

    index = ci[0]
    if index-1 in c:
        cnt += c[index-1]
    if index +1 in c:
        cnt += c[index+1]
    max_value = max(max_value, cnt)

print(max_value)

Measured memory_bytes: 16096
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279


int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    

 	int tt{},T{};
 	//cin>>t;T=t;
    tt=1;
 	while(tt--){
        //cout<<"------------- #"<<T-t<<endl;
        ll n{},m{},ans{10000},k{},a{},b{},c{},f{1};
        string s,t;
        cin>>s;
        cin>>t;
        //cout<<s<<" "<<t;
        a=s.length();
        b=t.length();
        F(i,0,a-b+1){
            c=0;
            F(j,i,i+b){
                if(s[j]!=t[j-i]){
                    ++c;
                }
            }
            ans=min(ans,c);
        }
        cout<<ans<<"\n";
    }
    
    
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int[] x = cin.arrayInt();
        Array.Sort(x);
        Console.WriteLine(x[1] + x[2] * 10 + x[0]);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

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

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11220
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int N;

	cin >> N ;
	vector<ll> A(N+3);

	for (int i = 1; i <= N;i++) {
		cin >> A[i];
	}

	ll c = 0;
	map<int, int>mp;

	for (int i = 1; i <= N; i++) {
		int b = i - A[i];
		int d = i + A[i];
		c += mp[b];
		++mp[d];
	}

	cout << c;

	return 0;
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}




int main() {
  int N,u,v,a,b;
  cin >> N >> u >> v;
  u--;v--;
  vector<vector<int>> tree(N);
  rep(i,N-1){
    cin >> a >> b;
    a--;b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  
  vector<vector<int>> cost(N,vector<int>(2,-1));
  queue<vector<int>> q;
  q.push({0,u});//cost,pos
  while(!q.empty()){
    auto t=q.front();
    q.pop();
    cost[t[1]][0] = t[0];
    for (auto e:tree[t[1]]) {
      if (cost[e][0]==-1) q.push({t[0]+1,e});
    }
  }

  q.push({0,v});//cost,pos
  while(!q.empty()){
    auto t=q.front();
    q.pop();
    cost[t[1]][1] = t[0];
    for (auto e:tree[t[1]]) {
      if (cost[e][1]==-1) q.push({t[0]+1,e});
    }
  }
  int res=0,tmp=0;
  rep(i,N) {
    if (cost[i][1]>cost[i][0]) tmp = cost[i][1]-1;
    chmax(res,tmp);
  }
  cout << res << endl;
}

Measured memory_bytes: 13560
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,m;cin>>n>>m;
    vector<ll> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    sort(ALL(a),greater<ll>());sort(ALL(b),greater<ll>());
    if(a[0]!=m*n||b[0]!=m*n){
        cout<<0<<endl;return 0;
    }
    map<ll,ll> mh,mw;
    rep(i,n){
        if(i!=0&&a[i]==a[i-1]){
            cout<<0<<endl;return 0;
        }
        mh[a[i]]=i+1;
    }
    rep(i,m){
        if(i!=0&&b[i]==b[i-1]){
            cout<<0<<endl;return 0;
        }
        mw[b[i]]=i+1;
    }
    ll ni=1,nj=1,ans=1;
    for(ll num=n*m;num>0;num--){
        if(mh.count(num)>0&&mw.count(num)>0){
            ni=mh[num];nj=mw[num];
        }
        else if(mh.count(num)>0){
            ans=(ans*nj)%mod;
            ni=mh[num];
        }
        else if(mw.count(num)>0){
            ans=(ans*ni)%mod;
            nj=mw[num];
        }
        else{
            ans=(ans*(ni*nj-(n*m-num)))%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[100000];
	int p=0,sc=0;
	cin>>s;
	int l=strlen(s);
	for(int i=0;i<l;i++)
	{
		if(s[i]=='g'){
			if(p>0) p--,sc++;
			else p++;
		}
		else{
			if(p>0) p--;
			else sc--,p++;
		}
	}
	cout<<sc;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];
    sort(l.begin(), l.end());
    rep(i, K) {
        ans += l[N - 1 - i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
# 小さいAと大きいF, 大きいAと小さいFの組を作りたい
A.sort()
F.sort(reverse=True)

# 最大値の最小化 -> 二分探索
# 目標値Xを達成できるか？

# ありうる最小値-1
left = -1
# ありうる最大値+1
right = 10**12 + 1
while right - left > 1:
    mid = (left + right) // 2
    cnt = 0
    for i in range(N):
        # スコアをmidにするために必要な「修行の回数」
        # 負になった場合は0にする（修行は必要ない）
        tmp = max(A[i] - mid // F[i], 0)
        cnt += tmp
    if cnt <= K:
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 113912
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, m) {
        cin >> b[i];
    }
    ll sum = 0;
    int ans = 0;
    int cnt_a = 0, cnt_b = 0;
    rep(i, n) {
        if(sum + a[i] <= k) {
            sum += a[i];
            cnt_a++;
        }
        else{
            break;
        }
    }
    ans = cnt_a;
    for(int i = cnt_a; i >= 0; i--) {
        for(int j = cnt_b; j < m; j++) {
            if(sum + b[j] <= k) {
                sum += b[j];
                cnt_b++;
            }
            else {
                break;
            }
        }
        ans = max(ans, cnt_a + cnt_b);
        cnt_a--;
        sum -= a[i-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <cstdio>
#include <iostream>
#include <algorithm> 
#include <cstring>
#include <map>
using namespace std;
const int N = 2e5 + 10;
map<int,int> h;
int n,a[N],ans;
int main() { 
	cin>>n;
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]),h[a[i]]++;
	for (int t = 1 << 30; t>1; t>>=1) {
		for (int i = 1; i <= n; i++) {
			int ot = t - a[i];
			if (ot == a[i]) {
				if (h[a[i]] >= 2) {
					h[a[i]]-=2; ans++;
				}
				continue;
			}
			if (ot > 0 && h[ot] > 0 && h[a[i]] > 0) {
				h[ot]--;
				h[a[i]]--;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 33664
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

ll dp[3001][3000];

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		string s,t;
		cin>>s>>t;
		ll l1=s.length(),l2=t.length();
		for(ll i=l1-1;i>=0;i--){
			for(ll j=l2-1;j>=0;j--){
				if(s[i]==t[j])
					dp[i][j]=dp[i+1][j+1]+1;
				else{
					dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
				}
			}
		}
		ll i=0,j=0;
		while(i<l1 && j<l2){
				if(s[i]==t[j]){
					cout<<s[i];
					i++,j++;
				}
				else if(dp[i+1][j]>=dp[i][j+1]){
					i++;
				}
				else{
					j++;
				}
		}
		cout << "\n";
		return 0;
	}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

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;
}

int main(){
    int n,s;
    while(cin >> n >> s,n!=0){
        int ans=0;
        for (int bit=0;bit<(1<<10);bit++){
            int flag=0;
            int count=0;
            rep(i,10){
                if (bit&(1<<i)){
                    flag++;
                    count+=i;
                }
            }
            if (flag!=n){
                continue;
            }
            if (count==s){
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3144
#include <cstdio>

int main() {
  //入力
  int a,b,c;
  std::scanf("%d %d %d",&a,&b,&c);
 
  if(a <= b && b <= c) {
    std::printf("%d %d %d" ,a,b,c);
  }
  
  else if(a <= c && c <= b) {
    std::printf("%d %d %d",a,c,b);
  }
  else if(b <= a && a <= c){
    std::printf("%d %d %d",b,a,c);
  }
  else if(b <= c && c <= a){
    std::printf("%d %d %d",b,c,a);
  }
  else if(c <= b && b <= a){
    std::printf("%d %d %d",c,b,a);
  }
  else if(c <= a && a <= b){
    std::printf("%d %d %d",c,a,b);
  }
  std::printf("\n");
  
  
  return 0;
}



Measured memory_bytes: 2708
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define p pair <int,int>
typedef long long ll;
using namespace std;
int main(int argc,char const* argv[])
{
  ll a,b,c,tmpa,tmpb,tmpc,count=0;
  bool miss=false;
  cin >> a >> b >> c;
  tmpa=a;tmpb=b;tmpc=c;
  if(a==b && b==c && a%2 ==0 && b%2 ==0 && c%2 ==0) 
    {
      cout << -1 << endl;
      return 0;
    }
  else
    {
      while(a % 2 ==0 && b % 2 ==0 && c % 2 ==0)
	{
	  a=(tmpb+tmpc)/2;
	  b=(tmpa+tmpc)/2;
	  c=(tmpb+tmpa)/2;
	  if(a==b && b==c)
	    {
	      miss=true;
	      break;
	    }
	  count++;
	  tmpa=a;
	  tmpb=b;
	  tmpc=c;
	}
      if(!miss)
      cout << count << endl;
      else
	{
	  cout << -1 << endl;
	}
	
      return 0;
    }
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())

from decimal import Decimal as de
l=sorted(list(map(int,input().split())),reverse=1)
fact=[1]
for i in range(1,51):
    fact.append(fact[-1]*i)
from collections import Counter as co
if l[0]==l[a-1]:
    def comb(x,y):
        return fact[x]//(fact[y]*fact[x-y]) if x>=y>=0 else 0
    x=co(l)[l[0]]
    print(l[0])
    print(sum(comb(x,i)for i in range(a,b+1)));exit()
ave=de(str(sum(l[:a])))/a
print(ave)

y=co(l[:a])[l[a-1]]
x=co(l)[l[a-1]]
print(fact[x]//(fact[y]*fact[x-y]))

Measured memory_bytes: 9976
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

const long long MOD = 1000000007;
vector<int> places[210000]; // [i] は 色がiであるような数列の場所リスト
long long dp[210000];
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

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

  int N; cin >> N;
  vector<int> c(N);
  rep(i, N) cin >> c[i];

  for (int i = 0; i < 210000; ++i) places[i].clear();
  rep(i, N) places[c[i]].push_back(i);

  dp[0] = 1;
  rep1(i, N) {
    add(dp[i], dp[i-1]);

    int color = c[i-1];
    int it = lower_bound(places[color].begin(), places[color].end(), i-1) - places[color].begin(); // 今のindexは同じ色で何番目か
    if(it > 0) {
      int j = places[color][it - 1]; // 前回出現した同じ色のindex
      if ((i-1) - j > 1) add(dp[i], dp[j+1]); // 同じ色が連続していなければ加算
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  int N; string S;
  cin >> N >> S;
  int ans = 0;
  for(int i=0; i<S.size()-2; ++i) {
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
A,B,C,X,Y =map(int,input().split())
ans = 10**9
for c in range(max(2*X,2*Y)+1):
    ans = min(ans, A*max(0,math.ceil(X-c/2))+B*max(0,math.ceil(Y-c/2))+C*c)
print(ans)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int x,y,z;cin >>x>>y>>z;
    cout <<z<<" "<<x<<" "<<y<<endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
	int i;
	int A[100], B[100], C[100];
	int N;
	int sum=0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (i = 0; i < N; ++i) {
		cin >> B[i];
	}
	 for (i = 0; i < N-1; ++i) {
		 cin >> C[i];
       }


	 for (i = 0; i < N; ++i) {
		 sum+= B[A[i]-1] ;
		 if (A[i - 1] + 1 == A[i]) {
			 sum += C[A[i] - 2];
		 }
	 }
	 cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
;
int dx[]={-1,-1,0,1,1,0};
int dy[]={0,-1,-1,0,1,1};
bool block[205][205];
int mincost[205][205];
int n,t,sx,sy;

struct Loc
{
  int x,y,turn;
  Loc(int _y,int _x,int _turn)
  {
    x=_x,y=_y,turn=_turn;
  }
};

int main(int argc,char const* argv[])
{
  while(1)
    {
      memset(block,false,sizeof(block));
      cin >> t >> n;
      if(!t) break;
      for(int i=0;i<n;i++)
	{
	  int x,y;
	  cin >> x >> y;
	  x+=100;
	  y+=100;
	  block[y][x]=true;
	}
      cin >> sx >> sy;
      sx+=100;
      sy+=100;
      for(int i=0;i<=200;i++)
	{
	  for(int j=0;j<=200;j++)
	    {
	      mincost[i][j]=1000000;
	    }
	}
      mincost[sy][sx]=0;
      queue<Loc> q;
      q.push(Loc(sy,sx,0));
      while(!q.empty())
	{
	  Loc now=q.front();
	  q.pop();
	  now.turn++;
	  if(now.turn > t) continue;
	  for(int k=0;k<6;k++)
	    {
	      int nx=now.x+dx[k];
	      int ny=now.y+dy[k];
	      if(0<=nx && nx<=200 && 0<=ny && ny<=200)
		{
		  if(mincost[ny][nx]<=now.turn) continue;
		  if(block[ny][nx]) continue;
		  mincost[ny][nx]=now.turn;
		  q.push(Loc(ny,nx,now.turn));
		}
	    }
	}
      int ans=0;
      for(int i=0;i<=200;i++)
	{
	  for(int j=0;j<=200;j++)
	    {
	      if(mincost[i][j]!=1000000) ans++;
	    }
	}
      cout << ans << endl;
    }
  return 0;
}





Measured memory_bytes: 3196
import sys
input = sys.stdin.readline

N, T = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

DP = [[[0] * 2 for _ in range(T)] for _ in range(2)]

a, b = AB[0]
if a < T:
  DP[0][a][0] = b
DP[0][0][1] = b

t = 1
for i in range(1, N):
  a, b = AB[i]
  if a < T:
    DP[t][a][0] = b
  DP[t][0][1] = b
  for j in range(T):
    DP[t][j][0] = max(DP[t][j][0], DP[1 - t][j][0])
    DP[t][j][1] = max(DP[t][j][1], DP[1 - t][j][1])
    if j + a < T: 
      DP[t][j + a][0] = max(DP[t][j + a][0], DP[1 - t][j][0] + b)
      DP[t][j + a][1] = max(DP[t][j + a][1], DP[1 - t][j][1] + b)
    DP[t][j][1] = max(DP[t][j][1], DP[1 - t][j][1])
    DP[t][j][1] = max(DP[t][j][1], DP[1 - t][j][0] + b)
  t = 1 - t
ans = 0
for i in range(T):
  ans = max(ans, DP[1 - t][i][0])
  ans = max(ans, DP[1 - t][i][1])

print(ans)

Measured memory_bytes: 70376
#include <iostream>
#include <string>
int main(){
    using namespace std;
    string s;
    int ans,x,y,size,i,j;
    ans = 0;
    i = 0;
    x = 1;
    while(x){
        cin >> s;
        if(s=="0"){break;}
        size = s.size();
        for(j=0;j<size;j++){
            y = s[j]-'0';
            ans = ans + y;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}



Measured memory_bytes: 3144
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import decimal
import math
"""
def input():
    return sys.stdin.readline()
"""

def resolve():
    input_list = list(input().split())

    for i, n  in enumerate(input_list):
        if i == 0:
            a = int(n)
        else:
            b = float(n)

    dec_a = decimal.Decimal(a)
    dec_b = decimal.Decimal(b)
    dec_b = round(dec_b, 3)
    ans = dec_a * dec_b


    ans = math.floor(ans)
    print(int(ans))

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 10072
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("AC", 0);
		map.put("WA", 0);
		map.put("TLE", 0);
		map.put("RE", 0);
		for (int i=0;i<N;i++) {
			String S = sc.next();
			map.put(S, map.get(S)+1);
		}
		System.out.println("AC x "+map.get("AC"));
		System.out.println("WA x "+map.get("WA"));
		System.out.println("TLE x "+map.get("TLE"));
		System.out.println("RE x "+map.get("RE"));
	}
}

Measured memory_bytes: 58348
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x%(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  else:
    x = x+1
print(x)

Measured memory_bytes: 3060