akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

int main(void){
    int H,W,N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;
    string S,T; cin >> S >> T;

    int r = sr, c = sc;
    REP(i,N){
        if(S[i] == 'L'){
            c--;
            if(c==0){
                cout << "NO" << endl;
                return 0;
            }
        }
        if(T[i] == 'R' && c<W) c++;
    }
    r = sr; c = sc;
    REP(i,N){
        if(S[i] == 'R'){
            c++;
            if(c>W){
                cout << "NO" << endl;
                return 0;
            }
        }
        if(T[i] == 'L' && 1<c) c--;
    }
    r = sr; c = sc;
    REP(i,N){
        if(S[i] == 'U'){
            r--;
            if(r==0){
                cout << "NO" << endl;
                return 0;
            }
        }
        if(T[i] == 'D' && r<H) r++;
    }
    r = sr; c = sc;
    REP(i,N){
        if(S[i] == 'D'){
            r++;
            if(r>H){
                cout << "NO" << endl;
                return 0;
            }
        }
        if(T[i] == 'U' && 1<r) r--;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int i = intRead();
        Console.WriteLine(i < 1000 ? "ABC" : "ABD");
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 11092
N,K = map(int,input().split())
count = 0
if K == 0:
    print(N*N)
else:
    for b in range(K+1,N+1):
        x = N // b
        y = N % b
        count = count + (b-K)*x #植木算.b-1-K+1 = b-K
        if y >= K:
            count = count + y-K+1 #K=0のときはこの式だと1多くなってしまう
    print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> h = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0};
  while (1){
    string S;
    cin >> S;
    if (S == "#"){
      break;
    }
    int N = S.size();
    int ans = 0;
    for (int i = 0; i < N - 1; i++){
      if (h[S[i + 1] - 'a'] != h[S[i] - 'a']){
        ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  double sum = 0;
  rep(i,n) {
    int a;
    cin >> a;
    sum += 1.0/a;
  }
  double ans = 1/sum;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(void){

  int row,column;
  cin>>row>>column;

  vector<int> vec(column);
  vector<vector<int>> mat(row,vector<int>(column));
  vector<int> res(row,0);
  for(int i=0;i<row;i++){
    for(int j=0;j<column;j++) cin>>mat.at(i).at(j);
  }
  for(int i=0;i<column;i++) cin>>vec.at(i);

  for(int i=0;i<row;i++){
    for(int j=0;j<column;j++){
      res.at(i)+=mat.at(i).at(j)*vec.at(j);
    }
    cout<<res.at(i)<<endl;
  }

  return 0;
}



Measured memory_bytes: 3152
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  _n <- readInt
  bs <- readInts
  print $ f bs

f :: [Int] -> Int
f bb@(b:bs) = h b bb

h acc []  = acc
h acc [b] = acc + b
h acc (b:bs@(c:cs)) = h acc' bs
  where acc' = min b c + acc

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

#include <atcoder/maxflow>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace atcoder;
using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector b(n, vector<bool>(m));
    vector<string> t(n);
    for (auto i : irange(0L, n)) {
        string s;
        cin >> s;
        for (auto j : irange(0L, m)) {
            b[i][j] = (s[j] == '.');
        }
        t[i] = s;
    }

    mf_graph<int64_t> g(n * m + 2);
    int64_t src = n * m, dst = n * m + 1;

    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, m)) {
            if (!b[i][j]) {
                continue;
            }

            bool is_even = (i + j) % 2;
            int64_t idx = i * m + j;

            if (is_even) {
                g.add_edge(src, idx, 1);
            } else {
                g.add_edge(idx, dst, 1);
            }

            if (!is_even) {
                continue;
            }

            int64_t dxs[] = {-1, 1, 0, 0};
            int64_t dys[] = {0, 0, -1, 1};
            for (auto k : irange(0L, 4L)) {
                auto dx = dxs[k];
                auto dy = dys[k];

                if (0 <= i + dx && i + dx < n && 0 <= j + dy && j + dy < m) {
                    if (!b[i + dx][j + dy]) {
                        continue;
                    }

                    int64_t idx2 = (i + dx) * m + j + dy;
                    g.add_edge(idx, idx2, 1);
                }
            }
        }
    }

    auto f = g.flow(src, dst);

    for (const auto& edge : g.edges()) {
        if (edge.from == src || edge.to == dst) {
            continue;
        }

        if (edge.flow == 0) {
            continue;
        }

        int64_t i0 = edge.from / m, j0 = edge.from % m;
        int64_t i1 = edge.to / m, j1 = edge.to % m;

        if (i0 == i1) {
            if (j0 > j1) {
                swap(j0, j1);
            }
            t[i0][j0] = '>';
            t[i0][j1] = '<';
        } else {
            if (i0 > i1) {
                swap(i0, i1);
            }
            t[i0][j0] = 'v';
            t[i1][j0] = '^';
        }
    }

    cout << f << endl;
    for (const auto& tt : t) {
        cout << tt << endl;
    }
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	scanf("%s",s);
	
		if(s[0]=='S')
		{
			printf("Cloudy\n");
		}
		else if(s[0]=='C')
		{
			printf("Rainy\n");
		}
		else
		{
			printf("Sunny\n");
		}
	
}

