akhauriyash/Code-Regression huggingface dataset:
//package beg_163;

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		String cryvgtubhi = s.nextLine();
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);
		}
		int[] count = new int[a];
		
		for (int i: list) {
			count[i-1]=count[i-1]+1;
		}
		
		for (int i: count) {
			System.out.println(i);
		}
		
	}

}


Measured memory_bytes: 68688
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    x = ni()
    xmod10 = x%10
    for a in range(-125, 125):
        for b in range(-125, 125):
            if (a-b)%10 == xmod10:
                if pow(a,5) - pow(b,5) == x:
                    print(a,b)
                    return
    print("Erorr")
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 64488
import sys

sys.setrecursionlimit(10**7)
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


from collections import deque


class Dinic:
    def __init__(self, N, inf):
        self.N = N
        self.inf = inf
        self.G = [[] for _ in range(N)]
        self.level = [0]*N

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s):
        self.level = [-1]*self.N
        deq = deque([s])
        self.level[s] = 0
        while deq:
            v = deq.pop()
            lv = self.level[v] + 1
            for w, cap, _ in self.G[v]:
                if cap > 0 and self.level[w] == -1:
                    self.level[w] = lv
                    deq.appendleft(w)

    def dfs(self, v, t, f):
        if v == t:
            return f
        for e in self.iter[v]:
            w, cap, rev = e
            if cap > 0 and self.level[v] < self.level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d > 0:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] == -1:
                return flow
            *self.iter, = map(iter, self.G)
            f = self.inf
            while f > 0:
                f = self.dfs(s, t, self.inf)
                flow += f


H,W = MI()
inf = 10**5
Di = Dinic(H+W+2,inf)
s,t = H+W,H+W+1
for i in range(H):
    S = LS2()
    for j in range(W):
        if S[j] == 'S':
            Di.add_edge(s,i,inf)
            Di.add_edge(s,j+H,inf)
        elif S[j] == 'T':
            Di.add_edge(i,t,inf)
            Di.add_edge(j+H,t,inf)
        elif S[j] == 'o':
            Di.add_edge(i,j+H,1)
            Di.add_edge(j+H,i,1)

ans = Di.flow(s,t)
print(ans if ans < inf else -1)


Measured memory_bytes: 78916
N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
B=(N+1)//2
A=B-1
C=N-1
D=1
for i in range(M):
    if i%2==0:
        a[i]=A
        b[i]=B
        A-=1
        B+=1
        A%=N
        B%=N
    else:
        a[i]=C
        b[i]=D
        C-=1
        D+=1
        C%=N
        D%=N
for i in range(M):
    print(a[i]+1,b[i]+1)

Measured memory_bytes: 16260
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int A,B,T;

int main() {

	scanf("%d%d%d", &A, &B, &T);



	printf("%d\n", T/A*B);

	return 0;
}


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

int main(){
  int s,i,j,k,cnt=0;
  cin >> s;
  int a=s/1000,b=s/100-a*10,c=s/10-b*10-a*100,d=s-c*10-b*100-a*1000;
  
  vector<char> op={'+','-'};
  int s1,s2,s3;
  for(i=0;i<2;i++){
    if(cnt>=1){
      break;
    }
    s1=0;
    if(i==0){
      s1=a+b;
    }
    else{
      s1=a-b;
    }
    for(j=0;j<2;j++){
      if(cnt>=1){
        break;
      }
      s2=s1;
      if(j==0){
        s2 +=c;
      }
      else{
        s2 -=c;
      }
      for(k=0;k<2;k++){
        s3=s2;
        if(k==0){
          s3 +=d;
        }
        else{
          s3 -=d;
        }
        if(s3==7){
          vector<int> vec={i,j,k};
          cout << a << op[i] << b << op[j] << c << op[k] << d << '=' << 7 <<endl;
          cnt++;
          break;
          
        }
        else{
          continue;
          
        }
      }
    }
  }
  
  
}


Measured memory_bytes: 3608
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
u = 0
for i in range(N - M + 1):
  for j in range(N - M + 1):
    s = 0
    for k in range(M):
      for l in range(M):
        if A[i+k][j+l] != B[k][l]:
          s += 1
    if s == 0:
      u = 1
if u == 1:
  print('Yes')
elif u == 0:
  print('No')

