akhauriyash/Code-Regression huggingface dataset:
n = int(input())
x = list(map(int, input().split()))
d = dict(zip(range(0,n), x))
x.sort()
for i in range(0, n):
    if d[i] <= x[n//2-1] :
        print(x[n//2])
    else :
        print(x[n//2-1])

Measured memory_bytes: 38908
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;

	S += S;
	int INF = (int)1 << 60;
	vector<vector<int> > ne(S.size(), vector<int>(26, INF));

	for (int i = (int)S.size() - 2; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			ne[i][j] = ne[i + 1][j];
		}
		ne[i][S[i + 1] - 'a'] = i + 1;
	}
	int res = 0;
	int cur = (S.size() / 2) - 1;


	for (int i = 0; i < T.size(); i++) {
		int b = cur;
		cur = ne[cur][T[i] - 'a'];

		if (cur == INF) {
			cout << -1 << endl;
			return 0;
		}
		res += cur - b;
		cur %= (S.size() / 2);
		//cerr << cur << endl;
	}
	cout << res << endl;
}

Measured memory_bytes: 49004
fun main(args:Array<String>) {
    val (w,h,x,y) = readLine()!!.split(" ").map { it.toInt() }
    val area = (w.toDouble()*h)/2
    val flag = if(x.toDouble() == w.toDouble() / 2 && y.toDouble() == h.toDouble() / 2) 1 else 0
    println("$area $flag")
}


Measured memory_bytes: 36040
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
const int M=998244353;
const int inf=4e18;
const int N=2e5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;cin>>n>>m;
	int a[n];
	unordered_set<int> s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]/=2;
		int p=a[i],cnt=0;
		while(p%2==0)
		{
			p/=2;
			cnt++;
		}
		s.emplace(cnt);
	}
	if(s.size()>1)
	{
		cout<<"0\n";
		return 0;
	}
	int LCM=1;
	for(int i=0;i<n;i++)
	{
		int g=__gcd(LCM,a[i]);
		LCM=(LCM*a[i])/g;
		if(LCM>m)
		{
			cout<<"0\n";
			return 0;
		}
	}
	int x=m/LCM;
	x-=(x%2==0);
	cout<<x/2+1<<'\n';
}

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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int res = 0;
    int tmax = h[0];
    int tmin = 0;
    bool down = false;
    for(int i=1; i<N; i++) {
        if(h[i] >= h[i-1]) {
            tmax = h[i];
            down = false;
        }
        else {
            if(down) tmin = h[i];
            else {
                res += tmax - tmin;
                tmin = h[i];
                down = true;
            }
        } 
    }
    if(!down) res += tmax - tmin;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, C;
  cin>>N>>C;
  int D[C][C], c;
  REP(i, C){
    REP(j, C) cin>>D[i][j];
  }
  int col[3][C]; //色の個数[(i+j)%3][もとのcolor]
  int cost[3][C]; //違和感[(i+j)%3][変更後のカラー]
  REP(i, 3){
    REP(j, C){
      col[i][j]=0;
      cost[i][j]=0;
    }
  }
  REP(i, N){
    REP(j, N){
      cin>>c;
      --c;
      ++col[(i+j)%3][c];
    }
  }
  int sum;
    int ans=2000000000;
  REP(i, C) REP(j, C) REP(k, C){
    if(i == j ||j == k ||k == i) continue;
    sum=0;
    REP(l, C) sum += col[0][l] * D[l][i] + col[1][l]*D[l][j] + col[2][l]*D[l][k];
    ans =min(ans, sum);
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;

int main(){
	string a;
	getline(cin, a);
	transform(a.cbegin(), a.cend(), a.begin(), ::toupper);
	cout << a << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N; cin >> N;
    vector<int> x(N), y(N), h(N);
    rep(i,N) cin >> x[i] >> y[i] >> h[i];
    
    rep(Cx,101)rep(Cy,101){
        int H = -2;
        vector<int> zeroheight_index;
        
        rep(i, N){
            if(h[i]==0){
                zeroheight_index.push_back(i);
                continue;
            }
            
            int height = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy);
            
            if(H == -2){
                H = height;
            }else if(H != height){
                H = -1;
                break;
            }
        }
        
        if(H != -1){
            bool is_collect = true;
            for(int i: zeroheight_index){
                if(max(H - abs(x[i]-Cx) - abs(y[i]-Cy), 0ll) != 0){
                    is_collect = false;
                    break;
                }
            }
            if(is_collect){
                printf("%lld %lld %lld\n",Cx,Cy,H);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/*
# C++
clang++ -std=c++17 filename.cpp -o outname
# C
clang filename.c -o outname
*/

#ifdef __linux__
    #define gcd __gcd
#endif

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main() {
    long long a, b, c;
    scanf("%lld %lld", &a, &b);
    c = (a+b)/2;
    if (abs(a-c) == abs(b-c)) {
        printf("%lld\n", c);
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#define ll long long int
using namespace std;
int main(){
    ll T,i,j,c,d,p,q,n,m,k,val,l,r;
    cin>>l>>r>>n;
    i=(l-1)/n;
    j=(r/n);


        cout<<j-i<<endl;




     }




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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){

    int a,b;
    cin>>a>>b;
    int now=1;
    int ans=0;
    while(now<b){
        now+=a-1;
        ans++;
    }
    cout<<ans<<"\n";
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

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

const int MAXN = 110;
const int MAXW = 10010;
int N, W;
int v[MAXN], w[MAXN];
int dp[MAXN][MAXW];

int main(void) {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j - w[i] < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, a, b;  cin >> w >> a >> b;
    if (a + w < b) {
      cout << b - (a + w) << '\n';
    } else if (b + w < a) {
      cout << a - (b + w) << '\n';
    } else {
      cout << 0 << '\n';
    }

    return 0;
}


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

const int INF = 1 << 30;

int dijkstra(const int s, const int t, const vector<vector<int> >& cost)
{
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
  que.push(make_pair(0, s));
  vector<int> dp(cost.size(), INF);
  while (!que.empty()) {
    const pair<int, int> p = que.top();
    que.pop();

    if (p.second == t)
      return p.first;

    if (dp[p.second] < p.first)
      continue;
    dp[p.second] = p.first;

    for (int i = 0; i < cost.size(); ++i) {
      if (p.first+cost[p.second][i] < dp[i]) {
	dp[i] = p.first+cost[p.second][i];
	que.push(make_pair(dp[i], i));
      }
    }
  }
  return -1;
}

int main()
{
  int n, k;
  while (~scanf("%d %d", &n, &k)) {
    if ((n|k) == 0)
      break;

    vector<vector<int> > cost(n, vector<int>(n, INF));
    for (int i = 0; i < k; ++i) {
      int op;
      scanf("%d", &op);
      if (op == 0) {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", dijkstra(a-1, b-1, cost));
      } else {
	int c, d, e;
	scanf("%d %d %d", &c, &d, &e);
	cost[c-1][d-1] = min(cost[c-1][d-1], e);
	cost[d-1][c-1] = min(cost[d-1][c-1], e);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
def resolve():
    N,M = map(int,input().split())
    import sys
    def modinv(a, mod=10**9+7):
        return pow(a, mod-2, mod)
    def primes(m):
        temp = m
        a = []
        if temp % 2 == 0:
            a.append(1)
            temp //= 2
            while(temp % 2 == 0):
                a[0] += 1
                temp //= 2
        p = 3
        while(p*p < m):
            if temp % p == 0:
                a.append(1)
                temp //= p
                while(temp % p == 0):
                    a[-1] += 1
                    temp //= p
            p += 2
        if temp != 1:
            a.append(1)
        return a
    prime_list = primes(M)
    if prime_list == []:
        print(1)
        sys.exit()
    H = [0 for _ in range(max(prime_list)+1)]
    H[0] = 1
    for k in range(max(prime_list)):
        H[k+1] = (N+k) * H[k] * modinv(k+1) % int(1e9+7)
    ans = 1
    for pr in prime_list: 
        ans *= H[pr]
        ans %= int(1e9+7)
    print(ans)
resolve()

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b,ll c){if(a==b)out(c);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll solve(string s){
    int n=s.size();
    vvi dp0(n,vi(10)),dp1(n,vi(10));
    REP(i,1,s[0]-'0')dp1[0][i]=1;
    dp0[0][s[0]-'0']=1;
    rep(i,n-1){
        rep(j,10){
            rep(k,10){
                if(abs(j-k)>1)continue;
                dp1[i+1][k]+=dp1[i][j];
                if(k==s[i+1]-'0')dp0[i+1][k]+=dp0[i][j];
                if(k<s[i+1]-'0')dp1[i+1][k]+=dp0[i][j];
            }
        }
        REP(j,1,10)dp1[i+1][j]++;
    }
    ll res=0;
    rep(i,10)res+=dp1[n-1][i]+dp0[n-1][i];
    //outvv(dp1);
    //outvv(dp0);
    return res;
}
int main(){
    ll n;cin>>n;
    ll ok=inf,ng=0;
    //out(solve("23"));
    while(ok-ng>1){
        ll md=(ok+ng)/2;
        ll k=solve(to_string(md));
        if(k>=n)ok=md;
        else ng=md;
    }
    out(ok);
}

Measured memory_bytes: 256
H, W = map(int, input().split())
INF = 2 ** 63 - 1
d = []
for i in range(10):
    d.append(list(map(int, input().split())))
A = []
for i in range(H):
    A += list(map(int, input().split()))
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = 0
for i in range(len(A)):
    if A[i] == -1:
        continue
    ans += d[A[i]][1]
print(ans)


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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < N-1; i++) {
            sum += v[i];
        }

        cout << sum / (N-2) << endl;
    }

    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define INF (int)1e9+5
#define nax (int)1e5+2
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hello\n"
#define f first
#define s second
using namespace std;



int main(){
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	ll val=INF;
	for(int i=1;i<=100;i++){
		ll temp =0;
		for(int j=0;j<n;j++){
			ll a= abs(v[j]-i);
			temp += a*a;
			
		}
		if(temp<val){
			val = temp;
		}
	}
	cout<<val;
	
	return 0;
}


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

namespace _170_a
{
    internal class FiveVariables
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine()?.Split(" ").Select(int.Parse).ToArray();
            if (x == null) return;

            for (var i = 0; i < 5; i++)
            {
                if (x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}

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

int solve(vector<vector<int>>& mat) {
  int n = mat.size();
  vector<vector<int>> dp(n, vector<int>(3, 0));
  for(int i = 0; i < 3; ++i) {
    dp[0][i] = mat[0][i];
  }
  for(int i = 1; i < n; ++i) {
    for(int j = 0; j < 3; ++j) {
      for(int k = 0; k < 3; ++k) {
        if (j == k) {
          continue;
        }
        dp[i][j] = max(dp[i][j], dp[i-1][k] + mat[i][j]);  
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < 3; ++i) {
    ans = max(ans, dp[n-1][i]);
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> mat(n, vector<int>(3, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 3; ++j) {
      cin >> mat[i][j];
    }
  }
  cout << solve(mat) << '\n';
  return 0;
}



Measured memory_bytes: 14024
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define INF INT_MAX/3

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 100
#define MAX_T 100
#define LOSE 1
#define BACK -1

struct dataset {
  int board[MAX_N];
  int n;
  int t;
};

int load(dataset* ds) {
  int n, t, l, b;
  scanf("%d %d %d %d", &n, &t, &l, &b);
  if( !(n or t or l or b) ) return 0;
  ds->n = n;
  ds->t = t;
  memset(ds->board, 0, n*sizeof(int));

  REP(i, l) {
    int k;
    scanf("%d", &k);
    ds->board[k] = LOSE;
  }

  REP(i, b) {
    int k;
    scanf("%d", &k);
    ds->board[k] = BACK;
  }
  return 1;
}

void solve(dataset* ds, double dp[MAX_T+1][MAX_N+1]) {
  REP(i, MAX_T+1) REP(j, MAX_N+1) dp[i][j] = 0;
  dp[0][ds->n] = 1;

  FOR(i, 1, 1+ds->t) REP(j, 1+ds->n) {
    if( j == ds->n ) {
      dp[i][j] = 1;
      continue;
    }

    switch( ds->board[j] ) {

    case LOSE:
      if( i < 2 ) {
        dp[i][j] = 0;
        break;
      }
      FOR(m, 1, 7) {
        int p = j+m;
        if( p > ds->n ) p = 2*ds->n - p;
        dp[i][j] += dp[i-2][p]/6;
      }
      break;

    case BACK:
      dp[i][j] = dp[i][0];
      break;

    default:
      FOR(m, 1, 7) {
        int p = j+m;
        if( p > ds->n ) p = 2*ds->n - p;
        dp[i][j] += dp[i-1][p]/6;
      }
      break;

    }
  }
  printf("%lf\n", dp[ds->t][0]);
}

int main() {
  dataset ds;
  double dp[MAX_T+1][MAX_N+1];
  while( load(&ds) ) solve(&ds, dp);

  return 0;
}

Measured memory_bytes: 1304
#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 << "Balanced" << endl;
  }
  if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> A(M), B(M);
    rep(i, M) cin >> A[i];
    int ans = 0;
    rep(i, N)
    {
        rep(j, M) cin >> B[j];
        int cnt = 0;
        rep(j, M)
        {
            cnt += (A[j] * B[j]);
        }
        if (cnt + C > 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 
using namespace std; 
  
// Function to compute num (mod a) 
int mod(string num, int a) 
{ 
    // Initialize result 
    int res = 0; 
  
    // One by one process all digits of 'num' 
    for (int i = 0; i < num.length(); i++) {
         res = (res*10 + (int)num[i] - '0') %a; 
         if(res == 0)
           return i + 1;
    }
  
    return -1;
} 
  
// Driver program 
int main() 
{ 
    string num;
    int i = 0;
    while(i < 1e7)
    {
        num.push_back('7');
        ++i;
    }
    int k;
    cin >> k;
    cout << mod(num, k); 
    return 0; 
} 

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

using namespace std;

int main(void) {
  string o, e;
  cin >> o >> e;

  for (int i = 0; i < o.size() + e.size(); i++) {
    if (i % 2 == 0) {
      cout << o[i / 2];
    } else {
      cout << e[i / 2];
    }
  }
  cout << endl;
  
  return 0;
}

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

using namespace std;
typedef long long int ll;

int n,r=1000;
vector<bool> gp,gna;
string s;

bool als(vector<bool> q){
    bool m=true;
    for(bool itr:q){
        m=m and itr;
    }
    return m;
    
}

int main(){
    cin>>s;
    for(int i=0;i<s.length();i++){
        gp={};
        for(int j=0;j<s.length();j++)gp.push_back(s[i]==s[j]);
        n=0;
        while(!als(gp)){
            gna={};
            for(int l=0;l<gp.size()-1;l++)gna.push_back(gp[l] or gp[l+1]);
            gp=gna;
            n++;
        }
        //printf("%d\n",n);
        r=min(r,n);
        
    }
    printf("%d\n",r);
    
}

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

int n, p[5];
int main(){
    long long ans = 0;
    char s[15], ch[] = "MARCH";
    cin >> n;

    while(n--){
        cin >> s;
        for(int k=0; k<5; ++k)
            if(s[0] == ch[k]) ++p[k];
    }

    for(int i=0; i<3; ++i){
        for(int j=i+1; j<4; ++j){
            for(int k=j+1; k<5; ++k){
                ans += (long long)p[i] * p[j] * p[k];
            }   
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())
num = input().split(" ")
ans_list = []
for i in num:
    x = int(i)
    ans_list.append(x)
M = int(max(ans_list))
ans = 0
for i in ans_list:
    t = int(i)
    ans +=t 
if ans>(2*M):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=1000005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,ans,a[N],cnt[N],tag[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),cnt[a[i]]++;
	for(int i=1;i<=n;i++)
		for(int j=i;j>i-cnt[i]&&j;j--)
			tag[j]++;
	for(int i=1;i<=n;i++) if(tag[i]) ans++;
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		cnt[a[x]]--;
		if(a[x]-cnt[a[x]]>0){
			tag[a[x]-cnt[a[x]]]--;
			if(!tag[a[x]-cnt[a[x]]]) ans--;
		}
		if(y-cnt[y]>0){
			if(!tag[y-cnt[y]]) ans++;
			tag[y-cnt[y]]++;
		}
		cnt[y]++;a[x]=y;
		printf("%d\n",n-ans);
	}
	return 0;
}

Measured memory_bytes: 10496
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        
        int[] A = new int[100000+1];

        long sum = 0;
        for (int x=0; x<N; x++) {
            int temp = nextInt();
            A[temp] ++;
            sum += temp;
        }

        int Q = nextInt();
 
        for (int x=0; x<Q; x++) {
            int B = nextInt();
            int C = nextInt();

            sum += C*A[B] - B*A[B];
            A[C] += A[B];
            A[B] = 0; 
            
            System.out.println(sum);
        }
 
    
    }
 
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

string s;

int main() {
  cin >> s;
  if(s == "A")
    cout << 'T' << endl;
  else if(s == "T")
    cout << "A" << endl;
  else if(s == "G")
    cout << "C" << endl;
  else
    cout << "G" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#define INFTY 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int color[120],d[120];
int M[120][120];
int n;

int start(int x){
  d[x]=0;
  while(true){
    int minimumd=INFTY,u;
    for(int i=0;i<n;i++){
      if(color[i]!=BLACK && minimumd>d[i]){
        minimumd=d[i];
        u=i;
      }
    }
    if(minimumd==INFTY) break;
    color[u]=BLACK;
    for(int i=0;i<n;i++){
      if(d[i]>M[u][i] && color[i]!=BLACK){
        d[i]=M[u][i];
        color[i]=GRAY;
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=d[i];
  }
  return sum;
}

int main(){
  int temp;
  cin>>n;
  for(int i=0;i<n;i++){
    d[i]=INFTY;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>temp;
      M[i][j]=(temp==-1)? INFTY : temp; 
    }
  }
  d[0]=0;
  int ans=start(0);
  cout<<ans<<endl;
}



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

struct Dinic{
    struct edge {
        int64_t to, cap, rev;
        edge(int64_t to, int64_t cap, int64_t rev):to(to), cap(cap), rev(rev){}
    };

    int N, S, T;
    int64_t flow = 0;
    const int64_t INF = 1e18;
    vector<int> level, iter;
    vector<vector<edge>> G;

    Dinic(int N, int S, int T):N(N), S(S), T(T){
        flow = 0;
        level.resize(N);
        iter.resize(N);
        G.resize(N);
    }

    void add_edge(int from, int to, int64_t cap){
        G[from].emplace_back(to, cap, G[to].size());
        G[to].emplace_back(from, 0, G[from].size()-1);
    }

    void bfs(int s){
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(que.size()){
            int v = que.front(); que.pop();
            for(auto& e : G[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int64_t dfs(int v, int t, int64_t f){
        if(v == t) return f;
        for(int& i=iter[v]; i<(int)G[v].size(); i++){
            auto& e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int64_t d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int64_t max_flow(){
        while(true){
            bfs(S);
            if(level[T] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            while(true){
                int64_t f = dfs(S, T, INF);
                if(f == 0) break;
                flow += f;
            }
        }
    }
};

bool is_prime(int64_t n){
    if(n <= 1) return false;
    for(int64_t i=2; i*i<=n; i++) if(n % i == 0) return false;
    return true;
}

int main(){
    int N;
    cin >> N;
    map<int, int> diff;
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        diff[x-1]++;
        diff[x]++;
    }

    vector<int> A[2];
    for(auto& p : diff) if(p.second%2) A[p.first%2].push_back(p.first);
    int sz[2];
    for(int k=0; k<2; k++) sz[k] = A[k].size();

    int S = sz[0]+sz[1];
    int T = S+1;
    Dinic solver(T+1, S, T);
    for(int i=0; i<sz[0]; i++) solver.add_edge(S, i, 1);
    for(int i=0; i<sz[1]; i++) solver.add_edge(sz[0]+i, T, 1);
    for(int i=0; i<sz[0]; i++) for(int j=0; j<sz[1]; j++){
        int d = abs(A[0][i] - A[1][j]);
        if(d%2 && is_prime(d)) solver.add_edge(i, sz[0]+j, 1);
    }

    int m = solver.max_flow();
    int r0 = sz[0]-m, r1 = sz[1]-m;
    int ans = m + r0/2*2 + r1/2*2 + (r0%2)*3;
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    map<string, vector<pair<ll, ll>>> m;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        string S;
        ll p;
        cin >> S >> p;
        m[S].emplace_back(p, i + 1);
    }
    for(auto &i: m) {
        sort(i.second.begin(), i.second.end(), greater<>());
        for(auto &j: i.second) cout << j.second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int w;
    char s[1000];
    gets(s);
    scanf("%d",&w);
    int i=0;
    while(s[i] != '\0')
    {
        if(i%w==0)
            printf("%c",s[i]);

        i++;
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int ima; int imi;
  int ma = 0; int mi = 0;
  for (int i = 1; i <= n; i++){
    int k;
    scanf("%d", &k);
    if (ma <= k) {
      ima = i;
      ma = k;
    }
    if (mi >= k) {
      imi = i;
      mi = k;
    }
  }
  if (imi == ima) {
    printf("0\n");
    return 0;
  }
  printf("%d\n", 2*n-1);
  if (ma + mi >= 0) {
    for (int i = 1; i <= n; i++){
      printf("%d %d\n", ima, i);
    }
    for (int i = 1; i < n; i++){
      printf("%d %d\n", i, i+1);
    }
  } else {
    for (int i = 1; i <= n; i++){
      printf("%d %d\n", imi, i);
    }
    for (int i = n; i > 1; i--){
      printf("%d %d\n", i, i-1);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int r, g, b;
  ci(r, g, b);
  if((100 * r + 10 * g + b) % 4 == 0){
    co("YES");
  }
  else{
    co("NO");
  }
}

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


void solve(long long N, std::vector<long long> P){
    map<long long, long long> ma;
    for(int i=0;i<N;++i){
        ma[P[i]] = i;
    }
    set<long long> se;
    se.insert(ma[N]);
    se.insert(-1);
    se.insert(-2);
    se.insert(N);
    se.insert(N+1);
    long long res = 0;
    for(long long k=N-1;k>0;--k){
        auto it = se.lower_bound(ma[k]);
        it--;
        long long l = *it;
        it--;
        long long ll = *it;
        it++;
        it++;
        long long r = *it;
        it++;
        long long rr = *it;
        if(l>-1){
            res += (l-ll) * (r - ma[k]) * k;
        }
        if(r<N){
            res += (rr-r) * (ma[k] - l) * k;
        }
        se.insert(ma[k]);
        // cout<<ll<<" "<<l<<" "<<r<<" "<<rr<<endl;
        // cout<<res<<endl;
    }
    cout<<res<<endl;
}

// Generated by 1.1.4 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);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 11904
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def solve():
    x = int(stdin.readline().rstrip())
    p = factorization(x)
    num = []
    if x == 1:
        print(0)
        exit()
    for i in p:
        for j in range(i[1]):
            if x%(i[0] ** (j+1)) == 0:
                num.append(i[0] ** (j+1))
                x = x/(i[0] ** (j+1))
            else:
                break
    print(len(num))
    exit()



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int a, b;
  int ans[] = {1, 2, 3};
  cin >> a >> b;
  REP(i, 3) {
    if (ans[i] != a && ans[i] != b) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  typedef long long ll;
int main()
{
      int a,b;
      cin>>a>>b;
      int x=a+b;
      int y=a-b;
      int z=a*b;
//   if(x>y and x>z)
//      cout<<x<<endl;
//   else if(y>x and y>z)
//      cout<<y<<endl;
//   else
//      cout<<z<<endl;
cout<<max(x,(max(y,z)))<<endl;

    return 0;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = int(input())
l = len(input())
dp = [[0] * (n + 2) for j in range(n + 1)]

for i in range(n + 1):
    for j in range(i + 1):
        if i == 0:
            dp[i][j] = 1
        elif j == 0:
            dp[i][j] = (dp[i - 1][1] * 2 + dp[i - 1][0]) % mod
        else:
            dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1] * 2) % mod

print(dp[n][l])


Measured memory_bytes: 229768
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[MAX], b[MAX][3], s[MAX];
int main(){
	int n, m, t1, t2;
	scanf("%d%d", &m, &n);
	rep(i,n)scanf("%d", &a[i]);
	rrep(i,m-1)rep(j,3)scanf("%d", &b[i][j]);
	for(int i = 1;i < n;i++){
		t1 = min(a[i-1], a[i]);
		t2 = max(a[i-1], a[i]);
		s[t1]++;s[t2]--;
	}
	for(int i = 1;i < MAX;i++)s[i] += s[i-1];
	
	ll ans = 0, t;
	for(int i = 1;i < m;i++){
		t = s[i];
		ans += min(b[i][0]*t, b[i][1]*t+b[i][2]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5152
N,W,*A=map(int,open(0).read().split());d={0:0}
while A:
 v,w=A.pop(),A.pop()
 for x,y in d.copy().items():
  if x+w<=W:d[x+w]=max(d.get(x+w,0),y+v)
print(max(d.values()))

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
int in;    
int h, m, s;    
scanf("%d",&in);       
h =in/3600;    
in %=3600;        
m =in/60;    
in %=60;        
s = in;        
printf("%d:%d:%d\n",h,m,s);    
}


Measured memory_bytes: 2104
var x,n,i:longint;
a:array[1..100]of longint;
function f(t:longint):Boolean;
var j,c:longint;
begin
c:=0;
for j:=1 to n do if a[j]=t then inc(c);
f:=c=0;
end;
begin
read(x,n);
for i:=1 to n do read(a[i]);
for i:=0 to 111 do begin
if f(x-i)then begin
writeln(x-i);
exit;
end;
if f(x+i)then begin
writeln(x+i);
exit;
end;
end;
end.

Measured memory_bytes: 1380
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define ld long double
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    ld a,b;
    cin>>a>>b;
    a*=b;
    cout<<(long long int)(a+1e-3);
    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];

int main() {
    string o,e,ans = {};
    cin >> o >> e;
    if(o.size() == e.size()){
        for (int i = 0; i < o.size(); i++) {
            ans += o[i];
            ans += e[i];
        }
        cout << ans << endl;
    }else{
        for (int i = 0; i < e.size(); ++i) {
            ans += o[i];
            ans += e[i];
        }
        ans += o[o.size()-1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    string t = "";
    for (auto i = 0; i < (int)s.size(); i++) {
        if(s[i] != 'B') t += s[i];
        else {
            if(t.size() != 0) t.resize((int)t.size() - 1);
        }
    }
    cout << t << endl;
    return 0;
}

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

a = [[] for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))

b = []
for i in range(m):
	b.append(int(input()))


for i in range(n):
	c = 0
	for j in range(m):
		c += a[i][j] * b[j]

	print(c)



Measured memory_bytes: 6024
#include<stdio.h>
int max(int a, int b){return a<b?b:a;}
char S[11], s, c, j;
long long int n, i;
long long int now, ans, f;

int main(){
	while((c=getchar())!=10){S[s++]=c-'0';}
	n = 1<<s-1;
	for(i=0; i<n; i++){
		now=0; f=0;
		for(j=0; j<s; j++){
			f=f*10+S[j];
			if((i>>j)&1){
				now+=f; f=0;
			}
		}
		now+=f;
		ans += now;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long 
using namespace std;
int main(){
  LL a,b,d;
  char c;
  cin>>a>>b;
  cin>>c;
  cin>>d;
  cout<< a * (100 * b + d) / 100<<endl;
  return 0;
}

Measured memory_bytes: 3616
n = int(input())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))

if sum(aList)< sum(bList):
    print(-1)
else:
    saList=[]
    minusSum=0
    minusCount=0
    for i in range(n):
        sa=aList[i]-bList[i]
        if sa<0:
            minusCount+=1
            minusSum+=sa
        saList.append(sa)
    saList.sort()
    saList.reverse()
    
    i=0
    while(minusSum<0):
        minusSum=minusSum+saList[i]
        i+=1

    ans=minusCount+i
    print(ans)

Measured memory_bytes: 19068
from sys import stdin

def main():

    input = stdin.readline

    N,M = map(int,input().split())
    
    # H = [0] * N
    H = list(map(int,input().split()))

    dame_list = []
    for _ in range(M):
        A,B = map(int,input().split())
        if H[A-1] > H[B-1]:
            dame_list.append(B)
        elif H[A-1] < H[B-1]:
            dame_list.append(A)
        else:
            dame_list.append(A)
            dame_list.append(B)

    ans = N - len(set(dame_list))
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 20192
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxi = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs

maxc = 0
maxci = -1
for i in range(26):
    if maxc < c[i]:
        maxc = c[i]
        maxci = i+1
for dd in range(D):
    prev_a = ans[dd]
    ans[dd] = maxci
    last = [0] * 26
    score = 0
    for d in range(1, D+1):
        td = ans[d-1] - 1
        cumsump = 0
        for i in range(26):
            if td != i:
                tmp = -c[i] * (d - last[i])
                cumsump += tmp
        last[td] = d
        score += S[d-1][td]+cumsump
    if score <= prev_score:
        ans[dd] = prev_a
    
for a in ans:
    print(a)

Measured memory_bytes: 70480
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll s, w;
	cin >> s >> w;
	if(w >= s) puts("unsafe");
	else puts("safe");

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main() {
  char c;
  int arr[26] = {};
  while( cin >> c ) {
    if(isalpha(c)) arr[tolower(c) - 'a']++; 
  }

  char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    cout << alpha[i] << " : ";
    cout << arr[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3092
s = gets.chomp
t = gets.chomp

s_size = s.size
t_size = t.size

tt = t.split('')

a = []
(s_size-t_size+1).times do |i|
  ss = s.slice(i, t_size)
  ss.split('').each_with_index do |c, index|
    break if c != tt[index] && c != '?'
    if index == t_size - 1
      a << (s.slice(0, i) + t + s.slice(i + t_size, s_size - t_size + 1 - i)).gsub(/\?/, 'a')
    end
  end
end

if a.empty?
  puts 'UNRESTORABLE'
else
  puts a.sort.first
end


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());

    int m;
    cin >> m;
    vector<tuple<int, long long, int> > v(m);
    for(int i=0; i<m; ++i){
        cin >> get<0>(v[i]);
        get<2>(v[i]) = i;
    }
    for(int i=0; i<m; ++i)
        cin >> get<1>(v[i]);
    sort(v.begin(), v.end());

    vector<bool> ans(m);
    int k = 0;
    long long score = 0;
    for(int i=0; i<m; ++i){
        int b, index;
        long long c;
        tie(b, c, index) = v[i];

        while(k < n && a[k] <= b){
            score += a[k];
            ++ k;
        }
        ans[index] = (c <= score);
    }

    for(int i=0; i<m; ++i){
        if(ans[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 9404
#include <bits/stdc++.h>
    using namespace std;
    int abs(int x,int y){
    	if(x>y) return (x-y);
    	else return (y-x);
    }
    int main(){
    	int a1,a2,a3,i,j;
    	cin>>a1>>a2>>a3;
    	int t=0,a[4]={0};
    	a[0]=abs(a1-a2),a[1]=abs(a2-a3),a[2]=abs(a3-a1);
    	sort(a,a+3);
    	cout<<a[0]+a[1];
    	return 0;
    }

Measured memory_bytes: 256
from collections import deque
import numpy as np
N = int(input())
h = np.array(list(map(int,input().split())))
count = 0
tmp = deque()
tmp.append(h)
while True:
    st,en = -1,-1
    if len(tmp) == 0:
        break
    count += min(tmp[0])
    tmp[0] -= min(tmp[0])
    if list(tmp[0]) == [0]*len(tmp[0]):
        tmp.popleft()
        continue
    for i in range(len(tmp[0])):
        if st == -1 and tmp[0][i] != 0:
            st = i
        if st != -1 and tmp[0][i] == 0:
            en = i
        if st != -1 and i == len(tmp[0])-1 and tmp[0][i] != 0:
            en = i+1
        if st != -1 and en != -1:
            tmp.append(tmp[0][st:en])
            st,en = -1,-1
    tmp.popleft()
print(count)

Measured memory_bytes: 21016