Measured memory_bytes: 1640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n,m,q; cin>>n>>m>>q;
    VV sec(n,V(n,0));
    for(int i=0; i<m; i++){
        int x,y; cin>>x>>y;
        x--;
        y--;
        sec[x][y]++;
    }
    vector<P> query(q);
    for(int i=0; i<q; i++){
        int x,y; cin>>x>>y;
        x--;
        y--;
        query[i] = make_pair(x,y);
    }
    for(int i=0; i<n; i++){
        for(int j=1; j<n; j++){
            sec[i][j] += sec[i][j-1];
        }
    }
    for(int i=0; i<q; i++){
        int ans = 0;
        int l=query[i].first, r=query[i].second;
        for(int j=l; j<=r; j++){
            if(l == 0) ans += sec[j][r];
            else ans += sec[j][r] - sec[j][l-1];
        }
        OUT(ans);
    }
}

Measured memory_bytes: 2688
import math
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
B = A.copy()
B.reverse()
halfN = N / 2

def func(arr):
  ans = 0
  i = -1
  prev = [arr[0]]
  for _ in range(math.ceil((N-1)/2)):
    if i > 0:
      if i >= halfN:
        ans += max([abs(p - arr[i-1]) for p in prev])
      else:
        ans += abs(max(prev) - arr[i-1]) + abs(min(prev) - arr[i])
        prev = [arr[i-1], arr[i]]
    else:
      if -i >= halfN:
        ans += max([abs(p - arr[i]) for p in prev])
      else:
        ans += abs(max(prev) - arr[i-1]) + abs(min(prev) - arr[i])
        prev = [arr[i-1], arr[i]]
    i = -i-1 if i >= 0 else -i+1
  return ans

print(max(func(A), func(B)))

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

int main() {
  int h, w;
  cin >> h >> w;
  int i;
  vector<string> a(h), b(h + 2);
  for (i = 0; i < h + 2; i++) {
    cin >> a[i];
    b[i] = "#";
    if (i == 0 || i == h + 1) {
      int j;
      for (j = 0; j < w; j++) {
        b[i] += "#";
      }
    } else {
      b[i] += a[i - 1];
    }
    b[i] += "#";
    cout << b[i] << endl;   
  }
}


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

int N;
typedef long long ll;
ll res=0,X;
vector<ll> v(51,1),v2(51,1);

int reg(int i,ll j){
    if (i==0 && j==1){
        res += 1;
        return 0;
    }
    else if (j==1) return 0;
    else if(j<=1+v2[i-1]){
        reg(i-1,j-1);
    }
    else if(j==1+v2[i-1]+1){
        res += v[i-1]+1;
        return 0;
    }
    else if(j<=1+v2[i-1]+1+v2[i-1]){
        res += v[i-1]+1;
        reg(i-1,j-1-v2[i-1]-1);
    }
    else if(j==3+2*v2[i-1]){
        res += 2*v[i-1]+1;
        return 0;
    }
}

int main(){
    cin >> N >> X;
    for (int i=1;i<=N;i++){
        v[i] =  2*v[i-1]+1;
        v2[i] = 3 + 2*v2[i-1];
    }

    reg(N,X);
    if (X==0)res =0;
    cout << res << endl;
    }
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 256
//include
//------------------------------------------
#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 <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL 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;
}