Measured memory_bytes: 3064
n,m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]
dic = {x:0 for x in range(1,m+1)}
ans = 0
for i in range(n):
  for j in range(1, k[i][0] + 1):
    dic[k[i][j]] += 1

for a,b in dic.items():
  if b == n:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define PB push_back
#define int ll

bool x[1000];
bool y[1000];
int a,b,c,d;

signed main(){
  cin>>a>>b>>c>>d;
  FOR(i,a,b){
    x[i]=true;
  }
  FOR(i,c,d){
    y[i]=true;
  }

  int sum=0;
  rep(i,1000){
    if(x[i]&&y[i]) sum++;
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<Int> sum(N + 1);
	sum[0] = abs(a[0]);

	for (Int i = 1; i < N; i++) {
		sum[i] = sum[i - 1] + abs(a[i] - a[i - 1]);
	}
	sum[N] = sum[N - 1] + abs(a[N - 1]);


	Int temp = 0;
	for (Int i = 0; i < N; i++) {
		if (i == 0) {
			temp = sum[N] - sum[1] + abs(a[1]);
			printf("%lld\n", temp);
		}
		else if (i == N - 1) {
			temp = sum[N - 2] + abs(a[N - 2]);
			printf("%lld\n", temp);
		}
		else {
			temp = sum[i - 1] + sum[N] - sum[i + 1] + abs(a[i - 1] - a[i + 1]);
				printf("%lld\n", temp);
		}
	}

}

Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
int main(){
  ll n; cin >> n;
  vector<ll> t(n),a(n),x(n);
  rep(i,n) cin >> t[i];
  rep(i,n) cin >> a[i];
  fill(ALL(x),LLINF);
  rep(i,n-1)if(t[i] > t[i+1]){cout<<0<<endl;return 0;}
  rep(i,n-1)if(a[i] < a[i+1]){cout<<0<<endl;return 0;}
  if(t[n-1] != a[0]){cout<<0<<endl;return 0;}
  ll max_h = a[0];
  rep(i,n){
    if(t[i] == max_h){
      if(t[i] == a[i]) break;
      else{cout<<0<<endl;return 0;}
    }
  }
  
  for(int i = 1; i < n; i++) if(t[i-1] != t[i]) x[i] = 1;
  for(int i = n-1; i >= 0; i--){
    x[i] = min(x[i],a[i]);
    x[i] = min(x[i],t[i]);
  }
  for(int i = n-2; i >= 0; i--) if(a[i] != a[i+1]) x[i] = 1;
  x[0] = x[n-1] = 1;
  ll ans = 1;
  //DEB;
  rep(i,n) ans *= x[i],ans %= DIV;
  cout << llabs(ans) << endl;
}

Measured memory_bytes: 2560
X, N = map(int, input().split())
if N:
  P = list(map(int, input().split()))
  distance = 10000
  ans = 0
  for cadi in range(101, -2, -1):
    if not cadi in P :
      if distance >= ( cadi - X ) * ( cadi - X ):
        distance = ( cadi - X ) * ( cadi - X )
        ans = cadi
  print(ans)
else:
  print(X)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
 if(A+B > C+D){
   cout<<"Left"<<endl;
 }
   if(A+B < C+D){
   cout<<"Right"<<endl;
   }
   if(A+B == C+D){
   cout<<"Balanced"<<endl;
   }
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int t;
    cin>>t;
    for(int h=0;h<t;h++){
    
    
        int n,k;
        cin>>n>>k;
        int a[100001]={};
        long long int sum=0;
        int b[100000]={};
        for(int i=0;i<n;i++){cin>>a[i]; if(i!=0){b[i-1]=a[i]-a[i-1]; sum+=b[i-1];}}
        sort(b,b+n-1);
        reverse(b,b+n-1);
        for(int i=0;i<k-1;i++){sum-=b[i];}
        cout<<sum<<endl;
    
    }
    
    return 0;
}


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int 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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)




