akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    map<char,int> ans,tmp;
    int n;
    cin>>n;
    rep(i,n){
        tmp.clear();
        map<char,int> m;
        string s;
        cin>>s;
        rep(i,s.size())m[s[i]]++;
        if(!i)ans=m;
        else {
            irep(j,m){
                if(ans.find(j->first)==ans.end()){
                    continue;
                } else {
                    tmp[j->first]=min(m[j->first],ans[j->first]);
                }
            }
            ans=tmp;
        }
        // irep(j,ans){
        //     char c=j->first;
        //     int num=j->second;
        //     rep(j,num)cout<<c;
        // }
        // cout<<"\n\n";
    }
    irep(i,ans){
        char c=i->first;
        int num=i->second;
        rep(j,num)cout<<c;
    }
    cout<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, j, n, minj, swap, flag=0, count=0, A[100];

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

  for( i= 0 ; i<n ; i++ ){
    minj = i;
    for( j=i ; j<n ; j++ ){
      if(A[j]<A[minj]){
	minj = j;
	flag = 1;
      }
    }
    swap = A[i];
    A[i] = A[minj];
    A[minj] = swap;
    if(flag==1){
      count++;
      flag =0;
    }
  }
  for( i=0 ; i<n-1 ; i++ )
    printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
    string buff;
    cin >> buff;

    char *temp = new char [buff.size()];
    memcpy(temp, buff.c_str(), buff.size());

    for(size_t i = 0; i < buff.size(); ++i)    
    {
        char c = temp[i];
        if(c == '?')
        {
            temp[i] = 'D';
        }
    }

    cout << temp << endl;

    delete temp;

    return 0;    
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vl vector<ll>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = a; i < (b); ++i)

int main() {

    int N;
    cin >> N;

    vector<int> f(N+1, 0);
    FOR(x, 1, 101) {
        FOR(y, 1, 101) {
            FOR(z, 1, 101) {
                int n = x*x + y*y + z*z + x*y + y*z + z*x;
                if (n <= 10000) f[n]++;
            }
        }
    }

    FOR(i, 1, N+1) cout << f[i] << endl;

    return 0;
}


Measured memory_bytes: 3664
n = int(input())
p = list(map(int,input().split()))
ans = []

for i in range(n-2):
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
        ans.append(p[i+1])
print(len(set(ans)))


Measured memory_bytes: 2940
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
cost=[0]*N
for i in range(N):
  cost[i]=V[i]-C[i]
ans=0
for i in range(N):
  if cost[i]>0:
    ans+=cost[i]
print(ans)

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

int     main() {
        vector<int> A(3);
        for (int i=0; i<3; i++) {
                cin >>A.at(i);
        }
        sort(A.begin(), A.end());
        cout <<A.at(2)*10+A.at(1)+A.at(0) << endl;
        return 0;
}

Measured memory_bytes: 256
N = gets.to_i+1
d_array=gets.chomp.split(" ").map(&:to_i).push(0)

# 0か12が2つあったら0
if d_array.count(0) >= 2 || d_array.count(12) >= 2
    puts 0
    exit
end

# 同じのが3つあったら0
if !d_array.group_by{ |e| e }.select { |k, v| v.size >=3 }.empty?
    puts 0
    exit
end

# 要素が24あったら1
if d_array.size == 24
    puts 1
    exit
end

# その他
def calc_s(array)
    size = array.length
    sorted = array.sort
    diffs = sorted.map.with_index.map do |e, i|
        if i == size - 1
            24 + sorted[0] - sorted[i]
        else
            sorted[i+1] - sorted[i]
        end
    end
    return diffs.min
end

ret = 0
[1, -1].repeated_permutation(N) do |permu|
    target_array = d_array.map.with_index { |e, i| e*permu[i] }
    s = calc_s(target_array)
    if s > ret
        ret = s
    end