int main(){
    LL A,B,C;
    cin >> A >> B >> C;
    LL K;
    cin >> K;
    LL limit=(int) pow(10,18);
    LL pos=0;
    LL tmp1,tmp2,tmp3;
    LL ans=A-B;
    if(K%2==0){
        ans=A-B;
    }
    else{
        ans=B-A;
    }
    if(abs(ans)>limit){
        cout << "Unfair";
    }
    else{
        cout << ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 50001
#define M 100011
#define f first
#define s second
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,T;
vector<PP> G[M]; // to,cost,y,x
vector<int> g[M],used[M];
vector<P> D[M];

priority_queue<PP,vector<PP>,greater<PP> >Q;  
P dijkstra(int a,int b){

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,cnt=t.f.s;
    int y=t.s.f, x=t.s.s;
    int pos=g[y][x];
    if(D[y][x]<t.f||used[y][x]++)continue;
    if(pos==b) return t.f;
    
    for(int i=0;i<G[pos].size();i++){
      PP e=G[pos][i];
      int ncost=cost+e.f.s,ncnt=cnt;
      int ny=e.s.f,nx=e.s.s;
      if(pos!=a&&(ny!=y||abs(x-nx)!=1)) ncost+=T,ncnt++;
      if(!used[ny][nx]&&D[ny][nx]>P(ncost,ncnt)){
	D[ny][nx]=P(ncost,ncnt);
	Q.push(PP(D[ny][nx],P(ny,nx)));
      }
    }
  }
  return P(-1,-1);
}

int main(){
  string s,t;
  cin>>m>>T>>s>>t;
  map<string,int> mp;
  mp[s]=n++;
  mp[t]=n++;

  for(int i=0,a;i<m;i++){
    cin>>a;
    D[i].resize(a,P(INF,INF));
    used[i].resize(a,0);
    for(int j=0;j<a;j++){
      string str;
      cin>>str;
      if(!mp.count(str))mp[str]=n++;
      if(str==s)D[i][j]=P(0,0);
      if(str==s&&Q.empty())Q.push(PP(P(0,0),P(i,j)));
      g[i].push_back(mp[str]);
    }

    for(int j=0,pre=g[i][0],cost;j<a-1;j++){
      cin>>cost;
      int pos=g[i][j+1];
      G[pre].push_back(PP(P(pos,cost),P(i,j+1)));
      G[pos].push_back(PP(P(pre,cost),P(i,j)));
      pre=pos;
    }
  }

  P ans=dijkstra(0,1);
  if(ans==P(-1,-1)) cout<<-1<<endl;
  else cout<<ans.f<<" "<<ans.s<<endl;
  return 0;
}

Measured memory_bytes: 26252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    string s; cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == s[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int H = 0;
	int W = 0;
	while (1) {
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) { break; }
		for (int a = 0; a < H; a++) {
			for (int b = 0; b < W; b++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1744
#!/usr/bin/env python3

# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence

Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])

    codList: Set[int] = set()
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = map(lambda x: int(x), input().split())
        item = (h, w)
        codList.add(item)
        # codList.setdefault(h, {})
        # codList[h][w] = item
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1

    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]

    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if (row + 1, column + 1) in codList:
                continue
            else:
                print(result)
                return

    print(result - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84696
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = 'Yes'
        for r in range(m):
            for c in range(m):
                if a[i+r][j+c] != b[r][c]:
                    flag = 'No'
                    break
        if flag == 'Yes':
            print(flag)
            quit()
print(flag)

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

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

    int ans=1e9;

    for(int i=0;i<n-k+1;i++){
        ans = min(ans,h[i+k-1] - h[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
using System;

namespace Application
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            string result = " ";
            string input = Console.ReadLine();

            if (input == "A") { result = "T"; }
            if (input == "T") { result = "A"; }
            if (input == "C") { result = "G"; }
            if (input == "G") { result = "C"; }


            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int top=0;
  int S[11];
void push(int x){
  top++;
  S[top]=x;
}
 int pop(){
    top--;
    return S[top+1];
 }
int main(){

  int y,t;
    while (scanf("%d",&y)!=EOF){
    if(y!=0){
      push(y);
    }else {
      t=pop();
      printf("%d\n",t);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int n,Alice=0,Bob=0;
	int N;
	//int a[1000];
	cin >> N;
	vector<int> a(N);
	for (n = 0; n < N; n++){
		cin >> a[n];
	}

	sort(a.rbegin(),a.rend());

	for( n = 0; n < N; n++){
		(n % 2 == 0) ? Alice += a[n] : Bob += a[n];
	}
	cout << Alice - Bob << endl;

	return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 2e3 + 20;
const int mod = 1e9 + 7;

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

	int n , x;
	cin >> n >> x;

	ll p = 0 , res = 1;
	for(int i = 0; i < n; i++)
	{
		int y;
		cin >> y;
		p += y;
		if(p <= x)
			res++;
	}

	cout << res << endl;
}










 


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

int main(){
    int N;
    cin>>N;
    int V[100],C[100];
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    for(int i=0;i<N;i++){
        if(V[i]>C[i]) ans+=V[i]-C[i];
    }
    
    cout<<ans<<endl;



}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

C = [0]*4

for i in S:
    if i=='AC':
        C[0]+=1
    elif i == 'WA':
        C[1]+=1
    elif i == 'TLE':
        C[2]+=1
    elif i == 'RE':
        C[3]+=1

print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(C[0],C[1],C[2],C[3]))

Measured memory_bytes: 16336
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= []
l = []
f = 0
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")

n = ai()
a = input()
b = input()
c =a
e = n
for i in range(n):
   # print(b[:n-i],c[i:])
    if b[:n-i] == c[i:]:break
    else:e-=1
print(n*2-e)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] m = new int[n];
		for(int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			x -= m[i];
		}
		Arrays.sort(m);
		int count = m.length + x / m[0];
		System.out.println(count);
	}
}


Measured memory_bytes: 22224
#include <strings.h>
#include <stdio.h>

int min(int a, int b)
{
    return (a > b ? b : a);
}
 
int max(int a, int b)
{
    return (b > a ? b : a);
}
 
int main(void) {
    int i, j, k, h, w;
    int m[501][501];
    int area, hmin;
    char map[500][501];
    int cnt[500][500];

    while (scanf("%d %d", &h, &w), h + w) {
	area = 0;
#if 0
	getchar();
	bzero(m, sizeof(m));
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		char c;
		scanf("%c", &c);
		if (c == '*') c = 0;
		else {
		    if (i == 0) c = 1;
		    else c = m[i-1][j]+1;
		}
		m[i][j] = c;
	    }
	    getchar();
	}
#endif
#if 1
        for (i = 0; i < h; i++){
            scanf("%s", map[i]);
        }
         
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                if (i == 0){
                    cnt[i][j] = map[i][j] == '*' ? 0 : 1;
                }
                else {
                    if (map[i][j] == '.'){
                        cnt[i][j] = cnt[i - 1][j] + 1;
                    }
                    else {
                        cnt[i][j] = 0;
                    }
                }
            }
        }
#endif
#if 0
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		printf("%d", m[i][j]);
	    }
	    putchar('\n');
	}
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		//		if (m[i][j] != 0) {
		    hmin = 10000000;
		    for (k = j; k < w; k++) {
			if (m[i][k] < hmin) hmin = m[i][k];
			if (area < hmin * (k-j+1)) area = hmin * (k-j+1);
		    }
		    //		}
	    }
	}