void solve(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<bool> d(1000001,false);
    
    sort(ALL(A));
    
    int ans = 0;
    rep(i,N){
        if(d[A[i]]) continue;
        
        if(i+1<N && A[i]==A[i+1]);
        else
            ans++;
        for(int n = A[i]; n<=1000000; n+=A[i]){
            d[n]=true;
        }
    }
    cout << ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define rep1(i,n,a) for(int i=0;i<n;i+=a)
#define rep2(i,n,a) for(int i=a;i<n;i++)
#define rep3(n)     for(int i=0;i<n;i++)
#define inarr(arr,n) rep1(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define trav(a,x) for(auto x:a)
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define gcd(a,b) __gcd(a,b)
#define pres(a,x) a.find(x)!=a.end()
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define psi pair<string,int>
#define pss pair<string,string>
#define pll pair<ll,ll>
#define vec vector<int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
#define narak 998244353
const int inf1=1e9;
const ll inf2=1e18;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
int solve(){
  int n,m;cin>>n>>m;
  int v[n+1]={0};
  int pe[n+1]={0};
  int cnt1=0,cnt2=0;
  rep3(m){
      int p;cin>>p;
      string s;cin>>s;
      if(s=="AC" && v[p]==0){
          v[p]=1;
          cnt1++;
          cnt2+=pe[p];
      }
      else{
          if(v[p]==0)pe[p]++;
      }
  }
  cout<<cnt1<<" "<<cnt2<<endl;
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

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

    int A[2][N];

    rep(i,0,N) {
        cin >> A[0][i];
    }
    rep(i,0,N) {
        cin >> A[1][i];
    }

    int B[2][N];
    B[0][0] = A[0][0];
    B[1][0] = A[1][0];

    rep(i,1,N) {
        B[0][i] = A[0][i]+B[0][i-1];
        B[1][i] = A[1][i]+B[1][i-1];
    }

    int ans = 0;
    rep(i,0,N) {
        int tmp = B[0][i]+B[1][N-1]-B[1][i]+A[1][i];
        ans = max(ans,tmp);
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct que{
    ll l,r,flag;
};
bool comp(que a,que b){
    return a.r<b.r;
}

// セグ木

ll segnodenum;
vector<ll> segnode;

ll init_num=0;
ll func(ll x,ll y){
    return x+y;
}

void init(vector<ll> v){
    segnodenum=1;
    while(v.size()>segnodenum)segnodenum*=2;
    segnode.resize(2*segnodenum-1,init_num);
    rep(i,segnodenum-1,segnodenum*2-2){
        if(i-(segnodenum-1)<v.size()){
            segnode[i]=segnode[i-(segnodenum-1)];
        }else{
            segnode[i]=init_num;
        }
    }
    for(ll i=segnodenum-2;i>=0;i--){
        segnode[i]=func(segnode[2*i+1],segnode[2*i+2]);
    }
}

void update(ll x,ll y){ //v[x]をyに変更する
    segnode[x+segnodenum-1]=y;
    ll next=x+segnodenum-1;
    while(next>0){
        next=(next-1)/2;
        segnode[next]=func(segnode[2*next+1],segnode[2*next+2]);
    }
}

ll find(ll i,ll j,ll x,ll y,ll z){     //v[[i,j)]でのfuncの結果を出力する //segnode[x]に着目しているsegnode[x]が担当する範囲は[y,z); //最初はx=-1で
    if(x==-1) return find(i,j,0,0,segnodenum);
    if(j<=y || z<=i)return init_num;
    if(i<=y && z<=j)return segnode[x];
    return func(find(i,j,2*x+1,y,(y+z)/2),find(i,j,2*x+2,(y+z)/2,z));
}

int main(){fastio
    ll n,q;cin>>n>>q;
    ll c[n+1];rep(i,1,n)cin>>c[i];
    vector<ll> V;rep(i,0,n)V.pb(0);
    init(V);
    ll de[n+1];rep(i,1,n)de[i]=-1;
    vector<que> v;
    rep(i,0,q-1){
        ll l,r;cin>>l>>r;
        que q;
        q.l=l;q.r=r;
        q.flag=i;
        v.pb(q);
    }
    sort(v.begin(),v.end(),comp);
    ll nowr=0;
    ll ans[q];
    rep(i,0,q-1){
        ll l,r;l=v[i].l;r=v[i].r;
        while(nowr<r){
            nowr++;
            if(de[c[nowr]]==-1){
                de[c[nowr]]=nowr;
                update(nowr,1);
            }else{
                update(de[c[nowr]],0);
                de[c[nowr]]=nowr;
                update(nowr,1);
            }
        }
        ans[v[i].flag]=find(l,r+1,-1,0,0);
    }
    rep(i,0,q-1){
        cout<<ans[i]<<endl;
    }

    return 0;
}





Measured memory_bytes: 45520
#include <iostream>

#include<cmath>

using namespace std;

int main()
{
  string s;
  cin>>s;
  if(s=="bac"||s=="bca"||s=="abc"||s=="acb"||s=="cab"||s=="cba")
  cout<<"Yes";
  else
  cout<<"No";
  
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"

int main(int argc, char const *argv[]) {
  /* code */
  std::string S, out;
  std::cin >> S;

  int w;
  std::cin >> w;
  //
  // std::cout << S << '\n';
  out = S[0];

  for (size_t i = 1; i < S.size(); i++) {
    /* code */
    if(i % w == 0) out += S[i];
  }
  std::cout << out << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n,p; cin>>n>>p;
    LLI beki[51];
    beki[0]=1;
    FOR(i,1,51){
        beki[i]=beki[i-1]*2;
    }
    LLI ans=0;
    int oddnum=0;
    FOR(i,0,n){
        int a;cin>>a;
        oddnum+=a%2;
    }
    if(oddnum==0){
        if(p) ans=0;
        else ans=beki[n];
    }else{
        ans=beki[n-1];
    }
    co(ans);
}


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

typedef long long ll;

int main(){
    int N;
    cin>>N;
    
    ll F[N],P[N][11];
    for(int i=0;i<N;i++){
        ll sum=0;
        for(int j=0;j<10;j++){
            int s;cin>>s;
            if(s==1) sum+=pow(2,9-j);
        }
        F[i]=sum;
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++) cin>>P[i][j];
    }
    
    ll ans=-100000000000;
    for(ll i=1;i<(1<<10);i++){
        ll sum=0;
        for(int j=0;j<N;j++){
            ll same=i&F[j];
            ll count=0;
            for(int k=0;k<10;k++){
                if(same&1<<k)count++;
            }
            sum+=P[j][count];
        }
        ans=max(sum,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=4e5+5;
const int MOD=1e9+7;
ll a[N],sum[N];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k,pos;
    cin>>n>>k;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++){
        if(a[i]==1){
            pos=i;
            break;
        }
    }

    ll cnt=pos-1;
    ll ans=0;
    if(cnt<=k-1){
        n--;
        ans+=n/(k-1);
        if(n%(k-1)) ans++;
    }
    else{
        if(cnt%(k-1)==0){
            n--;
            ans+=n/(k-1);
            if(n%(k-1)) ans++;
        }
        else{
            int t=cnt%(k-1);
            int st=pos-t;
            ans+=cnt/(k-1);
            while(st<n){
                st+=k-1;
                ans++;
            }
        }
    }
    cout <<ans << endl;

    return 0;
}


Measured memory_bytes: 2304
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

A = [0 for i in range(N)]

for i in range(N):
     A[i] = V[i]-C[i]

A = sorted(A)[::-1]

ans = 0

for i in range(N):
  if A[i] > 0:
    ans += A[i]
  else:
    break

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	int f[205],sum[205]={0};
	for(int i=1;i<=n;i++)
	{
		f[i]=i-1+l;
		sum[i]=sum[i-1]+f[i];
	}
	if(l>=0)
	{
		cout<<sum[n]-sum[1];
	}
	else
	{
		if(f[n]>=0)
		{
			cout<<sum[n];
		}
		else
		{
			cout<<sum[n-1];
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string s;
	cin>>s;
	if(s=="ARC")cout<<"ABC";
	else cout<<"ARC";
	return 0;
}


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

int main() {
  int n, x, c;
  char p;
  bool flag;
  cin >> n;
  c = 0;
  flag = true;
  while(n--) {
    cin >> p >> x;
    if(p == ')') x = -x;
    c += x;
    if(c < 0) flag = false;
  }
  if(c != 0) flag = false;
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main() {
	int i, k, n, a, b, dis, max = 0, z;
	cin >> k >> n;
	for (i = 0; i <= n; i++) {
		if (i == n) {
			dis = k - a + z;
		}
		else {
			cin >> a;
			if (i == 0) {
				z = a;
				dis = 0;
			}
			else {
				dis = a - b;
			}
			b = a;
		}
		if (dis > max)max = dis;
	}
	cout << k - max << endl;
}

Measured memory_bytes: 256
from collections import Counter
mod = 10 ** 9 + 7


class Combination:
    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    comb = Combination(N + 10)
    X = Counter(A).most_common()[0][0]

    l = A.index(X)
    r = A.index(X, l+1)
    LR = l + (N - r)

    for i in range(1, N + 2):
        ans = comb(N + 1, i)
        ans -= comb(LR, i - 1)
        ans = (ans + mod) % mod

        print(ans)

Measured memory_bytes: 29908
# -*- coding: utf-8 -*-
"""
A - Fairness
https://atcoder.jp/contests/agc024/tasks/agc024_a

"""
import sys


def solve(A, B, C, K):
    if K%2:
        return B-A
    return A-B


def main(args):
    A, B, C, K = map(int, input().split())
    ans = solve(A, B, C, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  char s[20];
  int i;
  
  scanf("%s",s);
  
  for(i=0;i<=4;i++){
    printf("%c",s[i]);
  }
  printf(" ");
  
  for(i=6;i<=12;i++){
    printf("%c",s[i]);
  }
  printf(" ");
  
  for(i=14;i<=18;i++){
    printf("%c",s[i]);
  }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 510000;  // 最大を決めておく
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nCr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// nCrを計算する (前処理は忘れないように)
long long nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

// nHrを計算する (nCrとセットです)
long long nHr(int n, int r) {
  return nCr(n + r - 1, r);
}

// 結果を入れたmapを返します
map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  // 2以上で割り切れなかったら
  if (n != 1) ret[n] = 1;
  return ret;
}

// ====================================================================

int main() {
  nCr_init();
  ll n, m;
  cin >> n >> m;
  map<ll, int> p = prime_factor(m);
  ll ans = 1;
  for (auto x : p) ans = ans * nHr(n, x.second) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 12160
//abc137_c.cpp
//Sat Aug 10 20:49:47 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	string s[n];
	for (int i=0;i<n;i++){
		cin >> s[i];
		sort(s[i].begin(),s[i].end());
	}

	sort(s,s+n);

	ll count = 1;
	ll ans = 0;
	for (int i=1;i<n;i++){
		if (s[i]==s[i-1]){
			count++;
		}else {
			ans += count*(count-1)/2;
			count = 1;
		}
	}
	ans += count*(count-1)/2;

	cout << ans << endl;
}

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

int main() {
    int n,a,b;
    cin>>n>>a>>b;

    int ma,mi;

    ma = min(a,b);
    if(n>a+b) mi = 0;
    else mi = a+b-n;

    cout<<ma<<' '<<mi<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
priority_queue<int>q;
ll sum;
int m,n,x;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>x;
		q.push(x);
	}
	while(m){
		x=q.top()/2;
		q.pop();
		q.push(x);
		m--;
	}
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}
	cout<<sum;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] array = sc.intarr;

            if(array[0] * array[1] < array[2])
            {
                wr.wri(array[0] * array[1]);
            }
            else
            {
                wr.wri(array[2]);
            }

        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;


int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        for (int i = 0; i < b; i++)
        cout << a ;
    }
    else
    {
        for (int i = 0; i < a; i++)
        cout << b ;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l={}
if n<=9:
  print(0)
else:
  for i in range(2,n+1):
    x=i
    for j in range(2,i+1):
      while x%j==0:
      	if j in l:
        	l[j]+=1
      	else:
        	l[j]=1
      	x=x//j
  c=0
  if l[2]>=74:
    c+=1
  c3=0
  c5=0
  c25=0
  c15=0
  for i in l:
    if l[i]>=2:
      c3+=1
      if l[i]>=4:
        c5+=1
        if l[i]>=14:
          c15+=1
          if l[i]>=24:
            c25+=1
  print(c5*(c5-1)*(c3-2)//2+c25*(c3-1)+c15*(c5-1)+c)     

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

int main() {
	int H, W;

	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if(i == 1 || i == H) printf("#");
				else if(j == 1 || j == W) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


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

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

  vector<int> dp(n,INT_MAX);
  vector<int> a(n);

  for(int i=0;i<n;i++){
    cin >> a.at(i) ;
  }

  dp.at(0)=0;
  if(a.at(0)>a.at(1)){
    dp.at(1)=a.at(0)-a.at(1);
  }else{
    dp.at(1)=a.at(1)-a.at(0);
  }
  for(int i=2;i<n;i++){
    int d1,d2;
    if(a.at(i-1)>a.at(i)){
      d1=a.at(i-1)-a.at(i);
    }else{
      d1=a.at(i)-a.at(i-1);
    }

    if(a.at(i-2)>a.at(i)){
      d2=a.at(i-2)-a.at(i);
    }else{
      d2=a.at(i)-a.at(i-2);
    }

    if(dp.at(i-1)+d1>dp.at(i-2)+d2){
      dp.at(i)=dp.at(i-2)+d2;
    }else{
      dp.at(i)=dp.at(i-1)+d1;
    }
  }
  cout << dp.at(n-1) <<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define MAX_N 1
#define MAX_V 1

signed main(){
	int n, m;
	string s;
	bool f = true;
	
	cin>>n;
	
	if(n == 1){
		cout<<"Hello World"<<endl;
	} else {
		cin>>n>>m;
		cout<<n+m<<endl;
	}
	
	// cout<<yn(f)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll x,ans=1;
  cin>>x;
  for(int i=2;i*i<=x;i++){
    ll tmp=1;
    do{
      tmp*=i;
    }while(tmp<=x/i);
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
S = str(input())

max_len = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        compared_str = compared_str = S[i : j+1]
        compared_str = compared_str.replace('A', '')
        compared_str = compared_str.replace('C', '')
        compared_str = compared_str.replace('G', '')
        compared_str = compared_str.replace('T', '')
        
        if compared_str == '':
            max_len = max([max_len, len(S[i : j+1])])
        
print(max_len)
    
        
        
        
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n) {
		cin >> v[i];
		if (v[i] == 0) {
			cout << 0 << endl;
			return ;
		}
	}
	ll ans = v[0], limit = 1e18L;
	rep2(i, 1, n) {
		if (ans > INT64_MAX / v[i]) {
			cout << -1 << endl;
			return;
		}
		ans *= v[i];
	}
	if (ans > limit) cout << -1 << endl;
	else cout << ans << endl;
}

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

	solve();
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }

  double sum = 0;
  for(double a : A){
    sum += 1 / a;
  }
  
  double ans = 1 / sum;
  

  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0,a=0;
	char s;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=='I')  sum++;
		else  sum-=1;
	    if(sum>=a)  a=sum;
	}
	cout<<a<<endl;
	return 0;
} 

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

int main(void){


    vector<int> array(5,0);

    for(int i = 0;i < 5;i++){
        cin >> array[i];
    }

    sort(array.begin(),array.end(),greater<int>());

    for(int i = 0;i < 4;i++){
        cout << array[i] << " " ;
    }
    cout << array[4] << endl;
    

    return 0;
}

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

int v[20],c[20];
int main()

{	
	int n,s1=0,s=0;
	cin >> n;
	for (int i=0;i<n;i++)
		cin >>v[i];
		
	for (int i=0;i<n;i++)
		cin >> c[i];
		
	
	for (int i=0;i<n;i++)
	{
	
		if (v[i]>c[i])
		{
		s=s+v[i];
		s1=s1+c[i];}	}
	cout << s-s1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
void chmin(int &a, int b) {
    if (a > b) a = b;
}

int main() {
    int n; cin >> n;
    vector<int> times(n + 100, INF);
    times[0] = 0;
    for (int i=0; i<n; ++i) {
        chmin(times[i+1], times[i] + 1);
        int s = 6;
        while (i+s <= n) {
            chmin(times[i+s], times[i] + 1);
            s *= 6;
        }
        int ni = 9;
        while (i+ni <= n) {
            chmin(times[i+ni], times[i] + 1);
            ni *= 9;
        }
    }
    cout << times[n] << endl;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

ifstream ifs;
vector<string> lineread(){
    vector<string> ret;
    string str = "";
// ファイルの中身を一行ずつ読み取る
    while(getline(ifs, str))
    {
        string tmp = "";
        istringstream stream(str);
 
        // 区切り文字がなくなるまで文字を区切っていく
        while (getline(stream, tmp, ' '))
        {
            // 区切られた文字がtmpに入る
            ret.push_back(tmp);
        }
    }
    return ret;
}

int main(){
//    vector<string> linereadret;
 //   int incnt=0;
 //   ifs.open("1_10.txt");
// 開かなかったらエラー
//    if (!ifs){
//        cout << "Error! File can not be opened" << endl;
//        return 0;
//    }
//    linereadret=lineread();

    int n;
    cin>>n;
//    n=stoi(linereadret[incnt++]);
    vector<ll> a(3*n);
    rep(i,3*n){
        cin>>a[i];
//        a[i]=stoi(linereadret[incnt++]);
    }
    priority_queue<ll,vector<ll>,greater<ll>> qf;
    priority_queue<ll> qb;
    ll sumf=0, sumb=0;
    rep(i,n){ 
        qf.push(a[i]);
        qb.push(a[3*n-i-1]);
        sumf+=a[i];
        sumb+=a[3*n-i-1];
    }
    vector<ll> kf(n+1),kb(n+1);
    kf[0]=sumf;
    kb[n]=sumb;
    rep(i,n) {
        qf.push(a[n+i]);
        sumf+=a[n+i]-qf.top();
        kf[i+1]=sumf;
        qf.pop();
        qb.push(a[2*n-i-1]);
        sumb+=a[2*n-i-1]-qb.top();
        kb[n-i-1]=sumb;
        qb.pop();
    }
    ll ans=-INF;
    rep(k,n+1) if(kf[k]-kb[k]>ans)ans=kf[k]-kb[k];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8708
s = gets.chomp
k = gets.to_i
a = Hash.new(0)
ans = []
for i in 0..s.size-1
  a[s[i]] += 1
end
a = a.keys.sort[0..k]
for i in 0..s.size-1
  if a.include?(s[i])
    for j in 0..k-1
      ans << s[i..[i+j,s.size-1].min]
    end
  end
end
ans = ans.uniq.sort!
puts ans[k-1]

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

int main() {
	int arr[6]={},x;
	for(int i=1;i<=5;i++){
		cin>>arr[i];
		if(arr[i]==0){
			 x=i;
		}
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 3496
import sys
def input(): return sys.stdin.readline().strip()

def main():
    S = input()
    l = len(S) - 1
    ans = 0
    for i in range(1 << l):
        val = 0
        num = S[0]
        for j in range(l):
            if (i & (1 << j)):
                val += int(num)
                num = S[j + 1]
            else:
                num += S[j + 1]
        val += int(num)
        ans += val
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67484
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int main() {
	ll n, a, b; read(n), read(a), read(b);
	if ((b - a) % 2 == 0) cout << (b - a) / 2 << endl;
	else cout << min(a + b - 1, 2 * n - a - b + 1) / 2 << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;



int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);

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

    d *= d;

    ll resposta = 0;
    for(int i = 0; i<n; ++i){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d){
            resposta++;
        }
    }

    cout<<resposta<<endl;

    return 0;
}

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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;

    cout << a[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    ll A[1100],B[1100],C[1100];
    vector<ll> AB(X*Y),S(min(3000,X*Y)*Z);
    for(int i=0;i<X;i++) cin>>A[i];
    for(int i=0;i<Y;i++) cin>>B[i];
    for(int i=0;i<Z;i++) cin>>C[i];
    int count=0;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            AB[count]=A[i]+B[j];
            count++;
        }
    }
    sort(AB.begin(),AB.end(),greater<ll>());
    count=0;
    for(int i=0;i<min(3000,X*Y);i++){
        for(int j=0;j<Z;j++){
            S[count]=AB[i]+C[j];
            count++;
        }
    }
    sort(S.begin(),S.end(),greater<ll>());
    for(int i=0;i<K;i++){
        cout<<S[i]<<endl;
    }
}



Measured memory_bytes: 32120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();

		if (n >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}

		sc.close();

	}

}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;


int main() {
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += 380000.0 * x;
        }
    }

    printf("%.10f", ans);
}