end
puts ret


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot,n,m;
int A[N],B[N],C[N],id[N];
int fa[N],vis[N];
ll mx[N],S[N];
bool cmp(int x,int y){
	return C[x]<C[y];
}
int get(int x){
	return x==fa[x]?x:fa[x]=get(fa[x]);
}
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) scanf("%d%d",&A[i],&B[i]);
	For(i,1,n) C[i]=max(0,A[i]-B[i]),id[i]=i;
	For(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	sort(id+1,id+n+1,cmp);
	For(i,1,n) fa[i]=i;
	For(i,1,n){
		int x=id[i]; vis[x]=1;
		mx[x]=C[x]; S[x]=B[x];
		for (int j=head[x];j;j=e[j].next)
			if (vis[e[j].to]&&get(e[j].to)!=get(x)){
				int y=get(e[j].to);
				mx[x]=min(mx[x],mx[y]+max(0ll,C[x]-(S[y]+mx[y])));
				S[x]=S[x]+S[y]; fa[y]=x;
			}
	}
	printf("%lld",S[get(1)]+mx[get(1)]);
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n, m;
ll fac[maxn];
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
}
int main()
{
	pre();
	scanf("%d%d", &n, &m);
	if(n < m) swap(n, m);
	if(n == m)
	{
		ll ans = 2 * fac[n] * fac[n] % mod;
		cout << ans << endl;
	}
	else if(n == m + 1)
	{
		ll ans = fac[n] * fac[m] % mod;
		cout << ans << endl;
	}
	else
		puts("0");
	return 0;
}
	 

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


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

    for (int i=0;i<=x/100;i++) {
        if(i*100<=x&&i*105>=x){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//---------------------------------------------
// Mr.HITMAN/hblord787
// Solution for Problem Code : B - Raccoon  vs Monster
// Contest : Beginner 153 
//-------------------------------------------- 
int main() {
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////    
	ios_base::sync_with_stdio(false); // fast io
	cin.tie(NULL);
	cout.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    int n,k;
    cin >> n >> k;
    int arr[k];
  	long long int sum = 0;
  	for(int i = 0; i < k; i++)
  	    {
  	        cin >> arr[i];
  	        sum = sum + arr[i];
  	    }
  	    //cout << sum << "\n";
  	 if( sum >= n)
  	 {
  	     cout << "Yes";
  	 }
  	 else 
  	 {
  	     cout << "No";
  	 }	
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
using namespace std;
struct point{double x,y;};
void koch(int n,point a,point b)
{
    if(n==0)return;
    point s,t,u;
    double th=M_PI*60.0/180.0;
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
        u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
        koch(n-1,a,s);
        printf("%.8f %.8f\n",s.x,s.y);
        koch(n-1,s,u);
         printf("%.8f %.8f\n",u.x,u.y);
          koch(n-1,u,t);
         printf("%.8f %.8f\n",t.x,t.y);
         koch(n-1,t,b);
}
int main()
{
    point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f",b.x,b.y);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	pi v;
	int N;
	v.PB(2);
	int moment_number = 3;
	cin >> N;
	bool accepted = true;
	if(N == 2) cout << 2;
	else{
		while(true){
			accepted = true;
			REP(i, 0, (int)v.size()){
				if(moment_number % v[i] == 0){
					accepted = false;
					break;
				}
			}
			if(accepted) v.PB(moment_number);
			
			if(moment_number >= N && accepted) break;
			
			++moment_number;
		}
		cout << moment_number;
	}
	

}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	H := readInt()
	N := readInt()
	AB := make([]struct{ A, B int }, N)
	for i := 0; i < N; i++ {
		AB[i].A = readInt()
		AB[i].B = readInt()
	}

	dp := make([]int, H+1)
	fill(dp, math.MaxInt64)

	dp[0] = 0
	for i := 0; i < H; i++ {
		if dp[i] == math.MaxInt64 {
			continue
		}
		for j := 0; j < N; j++ {
			t := i + AB[j].A
			if t > H {
				t = H
			}
			if dp[i]+AB[j].B < dp[t] {
				dp[t] = dp[i] + AB[j].B
			}
		}
	}

	fmt.Println(dp[H])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
using namespace std;
//
// Created by karayuu on 2018-12-19.
//
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    while (!(a <= b && b <= c)) {
        if (a > b) {
            swap(a, b);
        }
        if (b > c) {
            swap(b, c);
        }
        if (a > c) {
            swap(a, c);
        }
    }

    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}



int main()
{
string s;
cin>>s;
ll f1=1;
ll f2=1;
ll f3=1;
ll n=s.size();
for(ll i=0;i<n;i++){
    if(s[i]!=s[n-1-i]){
        f1=0;
        break;

    }



}


for(ll i=0;i<(n-1)/2;i++){
    if(s[i]!=s[(n-1)/2-i-1]){
        f2=0;
        break;

    }



}


for(ll i=(n+1)/2;i<n;i++){
    if(s[i]!=s[n-1-i]){
        f3=0;
        break;

    }



}
if(f1&&f2&&f3)cout<<"Yes";
else cout<<"No";

    return 0;

}


Measured memory_bytes: 256
import Data.List
main = mapM_ (print . solve) . analyze . map read . lines =<< getContents
analyze (n:cs) = (n,as):analyze bs where (as,bs) = splitAt n (cs)
analyze [] = []
solve (n,as) = f 0 as
f c (a1:a2:as) = f (c+(a1+a2)`div`2) (min a2 ((a1+a2)`mod`2):as)
f c (a1:as) = c+a1`div`2

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<int> v;
  rep(i,3){
    int a;
    cin >> a;
    v.push_back(a);
  }

  bool flg = false;
  if(v[0] == v[1] && v[0] != v[2]) flg = true;
  if(v[0] == v[2] && v[0] != v[1]) flg = true;
  if(v[1] == v[2] && v[0] != v[1]) flg = true;

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    ll A[N]; rep(i, N) cin >> A[i];
    ll sum[N + 1]; //[0, i) の和
    map<ll, ll>mp;
    sum[0] = 0;
    mp[0]++;
    rep(i, N) sum[i + 1] = sum[i] + A[i], mp[sum[i + 1]]++;
    ll ans = 0;
    for(auto i = mp.begin(); i != mp.end(); ++i) {
        ans += (i->second) * (i->second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int a[100005];
int b[100005];

int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	vector<int> pool;
	int need = 0;
	int change = 0;
	for(int i=1;i<=n;i++){
		if(a[i]>b[i]){
			pool.push_back(a[i]-b[i]);
		}
		else {
			change += (a[i]!=b[i]);
			need += (b[i]-a[i]);
		}
	}
	sort(all(pool),greater<int>());
	for(auto x:pool){
		if(!need){
			break;
		}
		need = max(0LL,need-x);
		change++;
	}
	if(need){
		cout<<-1;
		return 0;
	}
	cout<<change;
}


Measured memory_bytes: 2428
a=input()
if a=="SUN":
    print(7)
elif a=="MON":
    print(6)
elif a=="TUE":
    print(5)
elif a=="WED":
    print(4)
elif a=="THU":
    print(3)
elif a=="FRI":
    print(2)
elif a=="SAT":
    print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
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; }

using P = pair<int, int>;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];
  int ans = 0;
  rep(i, h) rep(j, w) {
    if (grid[i][j] == '#')
      continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[i][j] = 0;
    queue<P> que;
    que.push({i, j});
    while (!que.empty()) {
      int x, y;
      tie(x, y) = que.front();
      que.pop();
      rep(i, 4) {
        if (x+dx[i] < 0 || x+dx[i] >= h || y+dy[i] < 0 || y+dy[i] >= w)
          continue;
        if (grid[x+dx[i]][y+dy[i]] == '#')
          continue;
        if (chmin(dist[x+dx[i]][y+dy[i]], dist[x][y]+1)) {
          chmax(ans, dist[x][y]+1);
          que.push({x+dx[i], y+dy[i]});
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n;
	string s;
	cin>>n>>s;
	int m=s.size();
	
	if(m<=n)
		cout<<s;
	else
	{
		for(int i=0;i<n;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n, m;
VVI adj;
int pathCount(int here, VB visited)
{
	visited[here] = true;
	if(count(ALL(visited), true) == n)
		return 1;

	int ret = 0;
	for(auto there : adj[here])
		if(!visited[there])
			ret += pathCount(there, visited);
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> m;

	adj = VVI(n);
	VB visited(n, false);
	int u, v;
	for(int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		--u; --v;
		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}

	cout << pathCount(0, visited) << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int s = 0;
  if (N/100000 > 0) s = 90909;
  else if (N/10000 > 0) s = N - 9999 + 909;
  else if (N/1000 > 0) s = 909;
  else if (N/100 > 0) s = N - 99 + 9;
  else if (N/10 > 0) s = 9;
  else if (N > 0) s = N;
  else s = 0;
  
  cout << s;
  return 0;
}


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

const ll MOD = 1e9 + 7;

int main(void){
    int s;
    cin >> s;
    vector<int> dp(s + 1);
    fill(dp.begin(), dp.end(), 0);
    dp[0] = 1;
    for(int i = 3; i <= s; ++i){
        for(int j = i - 3; j >= 0; --j){
            dp[i] = (dp[i] + dp[j]) % MOD;
        }
    }
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3612
N = input()

N = [int(i) for i in list(N)][::-1] + [0]
# print(N)
lenN = len(N)

dp = [[float('inf')]*2 for _ in range(len(N)+1)]
dp[0][0] = 0


for i in range(1, len(N)+1):
    res0 = float('inf')
    res1 = float('inf')

    for j in range(2):
        for num in range(10):
            if j == 1:
                # 前に繰り下がりしていたらnumを減らす
                num = num - 1
            if num >= N[i-1]:
                b = num - N[i-1]
                res0 = min(res0, dp[i - 1][j] + num + b + j)
            else:
                b = num - N[i-1] + 10
                res1 = min(res1, dp[i - 1][j] + num + b + j)
    dp[i][0] = res0
    dp[i][1] = res1

# print(dp)

print(min(dp[lenN][0], dp[lenN][1]))


Measured memory_bytes: 197756
#include <cstdio>
#include <algorithm>

using namespace std;

typedef int weight_t;
int W,N;

int tbl[2][1001];

int main(){
    int round=0;
    while(scanf("%d",&W)&&W!=0){
        round++;
        scanf("%d",&N);
        //初期化
        for(int i=0;i<=W;i++)
            tbl[0][i] = 0, tbl[1][i] = 0;
        tbl[0][0]=0;



        //動的計画法
        for (int i=0;i<N;i++){
            int v,w;
            scanf("%d,%d",&v,&w);

            // printf("%d",i);
            int index=i%2;
            //jはweightのループ変数
            for (int j=0;j<=W;j++){
                int next_index=(index+1)%2;
                //宝物をとらない選択肢
                tbl[next_index][j] = max(tbl[next_index][j], tbl[index][j]);

                //宝物をとる選択肢
                int new_weight=j+w;
                if (new_weight<=W){
                    tbl[next_index][new_weight]=max(tbl[next_index][new_weight],tbl[index][j]+v);
                }

            }

            // for (int k=0;k<)
        }

        int final_index = N % 2;
        int value = 0, weight = 0;
        for (int i = 0; i <= W; i++)
        {
            if (tbl[final_index][i] > value)
            {
                value = tbl[final_index][i];
                weight = i;
            }
        }

        printf("Case %d:\n%d\n%d\n", round, value, weight);
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
 for ( int i = 0; i < n; i++ ){
   string s;
   cin >> s;
   if ( s == "Y" ){
     cout << "Four" << endl;
     break;
   }
   else if ( i == n - 1 ) {
     cout << "Three" << endl;
   }
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
vector<int> G[N];
int n;
int dp[N][2];

int dfs(int u,int par,int color){
    int cur=1;
    
    if(dp[u][color]!=-1) return dp[u][color];
    for(int i:G[u]){
       // a=1,b=0;
        if(i!=par){
          int  a = dfs(i,u,0);

            if(!color){
             int   b = dfs(i,u,1);
             a = (a+b)%mod;
            }
            cur = (cur*a)%mod;
        }
        
    }
    return dp[u][color] = cur;
}

int32_t main()
{
    
   
    crap;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        G[x].pb(y);
        G[y].pb(x);
    }

    int ans1 = dfs(1,-1,0);
    int ans2 = dfs(1,-1,1);
    cout<<(ans2+ans1)%mod<<endl;
    
}

Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	string s; cin >> s;
	if(s.size()==3){
		cout << s[2] << s[1] << s[0] << endl;
	}
	else{
		cout << s << endl;
	}
}

Measured memory_bytes: 256
import math

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


n,d=input2()
xy=[]
for _ in range(n):
	xy.append(input_array())
count=0

for i in xy:
	di=math.sqrt(float(i[0]**2 + i[1]**2))
	if di <= d:
		count+=1
print(count)


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

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

constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr int ddx[] = {1,1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr int ddy[] = {1,-1,1,-1,0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
constexpr int INF = 1<<28;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,C_h,C_w,D_h,D_w;
  cin>>H>>W>>C_h>>C_w>>D_h>>D_w;
  C_h--,C_w--,D_h--,D_w--;
  vector<string> S(H);
  rep(i,H)cin>>S[i];

  vector dist(H,vector(W,INF));
  dist[C_h][C_w] = 0;
  deque<int> deq;
  deq.emplace_front(C_h*W+C_w);
  while(!deq.empty()){
    int cur = deq.front();
    deq.pop_front();
    int y = cur/W;
    int x = cur%W;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]){
        dist[ny][nx] = dist[y][x];
        deq.emplace_front(ny*W+nx);
      }
    }
    rep(j,20){
      int ny = y+ddy[j];
      int nx = x+ddx[j];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]+1){
        dist[ny][nx] = dist[y][x]+1;
        deq.emplace_back(ny*W+nx);
      }
    }
  }
  int ans = dist[D_h][D_w];
  cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 8640
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a = int(input())
    s = input()

    print(s if a >= 3200 else 'red')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int A, B, C, X, count = 0;
    scanf("%d%d%d%d", &A, &B, &C, &X);

    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(i * 500 + j * 100 + k * 50 == X)
                    count++;
            }
        }
    }

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

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

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

  int ab = 0;
  int startb = 0;
  int enda = 0;
  int loop = 1;

  for (int i = 0; i < N; i++)
  {
    string s; cin >> s;
    for (int j = 0; j < s.size() - 1; j++)
    {
      if (s[j] == 'A' and s[j + 1] == 'B') ab++;
    }
    if (s[0] == 'B') startb++;
    if (s[s.size() - 1] == 'A') enda++;
    if (s[s.size() - 1] == 'A' xor s[0] == 'B') loop = 0;
  }

  int ans = ab + min(startb, enda);
  if (startb > 0 and loop == 1) ans--;
  cout << ans << endl;
}

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  
  if ( x * y <= z) {
    cout << x * y << endl;
  }
  else if (  x * y >= z) {
    cout << z << endl;
  }
}




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

int n;
vector<int> vec(10000000);

int main(int argc, char **argv)
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> vec[i];

	int mi{INT_MAX};
	int ans{0};
	for (int i = 0; i < n; ++i)
	{
		mi = min(mi, vec[i]);
		if (mi == vec[i]) ++ans;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 39296
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, ll, hh;
	cin >> nn;
	vector<int64> xx(nn), yy(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> xx[ii];
		yy[ii] = xx[ii];
	}
	sort(yy.begin(), yy.end());
	ll = yy[nn / 2 - 1];
	hh = yy[nn / 2];
	for(int64 ii = 0;ii < nn;ii++)
	{
		if(xx[ii] <= ll)
		{
			cout << hh << endl;
		}
		else
		{
			cout << ll << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end() å
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

#define TENNINE 1000000005
#define TENFIVE 100005

int k;

int gcd(int x, int y)
{
    int temp;
    while (y != 0)
    {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

signed main()
{
    cin >> k;

    int ans = 0;

    rep1(a, k + 1)
    {
        rep1(b, k + 1)
        {
            rep1(c, k + 1)
            {
                ans += gcd(a, gcd(b, c));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
/*input
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,1,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int> mp;
    ll ans=0;
    REP(i,n){
        string a;
        cin>>a;
        sort(a.begin(),a.end());
        ans+=mp[a];
        mp[a]++;
    }
    cout<<ans;
}


Measured memory_bytes: 11264
N,P = map(int, input().split())
A = list(map(int, input().split()))
x = y = 0
for i in range (N):
  if A[i]%2 == 0:
    x += 1
  else:
    y += 1
if P%2 == 0:
  print(2**N if y == 0 else 2**(N-1))
else:
  print(0 if y == 0 else 2**(N-1))

Measured memory_bytes: 9028
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <vector <int>> a(n, vector <int> (n));
    cin >> a;
    vector <long long> cost(1 << n);
    forn (mask, 0, 1 << n) {
        forn (i, 0, n)
            forn (j, i, n)
                if (((mask >> i) & 1) &&
                    ((mask >> j) & 1))
                    cost[mask] += a[i][j];
    }
    vector <long long> dp(1 << n);
    forn (mask, 0, 1 << n) {
        for (int submask = mask; submask > 0; submask = (submask - 1) & mask) {
            chkmax(dp[mask], cost[submask] + dp[mask ^ submask]);
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}

Measured memory_bytes: 1280
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int>r(n+1,0);
    for(int i=0;i<n;++i)
    {
        int x;
        cin>>x;
        r[x]++;
    }
    vector<int>cl;
    int tot=0;
    for(int i=1;i<=n;++i)
    {
        if(r[i])
        {
            tot++;
            cl.pb(r[i]);
        }
    }
    sort(all(cl));
    int i=0;
    int ans=0;
    while(1)
    {
        if(tot<=k)break;
        ans+=cl[i++];
        tot--;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 2168
#include <stdio.h>
main(){
  int N = 0;
  int t = 0;
  int i = 0;
  scanf("%d", &N);
  i = 1000;
  while (i < N){
    i = i + 1000;
  }	
  t = i - N;
  printf("%d", t);
}

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

using namespace std ; 

long double n , m , k ; 

int main(){
    //freopen("in.in" , "r" , stdin ) ; 
    cin>>n>>m>>k ; 
    cout<<( n+ m + 2*sqrt(n*m) < k ?"Yes" : "No");
    return 0 ; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
vector<int>E[maxn];
int h[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int flag=0;
        for(auto &v:E[i])
        {
            if(h[i]<=h[v])
            {
                flag=1;
                break;
            }
        }
        if(!flag)
            cnt++;
    }
    cout<<cnt<<'\n';


}


Measured memory_bytes: 9156
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<string, int>> S(N);
	for (int i = 0;i < N;++i) {
		cin >> S[i].first;
	}
	sort(S.begin(), S.end());
	string s = S[0].first;
	int count = 0;
	for (int i = 0;i < N;++i) {
		if (S[i].first == s) {
			count += 1;
			S[i].second = count;
		}
		else {
			s = S[i].first;
			count = 1;
			S[i].second = count;
		}
	}
	int max = S[0].second;
	for (int i = 1;i < N;++i) {
		if (S[i].second > max) {
			max = S[i].second;
		}
	}
	for (int i = 0;i < N;++i) {
		if (S[i].second == max) {
			cout << S[i].first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15872
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        int cnt=0;


        for(int i = 0;i<n;i++){
            num[i]=sc.nextInt();
        }

        for(int i = 0;i<n;i++){
            if(num[i]%2==0 && (num[i]%3)!=0 && (num[i]%5) !=0){
                cnt++;
            }
        }

        if(cnt==0){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }

    }
}


Measured memory_bytes: 22996
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
cd = []
for i in range(n):
    cd.append(list(map(int, input().split())))
cd.sort()
ab.sort(key = lambda x: x[1], reverse = True)
flag_ab = [False for i in range(n)]
count = 0
for i in range(n):
    c, d = cd[i][0], cd[i][1]
    for j in range(n):
        if flag_ab[j] == True:
            continue
        a, b = ab[j][0], ab[j][1]
        if c > a and d > b:
            flag_ab[j] = True
            count += 1
            break
print(count)

Measured memory_bytes: 9136
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64
    }
    let hd = (360.0 / 720.0) * (h * 60.0 + m);
    let md = (360.0 / 60.0) * m;
    let mut d = (hd - md).abs();
    if d > 180.0 {
        d = 360.0 - d;
    }
    let res = (a*a) + (b*b) - (2.0*a*b * d.to_radians().cos()); 
    println!("{}", res.sqrt());
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long int
#define ld                   long double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define ppf                  pop_front
#define ppb                  pop_back
#define pi                   acos(-1.0)
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  9000000000000000
#define en                   "\n"

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

    ll n; cin>>n;
    map<string, ll> m;
    while (n--) {
        string s;
        cin>>s;
        m[s]++;
    }

    cout<<"AC x "<<m["AC"]<<en;
    cout<<"WA x "<<m["WA"]<<en;
    cout<<"TLE x "<<m["TLE"]<<en;
    cout<<"RE x "<<m["RE"]<<en;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, x;
    cin >> n >> x;
    
    while (n != 0 || x != 0) {
        int count = 0;
        for ( int i = 1; i <= n; i++) {
            for ( int j = i+1; j <= n; j++ ) {
                for (int k = j+1; k <= n; k++ ) {
                    if (i+j+k == x) {
                        count++ ;
                    }
                }
            }
        } 
        cout << count << endl;
        cin >> n >> x;
    }
    
    return 0;
    
}



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

using namespace std;

int main(void) {
    int n;
    long k;
    cin >> n >> k;
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        ans.push_back(make_pair(a, b));
    }

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

    int i = 0;
    for (long j = 0; j < k; i++) j += ans[i].second;

    cout << ans[i - 1].first << endl;

    return 0;
}


Measured memory_bytes: 1400
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

A, B, K = i_l()

arr = []
for i in range(1, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        arr.append(i)

print(arr[::-1][K-1])


Measured memory_bytes: 3060
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


a,b,q=acinput()

S=[-10**15]
for i in range(a):
    S.append(II())
S.append(10**15)

T=[-10**15]
for i in range(b):
    T.append(II())
T.append(10**15)
X=[II() for i in range(q)]

import bisect


def near(arr,v):
    t=bisect.bisect(arr,v)
    
    #print(arr,v,t)
    if t>len(arr)-1:
        return len(arr)-1
    if t==0:
        return 0

    m = (abs(arr[t-1]-v) > abs(arr[t]-v))
    res = t+m-1
    #print(arr, v, res,m)
    return res


#print(S)
for i in range(q):
    x=X[i]

    s=bisect.bisect_right(S,x)
    t = bisect.bisect_right(T, x)
    res=10**19
    for ss in [S[s-1],S[s]]:
        for tt in [T[t-1],T[t]]:
            tmp=abs(ss-x)+abs(ss-tt)            
            res=min(res,tmp)
            tmp = abs(tt-x)+abs(ss-tt)
            res = min(res, tmp)
    print(res)




Measured memory_bytes: 26704
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
		int a, b;
		 cin >> a >> b;
		 cout << max(0, a - 2 * b) << endl;
	return 0;
}

Measured memory_bytes: 764
n,m,l=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[list(map(int,input().split())) for _ in range(m)]
[print(*x)for x in[[sum(s*t for s,t in zip(c,l))for l in zip(*b)]for c in a]]

Measured memory_bytes: 7004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

ll bfs(vector<vector<ll>> g, vector<ll> &dist, ll sv, ll k)
{
	queue<ll> q;
	q.push(sv);
	dist[sv]=0;
	ll ret = k;
	while(!q.empty()){
		ll now = q.front(); q.pop();
		ll cases = k-2;
		if(now==0) cases++;
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			if(cases==0) return 0;
			ret*=cases;
			ret%=MOD;
			cases--;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
	return ret;
}

int main(void) {
	ll n,k; cin >> n >> k;
	vector<vector<ll>> g(n,vector<ll>());
	vector<ll> dist(n,-1);
	rep(i,n-1){
		ll a,b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	out(bfs(g,dist,0,k));

}




Measured memory_bytes: 14324
def cross_point(p1, p2, p3, p4)
  d = (p2[0] - p1[0])*(p4[1] - p3[1]) - (p2[1] - p1[1])*(p4[0] - p3[0])
  return nil if d == 0
  u = ((p3[0] - p1[0])*(p4[1]-p3[1]) - (p3[1]-p1[1])*(p4[0]-p3[0]))/d.to_f
  return [p1[0] + u * (p2[0] - p1[0]), p1[1] + u * (p2[1] - p1[1])]
end

$len = {}
def length(p1, p2)
  unless $len[[p1,p2]]
    $len[[p1,p2]] =  Math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)
  end
  return $len[[p1,p2]]
end

def area(p1, p2, p3)
  a = length(p1, p2)
  b = length(p2, p3)
  c = length(p3, p1)
  s = (a+b+c)/2.0
  return Math.sqrt(s*(s-a)*(s-b)*(s-c))
end

n = gets.to_i
pt = []
n.times{|i|
  pt[i] = gets.split.map(&:to_i)
}

q = gets.to_i
q.times{
  x1,y1,x2,y2 = gets.split.map(&:to_i)
  left = []
  n.times{|i|
    side = pt[i][0] * (y1-y2) + x1 * (y2-pt[i][1]) + x2 * (pt[i][1]-y1)
    left << i if side > 0
  }
  ans = 0
  if left.size == n
    pol = []
    left.each{|i|
      pol << pt[i]
    }
    s = pol.shift
    (pol.size-1).times{|i|
      ans += area(s, pol[i], pol[i+1])
    }
  elsif left.size > 0
    if left[0] == 0 && left[-1] == n-1
      left.push(left.shift)
      while left[-1] + 1 == left[0]
        left.push(left.shift)
      end
    end
    pol = []
    cpt = cross_point(pt[left[0]-1], pt[left[0]], [x1, y1], [x2,y2])
    pol << cpt
    left.each{|i|
      pol << pt[i]
    }
    cpt = cross_point(pt[left[-1]], pt[(left[-1]+1)%n], [x1, y1], [x2,y2])
    pol << cpt
    s = pol.shift
    (pol.size-1).times{|i|
      ans += area(s, pol[i], pol[i+1])
    }
  end
  puts "%.5f" % ans
}

Measured memory_bytes: 9092
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
int a[40];
LL l[40],r[40],b[40];
int main()
{
    int i,j,n;
    LL x,y,k;
    k=1;
    x=0;
    y=0;
    for(i=0;i<32;i++)
    {
        if(i%2==0)
        {
            y=y+k;
            b[i]=k;
        }
        else
        {
            x=x-k;
            b[i]=-k;
        }
        l[i]=x;
        r[i]=y;
        k=k*2;
    }
    scanf("%d",&n);
    if(n==0)
    {
        printf("0\n");
        return 0;
    }
    while(n!=0)
    {
        for(i=0;;i++)
        if(l[i]<=n&&n<=r[i])
            break;
        a[i]=1;
        n=n-b[i];
    }
    i=35;
    while(i>0&&a[i]==0)
        i--;
    for(;i>=0;i--)
        printf("%d",a[i]);
    printf("\n");
}


Measured memory_bytes: 128