#endif
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                hmin = 10000000;
                for (k = j; k < w; k++){
                    hmin = min(cnt[i][k], hmin);
                    area = max(area, (k - j + 1) * hmin);
                }
            }
        }
	printf("%d\n", area);
    }
    return 0;
}

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

using namespace std;

int n,q,cnt;
int g[100010];
struct EDGE{
	int t,c,col,next;
}e[200010];

inline void add_edge(int x,int y,int col,int dis){
	e[++cnt].t=y;
	e[cnt].c=dis;
	e[cnt].col=col;
	e[cnt].next=g[x];
	g[x]=cnt;
}

int siz;
int root[100010];
int ls[3000000],rs[3000000],sum[3000000],CNT[3000000];

inline void build(int l,int r,int pre,int &now,int col,int len){
    now=++siz;CNT[now]=CNT[pre]+1;sum[now]=sum[pre]+len;
    if(l==r)return;
    ls[now]=ls[pre];rs[now]=rs[pre];

    int mid=(l+r)>>1;
    if(col<=mid)build(l,mid,ls[pre],ls[now],col,len);
    else build(mid+1,r,rs[pre],rs[now],col,len);
}
inline pair<int,int> query(int root,int l,int r,int pos){
	if(l==r)return make_pair(CNT[root],sum[root]);
	int mid=(l+r)>>1;

	if(pos<=mid)return query(ls[root],l,mid,pos);
	else return query(rs[root],mid+1,r,pos);
}