Measured memory_bytes: 256
#include<stdio.h>

int num[128];

int quicksort(int left,int right)
{
	int i,j,mid;
	i=left;j=right;
	mid=num[(left+right)>>1];
	while (i<j) 
	{
		while (num[i]>mid) ++i;
		while (num[j]<mid) --j;
		if (i<=j)
		{
			int tmp;
			tmp=num[i];num[i]=num[j];num[j]=tmp;
			++i;--j;
		}
	}
	if (i<right) quicksort(i,right);
	if (j>left) quicksort(left,j);
}

main()
{
	int n,m,i;
	double stan;
	scanf("%d%d",&n,&m);
	int sum=0; 
	for (i=1;i<=n;i++) 
	{
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	stan=sum/(4.0*m);
	quicksort(1,n);
	int count=0;
	for (i=1;i<=n;i++)
		if (num[i]>=stan) ++count;
	if (count>=m) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    if(n>=k){
        if(n%k==0)cout<<0<<endl;
        else{
            n-=n/k*k;
            cout<<min(n,k-n)<<endl;
        }
    }else{
        cout<<min(n,k-n)<<endl;
    }
}

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

using namespace std;

typedef long long LL;
const int MAXN=4096;
const int MOD=1e9+7;
LL dp[MAXN][MAXN],sum[MAXN][MAXN],n;
string s;

int main(){
	cin>>n>>s;
	s='$'+s;
	dp[1][1]=sum[1][1]=1;
	
	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(s[i-1]=='<'){
			/*	for(int k=0;k<j;k++){
					dp[i][j]+=dp[i-1][k];
					dp[i][j]%=MOD;
				}*/
				dp[i][j]=sum[i-1][j-1]%MOD;
			}
			else{
			/*	for(int k=j;k<=i-1;k++){
					dp[i][j]+=dp[i-1][k];
					dp[i][j]%=MOD;
				}*/
				dp[i][j]=(sum[i-1][i-1]-sum[i-1][j-1]+MOD)%MOD;
			}
			sum[i][j]=(sum[i][j-1]+dp[i][j])%MOD;
		}
	}
	LL ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[n][i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 191104
X,Y,A,B,C=map(int,input().split())
p=sorted(map(int,input().split()),reverse=True)[:X]
q=sorted(map(int,input().split()),reverse=True)[:Y]
r=sorted(map(int,input().split()),reverse=True)

pq=sorted(p+q+r,reverse=True)
print(sum(pq[:X+Y]))

Measured memory_bytes: 22524
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using arr = vector<ll>;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

ll n, a, b;

ll modpow(ll x, ll e) {
  ll res = 1;
  while(e) {
    if (e & 1) res = res * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return res;
}

ll comb(ll n, ll k) {
  ll res = 1;
  REP(i, k) {
    res = res * (n - i) % MOD * modpow(i + 1, MOD - 2) % MOD;
  }
  return res;
}

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

  ll ans = modpow(2, n) - 1;
  ans = (ans + MOD - comb(n, a)) % MOD;
  ans = (ans + MOD - comb(n, b)) % MOD;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
S = Array.new(5).map{Array.new()}
march = 'MARCH'
N.times do
	line = gets.chomp
	if march.include?(line[0])
		S[march.index(line[0])].push line
	end
end
S.reject!(&:empty?)
sum = 0
S.combination(3){|a,b,c|sum+=a.size*b.size*c.size}
print "#{sum}\n"

Measured memory_bytes: 9468
# coding: utf-8
# Your code here!

s = input()
cnt=0
if len(s)%2==0:
    a=s[:len(s)//2]
    b=s[len(s)//2:]
    b=b[::-1]
    for i in range(len(s)//2):
        if a[i]!=b[i]:
            cnt+=1
else:
    a=s[:len(s)//2]
    b=s[len(s)//2+1:]
    b=b[::-1]
    for i in range((len(s)-1)//2):
        if a[i]!=b[i]:
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 100000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n;
int a[N + 5], f[N + 5][2];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    scanf("%d", &n);
    f[1][0] = f[1][1] = 1;

    for(int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        if(i > 1) {
            f[i][1] = f[i][0] = min(f[i-1][0], f[i-1][1]) + 1;

            if(a[i] >= a[i-1]) chkmin(f[i][1], f[i-1][1]);
            if(a[i] <= a[i-1]) chkmin(f[i][0], f[i-1][0]);
        }
    }
    printf("%d\n", min(f[n][0], f[n][1]));

    return 0;
}


Measured memory_bytes: 1408