akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    vector<int> v;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    sort(v.begin(), v.end());
    
    int count = 0;
    int len = v.size();
    for (int i = 0; i < len; i++) {
        if (v[i] == v[i+1]) {
            i++;
        } else {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> d(n);
  rep(i, n) cin >> d[i];

  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  sort(all(d));
  ans = d[n / 2] - d[n / 2 - 1];

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

signed main() {
  init();
  ll a, b;
  cin >> a >> b;
  if (a + b == 15) {
    COUT("+");
  } else if (a * b == 15) {
    COUT("*");
  } else {
    COUT("x");
  }
  return 0;
}

Measured memory_bytes: 3580
#if 0
??¶?´? m <= 50??????????????????
????????????????????????????§??????£??????????????°?????????????????°????????¨??????????????¨????????????????????????????§????????????????
????????¨???U??????????????¢?????¶?´??????¨??????????°?????????¨?????????
???????????????????????¨???????°????????§£??????????????£????????§????°???????????????????????????¢????????¢?????¨????????¢????????¨?????£??????
????£?40?????????????????°30????????????
#endif
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using mat = vector<bitset<100>>;

mat matMul(const mat& a, const mat& b) {
    const int n = a.size();
    mat c(n, bitset<100>(0));
    for(int i : in(n))
        for(int k : in(n))
            for(int j : in(n))
                c[i][j] = c[i][j] | (a[i][k] & b[k][j]);
    return c;
}
mat matPow(mat a, int k) {
    const int n = a.size();
    mat b(n, bitset<100>(0));
    for(int i : in(n)) b[i][i] = 1;
    while(k > 0) {
        if(k & 1) b = matMul(b, a);
        a = matMul(a, a);
        k >>= 1;
    }
    return b;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    while(cin >> n >> m >> k && n) {
        vector<pair<int, int>> edge;
        for(int _ : in(m)) {
            int u, v;
            cin >> u >> v;
            edge.emplace_back(u, v);
            edge.emplace_back(v, u);
        }
        m *= 2;
        vector<int> start, goal;
        mat e(m, bitset<100>(0));
        for(int i : in(m)) {
            int cur = edge[i].first, nxt = edge[i].second;
            if(cur == 1) start.emplace_back(i);
            if(nxt == n) goal.emplace_back(i);
            for(int j : in(m))
                if(edge[j].first == nxt && edge[j].second != cur)
                    e[i][j] = 1;
        }
        e = matPow(e, k - 1);
        bool ok = false;
        for(int s : start)
            for(int g : goal)
                ok |= (e[s][g] == 1);
        cout << (ok ? "yes" : "no") << endl;
    }
    return 0;
}

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

using namespace std;

void solve()
{
	int n, m;
	while(cin >> n >> m)
	{
		if(!n && !m)
		{
			break;
		}
		vector<double> Vec1(n);
		vector<double> Vec2(m);
		double sum1 = 0;
		double sum2 = 0;
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec1[i];
			sum1 += Vec1[i];
		}
		for(int i = 0; i < m; ++i)
		{
			cin >> Vec2[i];
			sum2 += Vec2[i];
		}
		double diff = (sum1 - sum2) / 2;
		sort(Vec1.begin(), Vec1.end());
		sort(Vec2.begin(), Vec2.end());
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < m; ++j)
			{
				if(Vec1[i] - diff == Vec2[j])
				{
					cout << Vec1[i] << " " << Vec2[j] << endl;
					goto NEXT;
				}
			}
		}
		cout << -1 << endl;
NEXT:
		;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define first F
#define second S
typedef pair<int,int> P;
typedef vector<int> v;
char mas[1111][1111];
bool a[1001][1001];
int main(){
  char key[2][2];
  int N,M;
  int cnt;
  int ans=-111;
  cin>>M>>N;
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      cin>>mas[i][j];
      // haku[i][j]=mas[i][j];
    
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      cin>>key[i][j];
    }
  }
  int a_cnt=0;
  for(int i=0;i<M-1;i++){
    for(int j=0;j<N-1;j++){
      cnt=0;
      for(int k=0;k<2;k++){
	for(int l=0;l<2;l++){
	  if(mas[i+k][j+l]==key[k][l]){
	    cnt++;
	  }
	}
      }
      if(cnt==4) a_cnt++;
    }
  }
 
  int dx[]={-1,-1,0,0};
  int dy[]={-1,0,-1,0};
  char joi[]={'J','O','I'};
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      for(int mozi=0;mozi<3;mozi++){
	if(mas[i][j]==joi[mozi]) continue;
	char tmp=mas[i][j];
	mas[i][j]=joi[mozi];
	cnt=0;
	for(int k=0;k<4;k++){
	  int nx=i+dx[k];
	  int ny=j+dy[k];
	  int ret=0;
	  if(0<=nx && nx<M-1 && 0<=ny && ny<N-1){
	    
	    for(int m=0;m<2;m++){
	      for(int l=0;l<2;l++){
		if(mas[nx+m][ny+l]==key[m][l]){
		  ret++;
		}
	      }
	    }
	    if(ret==4) cnt++;
	  }
	}
	ans=max(ans,a_cnt+cnt);
	mas[i][j]=tmp;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
		

Measured memory_bytes: 2256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

vector<ll> V[4];
ll sum[4][110];

int main(){
  int N;
  ll W,w[110],v[110],ans=0,temp=0;
  
  cin>>N>>W;
  
  for(int i=0;i<N;i++){
    cin>>w[i]>>v[i];
    if(i==0) V[0].push_back(v[i]);
    else V[w[i]-w[0]].push_back(v[i]);
  }
  
  int n[4];
  for(int i=0;i<4;i++){
    V[i].push_back(10000000000);
    n[i]=(int)V[i].size();
  } 
  //cout<<n[1]<<endl;

  for(int i=0;i<4;i++){
    sort(V[i].begin(),V[i].end(),greater<ll>());
    V[i][0]=0;
  } 
  //cout<<V[2][1]<<endl;
  for(int i=0;i<4;i++){
    for(int j=0;j<n[i];j++){
      if(j==0) sum[i][j]=V[i][j];
      else sum[i][j]+=sum[i][j-1]+V[i][j];
    }
  }

  for(int i=0;i<n[0];i++){
    for(int j=0;j<n[1];j++){
      for(int k=0;k<n[2];k++,temp=0){
        //cout<<(i+j+k)*w[0]+j+k*2<<endl;
        if((i+j+k)*w[0]+j+k*2>W) break;
        temp=sum[0][i]+sum[1][j]+sum[2][k];
        if((W-(i+j+k)*w[0]-j-k*2)/(w[0]+3)>=n[3]) temp+=sum[3][n[3]-1];
        else temp+=sum[3][(W-(i+j+k)*w[0]-j-k*2)/(w[0]+3)];
        //cout<<i<<" "<<j<<" "<<k<<" "<<temp<<endl;
        ans=max(temp,ans);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= K) {
    cout << K << endl;
  } else if (A + B >= K) {
    cout << A << endl;
  } else {
    cout << 2*A + B - K << endl;
  }
}

Measured memory_bytes: 3636
import java.util.*;
class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long[] HP = new long[N];
    for(int i=0; i < N; i++){
      HP[i]= sc.nextLong();
    }
    Arrays.sort(HP);
    long total = 0;
    int lim = (N<K)? 0 : N-K;
    for(int i = 0; i < lim; i++){
        total += HP[i];
    }
    System.out.print(total);
    
  }
}

Measured memory_bytes: 80632
my $s = <>;
chomp $s;
my $Q = <>;
my $stat = 0;
my $fstr="";
for(my $i=0;$i<$Q;$i++){
    my @dat = split(/\s+/,<>);
    if($dat[0]==1){
        if($stat){
            $stat = 0;
        }else{
            $stat = 1;
        }
    }else{
      if(($dat[1]+$stat)%2){
        $fstr .= "$dat[2]";
      }else{
        $s .= "$dat[2]";
      }
    }
}
$fstr = reverse($fstr);
$s = "$fstr$s";

if($stat==1){
    $s = reverse($s);
}
print "$s";

Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
  int m, nmin, nmax, p[200], i, dif[200], max, ans;
  while (1) {
    scanf("%d%d%d", &m, &nmin, &nmax);
    if (m == 0 && nmin == 0 && nmax == 0) return 0;
    for (i = 0; i < m; i++)
      scanf("%d", &p[i]);

    for (i = 0; i < 200; i++)
      dif[i] = 0;

    for (i = nmin - 1; i < nmax; i++)
      dif[i] = p[i] - p[i + 1];

    max = dif[nmin - 1];
    ans = nmin;
    for (i = nmin; i < nmax; i++)
      if (dif[i] >= max) {
	max = dif[i];
	ans = i + 1;
      }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

bool isSquare(int n){
	for(int i=0;i*i<=n;i++){
		if(i*i==n) return true;
	}
	return false;
}

int main(){
	int N,D;
	cin >> N >> D;
	int X[N][D];
	Rep(i,N){
		Rep(j,D) cin >> X[i][j];
	}
	
	int cnt=0;
	Rep(i,N){
		Rep(j,N){
			int sum=0;
			Rep(k,D){
				sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			//cout << sum << endl;
			cnt+=isSquare(sum);
		}
	}
	cout << (cnt-N)/2;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <stack>
#define LL long long
using namespace std;
int n;
int main(){
    cin>>n;
    if(n<=999) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string name;
    map<string, int> words;
    int max_votes;

    max_votes = 0;
    for(int i = 0; i < n; i++) {
        cin >> name;
        if(words.find(name) == words.end()) {
            words[name] = 1;
        }
        else {
            words[name]++;
        }
        if (words[name] > max_votes) {
            max_votes = words[name];
        }
    }

    vector<string> max;
    map<string, int>::iterator it;

    for(it = words.begin(); it != words.end(); it++) {
        if(words[it->first] == max_votes) {
            max.push_back(it->first);
        }
    }
    string s, temp;
    sort(max.begin(), max.end());
    for(int i = 0; i < max.size(); i++) {
        cout << max[i] << endl;
    }

}

Measured memory_bytes: 26868
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
A = int(input())

if (N % 500) <= A:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3820
n = int(input())
jisyo = dict()
for i in range(n):
    city , point = input().split()
    if city in jisyo.keys():
        jisyo[city].append((int(point),i))
    else:
        jisyo[city] = [(int(point),i)]

jisyo_sort = sorted(jisyo.items() , key = lambda x : x[0])

for c in jisyo_sort:
    point_sort = sorted(c[1] , key = lambda x : x[0] , reverse = True)
    for i in point_sort:
        print(i[1]+1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>



int main(){
  int n,i;
  double kyori;
  int *x,*y;
  scanf("%d",&n);
  x=malloc(n*sizeof(int));
  y=malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&y[i]);
  }
  kyori=0;
  for(i=0;i<n;i++){
    kyori+=abs(x[i]-y[i]);
  }
  printf("%lf\n",kyori);
  kyori=0;
  for(i=0;i<n;i++){
    kyori+=pow(x[i]-y[i],2);
  }
  printf("%lf\n",pow(kyori,0.5));
  kyori=0;
  for(i=0;i<n;i++){
    kyori+=pow(abs(x[i]-y[i]),3);
  }
  printf("%lf\n",pow(kyori,1.0/3.0));
  kyori=0;
  for(i=0;i<n;i++){
    if(kyori<abs(x[i]-y[i])) kyori=abs(x[i]-y[i]);
  }
  printf("%lf\n",kyori);
  return 0;
}

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

def Warshall_Floyd(N,DIST):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                DIST[i][j]=min(DIST[i][j],DIST[i][k]+DIST[k][j])
    return DIST

N,M,L=map(int,input().split())

ABC=[list(map(int,input().split())) for i in range(M)]

Q=int(input())

st=[list(map(int,input().split())) for i in range(Q)]

inf=L+1
dist=[[inf]*N for i in range(N)]
for i in range(N):
    dist[i][i]=0
for A,B,C in ABC:
    dist[A-1][B-1]=min(dist[A-1][B-1],C)
    dist[B-1][A-1]=min(dist[B-1][A-1],C)

dist=Warshall_Floyd(N,dist)
dist_2=[[N+1]*N for i in range(N)]

for i in range(N):
    for j in range(N):
        if dist[i][j]<=L:
            dist_2[i][j]=1
            
for i in range(N):
    dist_2[i][i]=0

dist_2=Warshall_Floyd(N,dist_2)

for s,t in st:
    if dist_2[s-1][t-1]==N+1:
        print(-1)
    else:
        print(dist_2[s-1][t-1]-1)

Measured memory_bytes: 72284
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int flag[30];
  int i,n;
  
  memset(flag,0,sizeof(flag));
  
  for(i=0;i<28;i++){
    cin>>n;
    flag[n-1]=1;
  }
  for(i=0;i<30;i++){
    if(flag[i]!=1)
      printf("%d\n",i+1);
  }
  return 0;
}

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

vector<int>V[20];
int check[20];

int main()
{
    int n,m,x,c[20],a;
    cin >> n >> m >> x;
    for (int j=0; j<n; j++)
    {
        cin >> c[j];
        for (int i=0; i<m; i++)
        {
            cin >> a;
            V[j].push_back(a);
        }
    }
    int ans = 12345678;
    int all = 1<<n;
    bool T;
    for(int mask=0; mask<all; mask++)
    {
        for (int i=0;i<=m;i++)
            check[i]=0;
        T=false;
        int cost=0;
        for(int i=0; i<n; i++)
        {
            if((mask>>i)&1)
            {
                cost+=c[i];
                for(int j=0; j<m; j++)
                    check[j]+=V[i][j];
            }
        }
        for (int i=0; i<m; i++)
        {
            if (check[i]<x)
                T=true;
        }
        if (!T)
            ans=min(ans,cost);
    }
    if (ans==12345678)cout << -1 << endl;
    else cout << ans << endl;
}


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

using namespace std;

int main()
{
  int n,m;
  int sum = 0;
  cin >> n >> m;
  
  int a[100][100];
  int b[100];

  for(int i = 0;i < n;i++)
    {
      for(int j = 0;j < m;j++)
	{
	  cin >> a[i][j];
	}
    }
  for(int k = 0;k < m;k++)
    {
      cin >> b[k];
    }

  for(int i = 0;i < n;i++)
    {
      sum = 0;
      for(int j = 0;j < m;j++)
	{
	  sum += a[i][j]*b[j];
	}
      cout << sum << endl;
    }
}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	LL n,m,x;
	cin>>n>>m>>x;
	VLL c(n);
	VVLL a(n,VLL(m));
	rep(i,n){
		cin>>c[i];
		rep(j,m){
			cin>>a[i][j];
		}
	}
	LL N=pow(2,n)-1;
	VLL alg(m,0);
	LL cost=0;
	LL ans=LLONG_MAX;
	bool ok=true;

	for(LL i=0;i<n;i++){
		for(LL j=0;j<m;j++){
			alg[j]+=a[i][j];
		}
	}
	for(LL j=0;j<m;j++){
		if(alg[j]<x)ok=false;
	}
	if(!ok){
		cout<<-1<<endl;
		return 0;
	}

	for(LL k=0;k<=N;k++){
		rep(i,m)alg[i]=0;
		cost=0;
		ok=true;
		for(int i=0;i<n;i++){
			if(k&(1<<i)){
				for(LL j=0;j<m;j++){
					alg[j]+=a[i][j];
				}
				cost+=c[i];
			}
		}
		for(int i=0;i<m;i++){
			if(alg[i]<x)ok=false;
		}
		if(ok){
			chmin(ans,cost);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());

int main(){
	//freopen("input.txt","r",stdin);
	int n;
	cin >> n;
	cout << n/2 - (n%2 == 0) << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n){
    if(s[i] == 'R') a[i] = 0;
    if(s[i] == 'G') a[i] = 1;
    if(s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j){
    int k = j + (j-i);
    if(k < n){
      if(a[i] == a[j]) continue;
      if(a[i] == a[k]) continue;
      if(a[k] == a[j]) continue;
      ans--; //k = j + (j-i)のときがダメなのでそれを除く。（余事象）
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  cin >> s;
  int k , one;
  cin >> k;
  char ans = '1';
  for (int i = 0 ; i < s.size() ; i ++) {
    if (s.at(i) != '1') {
      ans = s.at(i);
      break;
    }
    one ++;
  }
  if (one >= k) {
    cout << 1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  ll N, x; cin >> N >> x;
  vector<ll> a(N+1, 0);
  rep(i, 1, N+1)  cin >> a[i];
  ll ans=0;
  rep(i, 1, N+1){
    if(a[i]+a[i-1]>x){
      ans   += ((a[i]+a[i-1])-x);
      a[i]  -= ((a[i]+a[i-1])-x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<long long>b(n);
  for(int i=0;i<n;i++){
    b[a[i]-1]+=1;
  }
  long long ans=0;
  for(int i=0;i<n;i++){
    ans+=b[i]*(b[i]-1)/2;
  }
  for(int i=0;i<n;i++){
    if(b[a[i]-1]!=0){
    long long answer=ans-b[a[i]-1]*(b[a[i]-1]-1)/2+(b[a[i]-1]-1)*(b[a[i]-1]-2)/2;
    cout<<answer<<endl;
    }
    else{
      long long answer=ans-b[a[i]-1]*(b[a[i]-1]-1)/2;
    cout<<answer<<endl;
    }
  }
}

Measured memory_bytes: 5760
h, w = map(int, input().split())
mat = [["#" for i in range(w+2)] for j in range(h+2)]
pix = []
for i in range(h):
	s = input()
	pix.append(s)
for i in range(1, h+1):
	for j in range(1, w+1):
		mat[i][j] = pix[i-1][j-1]
for i in mat:
	print("".join(i))

Measured memory_bytes: 9264
N,D = map(int,input().split())
X_list = []
for i in range(N):
    X_list.append(list(map(int,input().split())))
def try_square_root_naive(n):
    m = int(n**.5)
    return True if abs(m*m - n) < 1e-6 else None
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        L = 0
        for d in range(D):
            L += (X_list[i][d]-X_list[j][d])**2
        if try_square_root_naive(L):
            cnt += 1
print(cnt)    
        

Measured memory_bytes: 38384
#include <stdio.h>
int main(void) {
	int c, s;

	while (1) {
		c = getchar();
		if (c == '0')
			break;
		s = c - '0';
		while (1) {
			c = getchar();
			if (c < '0' || '9' < c)
				break;
			s += c - '0';
		}
		printf("%d\n", s);
	}
	return 0;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	for (int i=1; i<=a; i++)
		if (a>b) cout<<b;
	for (int i=1; i<=b; i++)
		if (a<=b) cout<<a;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

p = A[0]
count = 0
b = 0
c = 0
for i in range(1,N):
    a = A[i]
    b += a-p
    c += abs(a-p)
    if abs(b) != c:
        count += 1
        b = 0
        c = 0
    p = a
print(count+1)


Measured memory_bytes: 14252
#include<stdio.h>
int main(void)
{
	int h, m, s;
	int hx, mx, sx;
	int i = 0;
	scanf("%d", &sx);
	mx = sx % 3600;
	s = mx % 60;
	while (sx >= 0){
		sx -= 3600;
		if (sx >= 0){
			i++;
		}
	}
	h = i;
	i = 0;
	while (mx >= 0){
		mx -= 60;
		if (mx >= 0){
			i++;
		}
	}
	m = i;
	printf("%d:%d:%d\n", h, m, s);
	return 0;

}

Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define R(_x, _y) (0 <= _x && _x <= M - 1 && 0 <= _y && _y <= N - 1)
#define A(a) (!(R(x + dx[a], y + dy[a]) && b[y + dy[a]][x + dx[a]]))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N, A, B, x, n;
	ll ans = 0;
	cin >> N >> A >> B;
	vector<int> D(N - 1);
	cin >> x;
	rep(i, 0, N - 1)cin >> n, D[i] = n - x, x = n;
	rep(i, 0, N - 1) {
		ans += min((ll)A * D[i], (ll)B);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k; cin >> k;
	if (k % 2 == 0) {
		cout << (k / 2) * (k / 2) << endl;
	}
	else {
		cout << (k / 2)*((k / 2) + 1) << endl;
	}
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    char a;
    cin >> a;
    if('A' <= a && a <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
import java.io.*;
class Main {
    static long ans=0;
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // StringTokenizer st = new StringTokenizer(br.readLine());
        String s=br.readLine();

        int score=0;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='g'){
                if(i%2==1)
                    score++;
            }
            if(s.charAt(i)=='p'){
                if(i%2==0)
                    score--;
            }

        }
        
    

        System.out.println(score);
    }
}

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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> v;
	rep (i, n) {
		int s;
		cin >> s;
		if (s % 10 != 0) v.push_back(s);
		ans += s;
	}
	if (ans % 10 == 0) {
		if (v.size() == 0) ans = 0;
		else {
			sort(v.begin(), v.end());
			ans -= v[0];
		}
	}
	cout << (ans % 10 == 0 ? 0 : ans) << endl;
	return 0;
}

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

int main()
{
    int K;
    string S;

    cin >> K;
    cin >> S;

    if(S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[]) {
    int N;
    std::cin >> N;
    int a[N];
    for (size_t i = 0; i < N; i++) {
        std::cin >> a[i];
    }
    std::sort(a,a+N);
    std::cout << a[N-1]-a[0] << '\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [0] + list(map(int, input().split())) # 便宜上、先頭に[0]

dp = [None for _ in range(N+1)] # dp[i]：足場iに移動する最小コスト
dp[1] = 0 # 初期位置のため、0
dp[2] = abs(h[2]-h[1])

for i in range(3, N+1):
    one = dp[i-1] + abs(h[i]-h[i-1]) # 1段前からの移動
    two = dp[i-2] + abs(h[i]-h[i-2]) # 2段前からの移動
    dp[i] = min(one, two)

print(dp[N])

Measured memory_bytes: 13928
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	string S;
	cin >> S;
	int a = 0, b = 0, c = 0;
	int Z = S.size();
	rep(i, Z) {
		if (S[i] == 'a')a++;
		if (S[i] == 'b')b++;
		if (S[i] == 'c')c++;
	}
	int m = min(a, min(b, c));
	int M = max(a, max(b, c));
	if (M - m < 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i, h) {
        rep(j, w) {
            if ( i < b && j < a || j >= a && i >= b ) {
                cout << 0;
            }
            if ( i >= b && j < a || i < b && j >= a ) {
                cout << 1;
            }
        }
        cout << endl;
    }
    return 0;
}


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


void solve(long long N, long long M, std::vector<long long> A){

}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    
    std::priority_queue<long long> A;
    long long tmp;
    for(int i = 0 ; i < N ; i++){
      cin >> tmp;
      A.push(tmp);
    }
    
    // 割引券を使う品物を決めていく
    long long maxval;
    for(int j = 0 ; j < M ; j++){
      // 割引額が一番大きい = 現在最も高いものに割引券を使えばよい
      maxval = A.top(); A.pop();
      A.push(maxval/2);
    }

    long long ans = 0;
    for (int i=0; i<N; i++){
      ans += A.top(); A.pop();
    }

    // long long ans = accumulate(A.begin(),A.end(),(long long)0);
    cout << ans << endl;
    
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  string S;
  cin >> S;
  REP(i, S.length()) {
    cout << "x";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
long long n,x,y,s;
using namespace std;
int main()
{
	cin>>n>>x>>y;
	while(1)
	{
		if(x+1==y)
		{
			if(s%2==1) cout<<"Alice";
			else cout<<"Borys";
			return 0;
		}
		if(!s%2) x++;
		else y--;
		s++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n;
    cin >> n;
    int a[10];
    for(int i = 1; i <= 9; i++) a[i] = 111 * i;
    
    int as = 1e9;
    int ans = -1;
    for(int i = 1; i <= 9; i++){
        if(abs(a[i] - n) < as && n <= a[i]){
            as = abs(a[i] - n);
            ans = a[i];
        }
    }
    cout << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

    N = int(input())

    ans = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 2e-9
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 202020
#define LOGN 20
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

int ans, dig[20], ac[20], t;

int main(){
	ll n;
	scanf("%lld", &n);
	while(n){
		dig[t++] = n%10;
		n /= 10;
		ac[t-1] = dig[t-1];
		if(t>1) ac[t-1] += ac[t-2];
	}
	ans = ac[t-1];
	rep(i,1,t) if(dig[i] > 0) ans = max(ans, i*9 + ac[t-1] - ac[i-1] - 1);
	printf("%d\n", ans);
}


Measured memory_bytes: 764
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n){
		cin >> x[i];
	}
	vector<int> tmp = x;
	sort(all(x));
	int mid1 = x[n/2-1];
	int mid2 = x[n/2];
	rep(i,n){
		if(tmp[i] <= mid1) cout << mid2 << '\n';
		else cout << mid1 << '\n';
	}
	return 0;
}


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

signed main(){
  unsigned long long int N;
  cin >> N;
  unsigned long long int count=0;
  for(int i=1;i<sqrt(N)+1;i++){
    if(N%i==0){
      if(count==0){
        count=i+N/i-2;
      }
      else{
        count=min(count,i+N/i-2);
      }
    }
  }
  cout << count << endl;
}


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

int main() {

 int N;
 cin >> N;

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

 sort(A.begin(),A.end());
 reverse(A.begin(),A.end());

 int sum = 0,rest = 2,num1 = 0,flag = 0;
 for(int i = 0; i < N - 1;i++) {
   if(A.at(i) == A.at(i + 1)) sum++;
   else sum = 0;

  if(sum == 3)  {
    cout << A.at(i) * A.at(i) << endl;
    break;
  }

  if(flag && sum == 1) {
    cout << num1 * A.at(i) << endl;
    break;
  }

  if(sum == 1) {
    num1 = A.at(i);
    flag = 1;
  }

  

  if(i == N - 2) cout << 0 << endl;
 }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define MOD 1000000007
using namespace std;

void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  int n,k;
  long long int ans;
  ans = 0;
  cin >> n >> k;
  vector<long long int> a(n+1),b(n+1);
  a[0] = 0, b[0] = n;
  for(int i = 1; i <= n; i++){
    a[i] += a[i-1]+i;
  }
  for(int i = n; i >= 1; i--){
    b[n-i+1] += b[n-i]+i-1;
  }
  for(int i = k-1; i <= n; i++){
      ans += (b[i]-a[i]+1);
  }
  cout << ans%MOD << endl;
return 0;
}


Measured memory_bytes: 6368
N = int(input())
data = []
ans = 0
for i in range(N):
  A = int(input())
  for j in range(A):
    shougen = list(map(int,input().split()))
    hatugen = []
    hatugen.append(i+1)
    hatugen.append(shougen[0])
    hatugen.append(shougen[1])
    data.append(hatugen)
for k in range(2**N):
  ng=0
  hantei = format(k,'b')
  hantei = str(hantei.zfill(N)) 
  for p in range(len(data)):

    ng = 0
    if hantei[data[p][0]-1] == '1':
      
      if hantei[data[p][1]-1] == str(data[p][2]):
        continue
      else:
        ng = 1

        break
  if ng == 0:
    ans = max(hantei.count('1'),ans)
    
print(ans)


    
  
  

Measured memory_bytes: 3064
import sys
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))


Measured memory_bytes: 92696
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(C <= A+B)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))
def calc(A):
    B = [0] * len(A)
    for i in range(len(A)):
        B[max(0,i - A[i])] += 1
        if i + A[i] + 1 < len(A):
            B[i + A[i] + 1] -= 1
    for i in range(1,len(B)):
        B[i] = B[i - 1] + B[i]
    return B

for i in range(K):
  A = calc(A)
  if len(set(A)) == 1 and A[0] == N:
    print(*A)
    break
else:
  print(*A)



Measured memory_bytes: 137248
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){

	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int n = sc.nextInt();

	    double fd = (double)a/(double)b;
	    int fi = a/b;

	    String num = Double.toString(fd-fi);
	    int s = 0;
	    for(int i=0; i<n && i<num.length()-2; i++){
		s += Integer.parseInt(num.substring(2+i,3+i));
	    }

	    System.out.println(s);
	}
    }
}

Measured memory_bytes: 12000
fun main() {
    val n = readLine()!!.last() - '0'
    val ans = when {
        listOf(2, 4, 5, 7, 9).contains(n) -> {
            "hon"
        }
        listOf(0, 1, 6, 8).contains(n) -> {
            "pon"
        }
        else -> {
            "bon"
        }
    }
    println(ans)
}


Measured memory_bytes: 38936
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <map>
using namespace std;


map<int,long long> ma;
int N;
long long K;

int main() {
  while (cin >> N >> K) {
	ma.clear();
	for (int i = 0; i < N; ++i) {
	  int a;
	  long long b;
	  cin >> a >> b;
	  ma[a] += b;
	}
	long long sum = 0;
	for (map<int,long long>::iterator it = ma.begin(); it != ma.end(); ++it) {
	  sum += it->second;
	  if (sum >= K) {
		cout << it->first << endl;
		break;
	  }
	}
  }
}



Measured memory_bytes: 4224
/*
	Author: Luis Manuel D�az Bar�n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 5e2 + 2;


int N;
ll ai[lim];
ll dp[lim][lim];
bool mark[lim][lim];

ll cumul[lim];

ll query(int a, int b)
{
    return cumul[b] - cumul[a - 1];
}

ll DynamicProgrmming(int le, int ri)
{
    if(le == ri)
        return 0;
    
    if(mark[le][ri])
        return dp[le][ri];
    
    mark[le][ri] = true;

    ll curr = inf;

    for(int i = le; i < ri; i++)
    {
        ll auxLe = DynamicProgrmming(le, i);
        ll auxRi = DynamicProgrmming(i + 1, ri);

        ll auxSum = auxLe + auxRi + query(le, ri);

        curr = min(curr, auxSum);
    }
    dp[le][ri] = curr;
    return curr;
}

void solve()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> ai[i];
        cumul[i] = cumul[i-1] + ai[i];
    }

    ll answ = DynamicProgrmming(1, N);

    cout << answ;
}


void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 2048
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    S = input().strip()
    T = input().strip()
    ans = float('inf')
    for i in range(len(S)-len(T)+1):
        ans_ = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                ans_ += 1
        ans = min(ans, ans_)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
n, m = map(int, input().split())

def fac(x):
    ans = 1
    for i in range(1, x + 1):
        ans = (ans * i) % (10 ** 9 + 7)
    return(ans)

if n < m:
    n, m = m, n

if n - m >= 2:
    print(0)
elif n - m == 1:
    print((fac(m)) ** 2 * n % (10 ** 9 + 7) )
else:
    print((fac(n)) ** 2 * 2 % (10 ** 9 + 7))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
int N;
cin >> N;
int v[N];
int  c[N];
for(int i=0;i<N;i++)cin >> v[i];
for(int i=0;i<N;i++)cin >> c[i];

int sum=0;

for(int i=0;i<N;i++){
    if(v[i]>c[i]){
        sum+=v[i]-c[i];
    }
}
cout << sum << endl;

 return 0;
}

Measured memory_bytes: 256