int fa[100010][20];
int dep[100010],dis[100010];

inline void dfs(int x){
	for(int i=1;i<20;i++)
		fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int i=g[x];i;i=e[i].next)
		if(e[i].t!=fa[x][0]){
			fa[e[i].t][0]=x;
			dep[e[i].t]=dep[x]+1;
			dis[e[i].t]=dis[x]+e[i].c;
			build(1,n-1,root[x],root[e[i].t],e[i].col,e[i].c);
			dfs(e[i].t);
		}
}

inline void swim(int&x,int h){
	for(int i=0;h;i++){
		if(h&1)x=fa[x][i];
		h>>=1;
	}
}
inline int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	swim(x,dep[x]-dep[y]);
	for(int i=19;x!=y;i--){
		if(fa[x][i]!=fa[y][i]||i==0){
			x=fa[x][i];
			y=fa[y][i];
		}
		if(!i)i=1;
	}
	return x;
}

inline pair<int,int> operator+(const pair<int,int>&x, const pair<int,int>&y) {
    return make_pair(x.first+y.first, x.second+y.second);
}
inline pair<int,int> operator-(const pair<int,int>&x, const pair<int,int>&y) {
    return make_pair(x.first-y.first, x.second-y.second);
}
inline pair<int,int> operator*(const pair<int,int>&x, const int&y) {
    return make_pair(x.first*y, x.second*y);
}

int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		add_edge(a,b,c,d);
		add_edge(b,a,c,d);
	}
	fa[1][0]=1;dep[1]=1;root[1]=0;
	dfs(1);

	for(;q;q--){
		int x,y,u,v;
		scanf("%d%d%d%d",&x,&y,&u,&v);

		int LCA=lca(u,v);
		int ans=dis[u]+dis[v]-dis[LCA]*2;

		auto q = query(root[u],1,n-1,x)+query(root[v],1,n-1,x)-query(root[LCA],1,n-1,x)*2;
		ans-=q.second;
		ans+=q.first*y;
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 52608
#include<stdio.h>
int main(void)
{
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    
    if(A>=13){
        printf("%d\n",B);
    }else if(A>=6 && A<=12){
        printf("%d\n",B/2);
    }else if(A>=0 && A<=5){
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
import itertools
n,m,x = map(int,input().split())
book = []
for _ in range(n):
    book.append(list(map(int,input().split())))

buy = list(itertools.product([0,1],repeat=n))

money = []

for i in range(len(buy)):
    algo = [0 for _ in range(m)]
    money_tmp = 0
    #j冊目の本
    for j in range(len(buy[i])):
        for k in range(m):
            algo[k] += book[j][k+1] * buy[i][j]
        money_tmp += book[j][0]*buy[i][j]
    #print(money_tmp)
    if min(algo) >= x:
        money.append(money_tmp)
        
if len(money) > 0:    
    print(min(money))
else:
    print(-1)

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

int main(){
  int n;cin>>n;
  int p[n+10];
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int cnt=0;
  for(int i=1;i<n-1;i++){
    if(p[i]!=min({p[i-1],p[i],p[i+1]})&&p[i]!=max({p[i-1],p[i],p[i+1]})){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0 and i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int s[101];

int qaq(int x) {return x % 10 ? x : 0;}

int main(void) {
    int N, sum = 0, ans = 0;
    cin >> N;
    for(int i = 0; i < N ; i++) {
        cin >> s[i];
        sum += s[i];
    }

    ans = max(ans, qaq(sum));
    for(int i = 0; i < N; i++) {
        ans = max(ans, qaq(sum - s[i]));
    }

    return !printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int p,q,r,ans=0;
  scanf("%d%d%d",&p,&q,&r);
  if(p>=q && p>=r){
    ans=q+r;
  }
  else if(q>=r && q>=p){
    ans=p+r;
  }
  else{
    ans=p+q;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
// AOJ 0142: Nature of Prime Numbers
// 2017.8.16 bal4u@uu
// 2018.5.4

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int w;
	char ob[20];

	if (!n) { pc('0'); return; }
	w = 0; while (n) ob[w++] = n%10 + '0', n /= 10;
	while (w--) pc(ob[w]);
}

#define MAX  10000
#define HALF 5000
int  a[HALF+5];
int  d[HALF+5];
char f[MAX+5];

int main()
{
	int n, i, j, k, b, m;

	while (n = in()) {
		k = n >> 1;

		memset(d, 0, sizeof(d));
		memset(f, 0, sizeof(f));
		m = 0;
		for (i = 1; i <= k; i++) {
			b = i*i % n;
			if (!f[b]) f[b] = 1, a[m++] = b;
		}
		for (i = 0; i < m; i++) {
			for (j = 0; j < i; j++) {
				if (b = a[i] - a[j]) {
					if (b < 0) b += n;
					if (b > k) b = n - b;
					d[b]++;
				}
			}
		}
		for (i = 1; i <= k; i++) out(d[i]<<1), pc('\n');
	}
	return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
bool c[N];
int a[4][N],n;
inline void add(int x) { while (x<=n) c[x]^=1,x+=x&-x; }
inline bool sum(int x) { int ans=0; while (x) ans^=c[x],x^=x&-x; return ans; }
inline bool solve(int m) {
	bool o=0;int i,t;
	for (i=1;i<=n;i++) c[i]=0;
	for (i=m;i>0;i-=2) {
		for (t=a[2][i]/3+1;t;t^=t&-t) o^=c[t];
		for (t=a[2][i]/3+1;t<=n;t+=t&-t) c[t]^=1;
	}
	return o;
}
int main()
{
	int i,j,t;n=gi();
	bool A=0,B=0,AA=0,BB=0;
	for (i=1;i<=3;i++)
		for (j=1;j<=n;j++)
			a[i][j]=gi();
	for (i=1;i<=n;i++) {
		t=a[2][i]/3+1;
		if (a[1][i]>a[2][i]) (i&1?A:B)^=1;
		if (!((a[1][i]==t*3-2&&a[2][i]==t*3-1&&a[3][i]==t*3)||(a[1][i]==t*3&&a[2][i]==t*3-1&&a[3][i]==t*3-2))||((t&1)!=(i&1)))
			return puts("No"),0;
	}
	AA=solve(n-!(n&1));
	BB=solve(n^(n&1));
	if (AA^B) puts("No");
	else if (BB^A) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
  int x,y,i,j=0;
  int xy,yaku[100];
    
    scanf("%d%d",&x,&y);
    
    if(x>=y) xy=x%y;
    else xy=y%x;
    
    for(i=1; i<=xy; i++)
    {
      
      if(y%i==0 && xy%i==0)
	{
	  yaku[j]=i;
	  j++;
	}
        
    }
    printf("%d\n",yaku[j-1]);
    return 0;
}



Measured memory_bytes: 2048
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
const int MYINF = 1e9+7;

ll S[256];
int idx;

void push(ll x) {
	S[idx++] = x;
}

ll pop() {
	if (idx == 0) {
		fprintf(stderr, "Stack is empty");
		exit(1);
	}
	return S[--idx];
}

int main(int argc, char **argv)
{
	ll x, y;
	char buf[16];

	while (scanf("%s", buf) > 0) {
		if (buf[0] == '+') {
			y = pop();
			x = pop();
			push(x + y);
		} else if (buf[0] == '-') {
			y = pop();
			x = pop();
			push(x - y);
		} else if (buf[0] == '*') {
			y = pop();
			x = pop();
			push(x * y);
		} else {
			push(atoll(buf));
		}
	}
	printf("%lld\n", pop());
	return 0;
}

Measured memory_bytes: 548
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    auto s = readln.chomp.to!(dchar[]).sort();
    bool ok = s[0] == s[1] && s[1] != s[2] && s[2] == s[3];
    writeln(ok ? "Yes" : "No");
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
while True:
    T, D, L = map(int, input().split())
    if T == 0:
        exit()
    ans = [0] * 200001
    for i in range(T):
        x = int(input())
        if i < T - 1 and x >= L:
            ans[i] += 1
            ans[i + D] -= 1

    for i in range(T):
        ans[i + 1] += ans[i]
    print(len([x for x in ans[:T - 1] if x > 0]))



Measured memory_bytes: 12596
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int ary[3];

signed main(){
    io();

    rep(i,3) in(ary[i]);
    int ans=0;
    bool f=true;
    for(auto e:ary){
        if(e&1){
            out(0);
            return 0;
        }
    }
    while(f){
        int a=ary[0]/2,b=ary[1]/2,c=ary[2]/2;
        //show(ary[0],b,c,b+c);
        if(b+c==ary[0]&&a+c==ary[1]&&a+b==ary[2]){
            ans=-1;
            break;
        }
        ary[0]=b+c;
        ary[1]=a+c;
        ary[2]=a+b;
        ans++;
        for(auto e:ary) if(e&1) f=false;
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 888
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main()
{
    int N, M;
    scanf("%i %i", &N, &M);
    dsu d(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        scanf("%i %i", &A, &B);
        d.merge(A-1, B-1);
    }
    printf("%zu\n",d.groups().size()-1);
}


Measured memory_bytes: 8256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int r = 0;
            for (int i = 1; i < 13; i++) {
                n -= sc.nextInt() - sc.nextInt();
                if (n <= 0 && r == 0) {
                    r = i;
                }
            }
            System.out.println(n <= 0 ? r : "NA");
        }
    }
}


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

using namespace std;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()

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

    vector<int> v[m];

    for (size_t i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (size_t j = 0; j < k; j++)
        {
            int l;
            cin >> l;
            l--;
            v[i].push_back(l);
        }
    }
    int p[m];
    for (auto &x : p)
        cin >> x;
    int ans = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        int f = 1;
        for (size_t j = 0; j < m; j++)
        {
            int cnt = 0;
            for (size_t k = 0; k < v[j].size(); k++)
            {
                if ((i & (1 << v[j][k])) > 0)
                    cnt++;
            }
            if (cnt % 2 != p[j])
            {
                f = 0;
                break;
            }
        }
        if (f)
            ans++;
    }
    cout << ans << 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 < int(n); ++i)

int main(){
    int a,b; cin >> a >> b;
    if(a >= 2*b) cout << a - 2*b << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().strip().split())
H = list(map(int, input().strip().split()))
best = abs(T-A-0.006*H[0])
num = 1
for i in range(1, N):
    if best > abs(T-A-0.006*H[i]):
        best = abs(T - A - 0.006 * H[i])
        num = i+1
print(num)


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

using namespace std;

typedef long long ll;

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

long gcd(long a, long b) {
    if (a < b) {
        swap(a, b);
    }

    while (b != 0) {
        a = a % b;
        swap(a, b);
    }

    return a;
}

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

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

    if (x % 11 == 0) {
        cout << (x / 11) * 2 << endl;
    } else if (x % 11 <= 6) {
        cout << (x / 11) * 2 + 1 << endl;
    } else {
        cout << (x / 11) * 2 + 2 << endl;
    }

    return 0;
}

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

using namespace std;

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

        cout << n * (n - 1) / 2 - n / 2 << '\n';
        for (int i = 1; i <= n; i++)
                for (int j = i + 1; j <= n; j++)
                        if (i + j != n - (n & 1) + 1)
                                cout << i << ' ' << j << '\n';

        return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> store(N);
  for (auto &m : store) {
    cin >> m.first >> m.second;
  }
  
  ll albuy = 0;
  ll alprice = 0;
  sort(store.begin(), store.end());
  for (int i = 0; i < N; i++) {
    if(albuy + store[i].second > M) {
      alprice += (M - albuy) * store[i].first;
      break;
    }
    albuy += store[i].second;
    alprice += (store[i].first * store[i].second);
  }
  
  cout << alprice << endl;
}

Measured memory_bytes: 1792
n=int(input())
s=list()
for i in range(n):
  s.append(input())

import collections

c=collections.Counter(s)



l=list()
max_=0
for cc in c.values():
  max_=max(cc, max_)

for ca,cb in c.items():
  if max_==cb:
    l.append(ca)

l.sort()
for ll in l:
  print(ll)


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

typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
public:
    UnionFind(size_t n){
        m_parent.resize(n);
        iota(m_parent.begin(), m_parent.end(), 0);

        m_rank.resize(n);
        fill(m_rank.begin(), m_rank.end(), 0);
    }

    int Find(int x){
        if(m_parent[x] == x){
            return x;
        }else{
            m_parent[x] = Find(m_parent[x]);
            return m_parent[x];
        }
    }

    void Union(int x, int y){
        auto xroot = Find(x);
        auto yroot = Find(y);
        if(m_rank[xroot] > m_rank[yroot]){
            m_parent[yroot] = xroot;
        }else if(m_rank[xroot] < m_rank[yroot]){
            m_parent[xroot] = yroot;
        }else if(xroot != yroot){
            m_parent[yroot] = xroot;
            m_rank[xroot] = m_rank[xroot] + 1;
        }
    }

    int GetSize(){
        for(size_t i=0;i<m_parent.size();i++){
            m_parent[i] = Find(m_parent[i]);
        }
        std::set<int> s(m_parent.begin(), m_parent.end());
        return s.size();
    }

    int GetSize(int x){
        auto xroot = Find(x);
        int res = 0;
        for(size_t i=0;i<m_parent.size();i++){
            m_parent[i] = Find(m_parent[i]);
            if(xroot == m_parent[i]) res++;
        }
        return res;
    }

    std::vector<int> m_parent;
    std::vector<int> m_rank;
};

int main()
{
    ll N, M;
    cin >> N >> M;
    ll pi, xi, yi;
    vector<ll> P, X, Y;
    for(int i=0;i<N;i++){
        cin >> pi;
        P.push_back(pi-1);
    }
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        cin >> xi >> yi;
        uf.Union(xi-1, yi-1);
    }
    map<ll, set<ll>> xy_uf;
    map<ll, set<ll>> p_uf;
    for(int i=0;i<N;i++){
        auto root = uf.Find(i);
        if(xy_uf.count(root)==0){
            xy_uf[root] = set<ll>();
            p_uf[root] = set<ll>();
        }
        xy_uf[root].insert(i);
        p_uf [root].insert(P[i]);
    }
    ll res = 0;
    for(auto m : p_uf){
        set<ll> r;
        set_intersection(
            xy_uf[m.first].begin(), xy_uf[m.first].end(),
            p_uf [m.first].begin(), p_uf [m.first].end(),
            inserter(r, r.end())
        );
        res += r.size();
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 29940
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main ()
{
	char a[109],b[109];
	scanf("%s%s",a,b);
	int len1,len2;
	len1 = strlen(a);
	for (int i = 0; i < len1; i++)
		a[i+len1] = a[i];
	int flag = 0;
	for (int i = 0; i < len1; i++){
		if (a[i] == b[0])
		{
			int pos = i;
			for (int j = 0; j < len1; j++){
				if (a[pos] == b[j])
				{
					flag++;
					pos++;
				}
				else break;
			}
			if (flag == len1) {
			printf("Yes\n");
			return 0;
		}
		}
		flag = 0;
	}
	printf("No\n");
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll mod = 1e9+7;
const ll MX = 1e6+5;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


long long Modpow(long long a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    long long res = Modpow(a, n/2);
    return res * res % mod;
  }
  return a * Modpow(a, n-1) % mod;
}

int inv(int n) { // 逆元
  return Modpow(n, mod-2);
}



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

  int n;
  cin >> n;
  vi a(n);
  Sieve s(MX);
  rep(i,n) cin >> a[i];
  map<int, int> mp;
  rep(i,n) {
    vector<P> f = s.factor(a[i]);
    for(P p : f) {
      chmax(mp[p.first], p.second);
    }
  }
  ll lcm = 1;
  for(P p : mp) {
    lcm *= Modpow(p.first, p.second);
    lcm %= mod;
  }
  int ans = 0;
  rep(i,n) {
    ll b = inv(a[i]);
    ans += (lcm*b) % mod;
    ans %= mod;  
  }
  cout << ans << endl;
}

Measured memory_bytes: 5112
import sys
from collections import defaultdict
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

def main():
    n,k,l = map(int,input().split())
    Road = [list(map(int,input().split())) for i in range(k)]
    Train = [list(map(int,input().split())) for i in range(l)]

    uf_r = UnionFind(n)
    uf_t = UnionFind(n)

    for i in range(k):
        uf_r.union(Road[i][0]-1,Road[i][1]-1)

    for i in range(l):
        uf_t.union(Train[i][0]-1,Train[i][1]-1)

    Roots_dict = defaultdict(int)
    Roots = []
    for i in range(n):
        Roots.append(str(uf_r.find(i))+' '+str(uf_t.find(i)))
        Roots_dict[Roots[i]] += 1

    ans = [0]*n

    for i in range(n):
        ans[i] = Roots_dict[Roots[i]]

    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 134008