akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int length = 0;
  int height = 0;
  int area = 0;
  int cir = 0;

  scanf("%d %d",&length, &height);
  area = length*height;
  cir = length*2+height*2;

  printf("%d %d\n",area,cir);

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<math.h>

#define PI 3.14159

typedef struct Point{
    double x,y;
}Point;

void koch(int n,Point a,Point b){
    if(n==0) return;
    Point s,t,u;
    double th = PI*60.0/180.0; //ラジアン
    s.x=(2.0*a.x+1.0*b.x)/3.0; //内分
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
    
}
int main(void){
    int n;
    Point a,b;
    a.x=0.0;
    a.y=0.0;
    b.x=100.0;
    b.y=0.0;
    scanf("%d",&n);
    //
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    
    return 0;
}



Measured memory_bytes: 2104
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/17/20 20:48:51
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string s; cin>>s;
  int bs = 0;
  ll ans = 0;
  for (auto c:s) {
    if (c == 'B') {
      bs++;
    } else {
      ans += bs;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 720
import queue

class Dinic:
    """Implementation of Dinic's Alogorithm"""

    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        # to: 行き先, cap: 容量, rev: 反対側の辺
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})

    # sからの最短距離をbfsで計算
    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    # 増加バスをdfsで探す
    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            # bfsで到達不可
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)
                
N = int(input())
red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split())) for i in range(N)]


red = sorted(red, key = lambda a: a[1])
red = sorted(red, key = lambda a: a[0])
blue = sorted(blue, key = lambda a: a[1])
blue = sorted(blue, key = lambda a: a[0])

btor = [[] for i in range(N)]

for i in range(N):
    by,bx = blue[i]
    for j in range(N):
        ry,rx = red[j]
        if ry < by and rx < bx:
            btor[i].append(j)

A = Dinic(2*N+2)

for i in range(N):
    A.add_edge(0,i+1,1)
    A.add_edge(N+i+1,2*N+1,1)

for i in range(N):
    for j in btor[i]:
        A.add_edge(i+1, N+1+j,1)
        
ans = A.max_flow(0,2*N+1)
            
print(ans)

Measured memory_bytes: 50008
#include<cstdio>
const int N=3002,M=1000000007;
int n,m,i,j,f[N][N][2],ans;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		f[0][i][0]=1;
	f[0][0][1]=1;
	for(i=0;i<m;i++)
		for(j=0;j<=n;j++){
			if(j){
				f[i+1][j-1][1]=(f[i+1][j-1][1]+f[i][j][1])%M;
				if(j==1)
					f[i+1][j-1][1]=(f[i+1][j-1][1]+f[i][j][0])%M;
				else
					f[i+1][j-1][0]=(f[i+1][j-1][0]+f[i][j][0])%M;
			}
			if(j<n){
				f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][1])%M;
				f[i+1][j+1][0]=(f[i+1][j+1][0]+f[i][j][0])%M;
			}
			if(j){
				f[i+1][j][1]=(f[i+1][j][1]+f[i][j][1])%M;
				if(j==1)
					f[i+1][j][1]=(f[i+1][j][1]+f[i][j][0])%M;
				else
					f[i+1][j][0]=(f[i+1][j][0]+f[i][j][0])%M;		
			}
			if(j<n){
				f[i+1][j][1]=(f[i+1][j][1]+f[i][j][1])%M;
				f[i+1][j][0]=(f[i+1][j][0]+f[i][j][0])%M;	
			}
		}			
	for(i=0;i<=n;i++)
		ans=(ans+f[m][i][1])%M;
	printf("%d",ans);
//	while(1);
}


Measured memory_bytes: 70528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int D = ri();
		String[] s = new String[30];
		s[25] = "Christmas";
		s[24] = "Christmas Eve";
		s[23] = "Christmas Eve Eve";
		s[22] = "Christmas Eve Eve Eve";
		Console.WriteLine(s[D]);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;
int main(int argc, char const *argv[]) {
  int H, W;
  std::cin >> H >> W;
  vector<string> S(H);
  vector<vector<int>> zaatu_x(H, vector<int> (0,0)),zaatu_y(W,vector<int> (0,0));
  for(int i=0;i<H;i++) std::cin >> S[i];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#') zaatu_x[i].push_back(j),zaatu_y[j].push_back(i);
    }
  }
  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int candi=0,right,left;
      auto ite = lower_bound(zaatu_x[i].begin(),zaatu_x[i].end(),j);
      if(ite==zaatu_x[i].end()) right=W;
      else if(*ite==j) continue;
      else right=*ite;
      if(ite==zaatu_x[i].begin()) left=-1;
      else {
        ite--;
        left=*ite;
      }
      candi+=right-left-1;
      ite=lower_bound(zaatu_y[j].begin(),zaatu_y[j].end(),i);
      if(ite==zaatu_y[j].end()) right=H;
      else if(*ite==i) continue;
      else right=*ite;
      if(ite==zaatu_y[j].begin()) left=-1;
      else{
        ite--;
        left=*ite;
      }
      candi+=right-left-1;
      ans=max(ans,candi);
    }
  }
  std::cout << ans - 1 << '\n';
  return 0;
}


Measured memory_bytes: 40448
import bisect

class Peaks:
    def __init__(self, N, H, next_obs_heights):
        self.N = N
        self.H = H
        self.next_obs_heights = next_obs_heights

    def solve(self):
        result = 0

        for i in range(N):
            if len(next_obs_heights[i]) == 0:
                result += 1
                continue

            next_num = len(next_obs_heights[i])
            if self.H[i] > next_obs_heights[i][next_num-1]:
                result += 1

        print(result)

N, M = map(int, input().split())
H = list(map(int, input().split()))
next_obs_heights = [ [] for i in range(N) ]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    bisect.insort(next_obs_heights[a], H[b])
    bisect.insort(next_obs_heights[b], H[a])

peaks = Peaks(N, H, next_obs_heights)
peaks.solve()


Measured memory_bytes: 96056
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
c = collections.Counter(prime_factorize(n))
ans = 0
for _,value in c.items():
    i = 0
    while value>i:
        i += 1
        value -= i
    ans += i
print(ans)

Measured memory_bytes: 9412
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000000 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    ll res=0;
    for(ll i=k;i<=n+1;i++){
        res+=i*(n-i+1)+1;
        res=res%MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll x, a, b;
    cin >> x >> a >> b;
    if(b <= a){
        cout << "delicious" << endl;
    }else if(b <= a + x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    ll res = 0;
    res += (a / 2) * 2;
    res += b;
    res += (d / 2) * 2;
    res += (e / 2) * 2;
    if (a && d && e){
        int odds = (a & 1) + (d & 1) + (e & 1);
        if (odds == 3) res += 3;
        else if (odds == 2) res += 1;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
//ダブリング
int N; ll K; int A[201010];
int dp[61][201010];

int main(){
  cin >> N >> K;
  rep(i,N) cin >> A[i],A[i]--;
  rep(cu,N) dp[0][cu] = A[cu];
  for(int i=1;i<61;i++) rep(cu,N) dp[i][cu] = dp[i-1][dp[i-1][cu]];
  int cu = 0;
  for(int p=60;p>=0;p--) if(K&(1LL << p)) cu = dp[p][cu];
  cout << cu+1 << endl;
}

Measured memory_bytes: 52352
#include <cstdio>
#include <iostream>
#include <vector>
#include <complex>
#include <utility>
#include <algorithm>
#include <numeric>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
#define X real()
#define Y imag()
const double INF = (1e15), EPS = (1e-8);
const pair<int,double> init(8,INF);
P Points[10];
pair<int,double> ans, DP[2];

inline double dot(P a, P b){ return a.X*b.X + a.Y*b.Y;}
inline double cross(P a, P b){ return a.X*b.Y - a.Y*b.X;}

inline P intersection(L a, L b){
  P bf = b.first, af = a.first-bf, as = a.second-bf, bs = b.second-bf;
  return af + bf + cross(bs,af)/(-cross(bs,as)+cross(bs,af))*(as-af);
}

inline bool on_line(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS) return false;
  if(cross(b,c) < -EPS) return false;
  if(dot(b,c) < 0) return false;
  if(norm(b) + EPS < norm(c)) return false;
  return true;
}

int main(){
  int n;
  while(cin >> n, n){
    ans = init;
    for(int i = 0; i < n; ++i){
      double x, y;
      cin >> x >> y;
      Points[i] = P(x,y);
    }
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    do{
      if(perm[0] == n-1) break;
      if(perm[0] > perm.back()) continue;
      DP[1] = init;
      DP[0] = pair<int,double>(0,abs(Points[perm[1]]-Points[perm[0]]));
      for(int i = 1; i < n-1; ++i){
        if(DP[0] >= ans && DP[1] >= ans) break;
        P prev = Points[perm[i-1]], cur = Points[perm[i]], nex = Points[perm[i+1]];
        int c = !on_line(prev, nex, cur);
        pair<int,double> val = DP[0];
        double l = abs(nex-cur);
        DP[1].second += l;
        DP[0].second += l;
        DP[0].first += c;
        DP[0] = min(DP[0],DP[1]);
        if(i == n-2) break;
        P nexx = Points[perm[i+2]];
        if(norm(cross(cur-prev,nexx-nex)) < EPS or on_line(prev,nex,cur) or on_line(cur,nexx,nex)){
          DP[1] = init;
          continue;
        }
        P cp = intersection(L(prev,cur),L(nex,nexx));
        if((!on_line(cp,nexx,nex)) or (!on_line(prev,cp,cur))){
          DP[1] = init;
          continue;
        }
        DP[1] = val;
        ++DP[1].first;
        DP[1].second += abs(cp-cur) + abs(cp-nex);
      }
      ans = min(ans, DP[0]);
    }while(next_permutation(perm.begin(), perm.end()));
    printf("%d %.5f\n", ans.first, ans.second);
  }
  return 0;
}



Measured memory_bytes: 3168
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( n == -1 )  break ;

    for ( i = 4; n / i; i *= 4 );
    while ( i /= 4 )
    {
      printf ( "%d", ( n / i ) % 4 );
    }
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
       String s = scanner.next();

       int count = 0;
       for (int i = 0; i < 3; i++) {
           String str = s.substring(i, i+1);
           if (str.equals("1")) {
               count++;
           }
       }
       System.out.println(count);
    }

}

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

#include <string>
using namespace std;

int main() {
    string S;
    string T;
    cin >> S >> T ;
    
    int matchCount= 0;
    for(int i = 0; i < S.length(); i++){
        if (S[i] == T[i]) matchCount++;
    }

    cout << matchCount << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se( T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int N;
  cin >> N;
  if(N==1) cout << "Hello World" <<endl;
  else{
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
  return 0;
}

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

int main(){
    int N, K;
    int tmp;
    cin >> N >> K;

    vector<int> val;
    for (int i=0; i<N; i++){
        cin >> tmp;
        val.push_back(tmp);
    }

    sort(val.begin(), val.end());
    tmp = 0;
    for (int i = 0; i < K; i++)
    {
        tmp += val[i];
    }

    cout << tmp;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong extgcd(llong a,llong b,llong& x,llong& y){
    llong d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

llong  mod_inverse(llong  a,llong m){
    long long int x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n; cin>>n;
    int c=0;
    REP(i,4) if(n[i]=='2') ++c;
    cout<<c<<endl;
    return  0;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    vector<vector<ll>> dp(s.size(), vector<ll>(2, 0));
    dp[0][1] = 2;
    dp[0][0] = 1;
    vector<ll> n(s.size());
    rep(i, s.size()) n[i] = s[i] - '0';
    for(ll i = 1; i < n.size(); ++i){
        if(n[i] == 0){
            dp[i][0] = (3 * dp[i - 1][0] % MOD);
            dp[i][1] = dp[i - 1][1];
            dp[i][0] %= MOD;
            dp[i][1] %= MOD;
        }else{
            dp[i][0] = (3 * dp[i - 1][0] % MOD) + (dp[i - 1][1] % MOD);
            dp[i][1] = (2 * dp[i - 1][1] % MOD);
            dp[i][0] %= MOD;
            dp[i][1] %= MOD;
        }
    }
    ll ans = (dp[n.size() - 1][0] + dp[n.size() - 1][1]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 6656
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N = int(input())

    g = tuple(set() for _ in range(N))
    for i in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add((b, i))
        g[b].add((a, i))

    dq = deque()
    dq.append([0, -1])
    color = [-1] * (N - 1)
    while dq:
        v, skip = dq.popleft()
        color_to_use = 1
        for u, i in g[v]:
            if ~color[i]: continue
            if color_to_use == skip:
                color_to_use += 1
            color[i] = color_to_use
            dq.append((u, color_to_use))
            color_to_use += 1

    print(max(color))
    print(*color, sep='\n')


if __name__ == '__main__':
    main()


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

#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'

using namespace std;

int32_t main()
{
    ios_base :: sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	map <int, int> m;
	int sum = 0;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp;
		sum += tmp;
		m[tmp]++;
	}
	int q;
	cin >> q;
	while (q--) {
		int a, b;
		cin >> a >> b;
		sum += m[a] * ( b - a );
		cout << sum << endl;
		m[b] += m[a];
		m[a] = 0;
	}
	return 0;
}



Measured memory_bytes: 9532
cat<<EOF>Source.cpp

extern "C"{
int printf (const char *__restrict __format, ...);
int scanf (const char *__restrict __format, ...) ;
}
int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	//~ #pragma omp parallel for num_threads(2)
	for(int i=0;i<k;i++){
		int d=max(n,k);
		int cnt[d];
		for(int j=0;j<d;j++)cnt[j]=0;
		for(int j=0;j<n;j++){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		for(int j=0;j<k;j++){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	for(int i=0;i<k;i++)Max=max(Max,ans[i]);
	printf("%d\n",Max);
}
EOF
clang++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 12756
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
tb=m
p=0
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

Measured memory_bytes: 47484
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string x,y;
    cin>>x>>y;
    int l=0,r=0;
    while(l<x.length() || r<y.length())
    {
        if(l<x.length())
            cout<<x[l++];
        if(r<y.length())
            cout<<y[r++];
    }
cout<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
int w[10],k[10],i,n,pre,wsum,ksum;
for(i=0;i<10;i++){
scanf("%d\n",&w[i]);
}
for(i=0;i<10;i++){
scanf("%d\n",&k[i]);
}
for(i=0;i<9;i++){//????´?????????????????????????
for(n=9;n>i;n--){//??\?????????????????????
if(w[n-1]>w[n]){
pre=w[n-1];
w[n-1]=w[n];
w[n]=pre;
}
}
}


for(i=0;i<9;i++){//????´?????????????????????????
for(n=9;n>i;n--){//??\?????????????????????
if(k[n-1]>k[n]){
pre=k[n-1];
k[n-1]=k[n];
k[n]=pre;
}
}
}

wsum = w[7]+w[8]+w[9];
ksum = k[7]+k[8]+k[9];
printf("%d %d\n",wsum,ksum);
 
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順


// Count the number of the same characters
int length(string& s, int i) {
    int first = i;
    int L = s.size();
    do {
        if (++i == L) return L - first;
    } while (s.at(first) == s.at(i));

    return i - first;
}

bool test(queue<int>& dx, int start, int target) {
    set<int> V2, V1;
    V1.insert(start);
    while (!dx.empty()) {
        int d = dx.front(); dx.pop();
        V2.clear();
        for (int cx : V1) {
            V2.emplace(cx + d);
            V2.emplace(cx - d);
        }
        V1 = V2;
    }
    return V1.count(target);
}

int main() {
    string s; cin >> s;
    int x,y; cin >> x >> y;
    
    bool isX = true;
    queue<int> dx, dy;
    int i = 0;
    while(true) {
        int L = length(s, i);
        if (s.at(i) == 'F') {
            if (isX) dx.push(L); else dy.push(L);
        } else {
            if (L % 2 == 1) {
                isX = !isX;
            }
        }
        i += L;
        if ((size_t)i >= s.size()) break;
    }

    int xs = 0;
    if (s.at(0) == 'F') xs = dx.front(), dx.pop();

    if (test(dx, xs, x) && test(dy, 0, y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 510, M = 1010;

int n, m, k;
int f[N][N];
int L[N][N], R[N][N];

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	while (m -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		L[l][r] ++ , R[r][l] ++ ;
	}
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
		{
			L[i][j] += L[i][j - 1];
			R[i][j] += R[i][j - 1];
		}
	
	for (int len = 1; len <= n; len ++ )
		for (int l = 1; l + len - 1 <= n; l ++ )
		{
			int r = l + len - 1;
			if (r > l + 1) f[l][r] += f[l + 1][r - 1];
			f[l][r] += L[l][r] - L[l][l - 1];
			f[l][r] += R[r][r] - R[r][l - 1];
			f[l][r] -= L[l][r] - L[l][r - 1];
		}
	
	while (k -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string s;
    int K;
    cin >> s >> K;
    int lens = s.length();
    int dist_a[lens];
    rep(i, lens){
        if(s[i] == 'a') dist_a[i] = 0;
        else dist_a[i] = 'z' - s[i] + 1;
    }
    rep(i, lens-1){
        if(K >= dist_a[i]){
            K -= dist_a[i];
            dist_a[i] = 0;
        }
    }
    char dist_alp[26];
    dist_alp[0] = 'a';
    char alp = 'z';
    for(int i = 1; i < 26; i++){
        dist_alp[i] = alp;
        alp--;
    }
    rep(i, lens-1){
        cout << dist_alp[dist_a[i]];
    }
    int rem = K % 26;
    dist_a[lens-1] -= rem;
    if(dist_a[lens-1] < 0) dist_a[lens-1] += 26;
    cout << dist_alp[dist_a[lens-1]] << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 896
H, W = [int(i) for i in input().split()]
A = [[a for a in input()] for _ in range(H)]

i = 0
while i < H:
    j = 0
    while j < W and A[i][j] == '.':
        j += 1
    if j >= W:
        for k in range(i, H - 1):
            for j in range(W):
                A[k][j] = A[k + 1][j]
        H -= 1
    else:
        i += 1
j = 0
while j < W:
    i = 0
    while i < H and A[i][j] == '.':
        i += 1
    if i >= H:
        for k in range(j, W - 1):
            for i in range(H):
                A[i][k] = A[i][k + 1]
        W -= 1
    else:
        j += 1
for i in range(H):
    for j in range(W):
        print(A[i][j], end='')
    print()


Measured memory_bytes: 9380
#include <stdio.h>

typedef long long ll;

ll YZ[10010];

int main(){

	int K,S;

	scanf("%d %d",&K,&S);

	int i,j;

	for(i=0;i<=K;i++){
		for(j=0;j<=K;j++){
			YZ[i+j]+=1ll;
		}
	}
	ll ans=0ll;
	for(i=0;i<=K;i++){
		if(S-i>=0){
		ans+=YZ[S-i];
		}
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int k, s;
	cin >> k >> s;
	int ans = 0;
	rep(i, k + 1) {
		rep(j, k + 1) {
			int num = 0;
			num = s - (i + j);
			if (num <= k && num >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n,a;
    long long s=0;
    cin>>h>>n;
    while(n--)
    {
        cin>>a;
        s+=a;
    }
    if(h>s)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    
    
    return 0;
}


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

s = [0 for i in range(m)]

for i in range(n):
    konomi = input().split()
    for j in range(len(konomi)-1):
        s[int(konomi[j+1])-1] += 1

sum = 0
for i in range(m):
    if(s[i]==n):
        sum += 1

print(sum)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) 
{
	unsigned int i;
	unsigned int x, y;
	int tmp;
	
	for(i = 0; i <= 10000; i++)
	{
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)
		{
			break;
		}
		if(x > y)
		{
			tmp = x;
			x = y;
			y = tmp;
			
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 600
#import<stdio.h>
#import<queue>
int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(i=0;i++<h;){for(j=0;j++<w;)f[j]=f[j-~h*22]=-1,f[x=i*22+j]=-2,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-1;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-2)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,~f[j=b-54+"L65676 "[p[i++]-50]]?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(~a?"%d %d %d\n":"impossible\n",t,a/22-1,a%22-1);}}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2));
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> S.at(i).at(j);
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (S.at(i).at(j) == '#') {
        bool b = 1;
        if (S.at(i - 1).at(j) == '#') b = 0;
        if (S.at(i + 1).at(j) == '#') b = 0;
        if (S.at(i).at(j - 1) == '#') b = 0;
        if (S.at(i).at(j + 1) == '#') b = 0;
        if (b) {
          cout << "No" << "\n";
          return 0;
        }
      }
    }
  }

  cout << "Yes" << "\n";
}

Measured memory_bytes: 256
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def solve(n, aaa):
    factorials, invs = prepare(n, MOD)
    fn = factorials[n]
    coefs = [fn * invs[i + 1] * factorials[i] % MOD for i in range(1, n)]
    acc = [0]
    for c in coefs:
        tmp = (acc[-1] + c) % MOD
        acc.append(tmp)

    ans = 0
    for i, a in enumerate(aaa):
        ans += (acc[i] + acc[n - i - 1] + fn) * a
        ans %= MOD
    return ans


MOD = 1000000007

n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


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

int main(){
	string s1;
	string s2;
	cin >> s1;
	cin >> s2;


	int l1 = s1.size();
	int l2 = s2.size();

	int dp[s1.size()+1][s2.size()+1];

	for(int i=0 ; i<=l1 ; i++){
		for(int j=0 ; j<=l2 ; j++){
			if(i==0 || j==0){
				dp[i][j] = 0;
			}
			else{
				if(s1[i-1] == s2[j-1]){
					dp[i][j] = dp[i-1][j-1] + 1;
				}
				else{
					dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				}
			}
			//cout << dp[i][j] << " ";
		}
		//cout << "\n";
	}

	int sx = l1;
	int sy = l2;
	string res = "";
	int ans = dp[sx][sy];
	while(ans > 0){
		if(s1[sx-1] == s2[sy-1]){
			res = res + s1[sx-1];
			sx--;
			sy--;
			ans--;
		}
		else{
			if(dp[sx-1][sy] > dp[sx][sy-1]){sx--;}
			else{sy--;}
		}
	}
	reverse(res.begin(), res.end());
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
using namespace std;
int a[1001];
int main()
{
    bool f;
    int n,q;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int b,e;
        cin>>b;cin>>e;
        reverse(&a[b],&a[e]);
    }
        f=false;
        for(int j=0;j<n;j++)
        {
            if(f==true)
                cout<<" "<<a[j];
            else
            {
                f=true;
                cout<<a[j];
            }
        }
        cout<<"\n";
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
using namespace std; 
#define X real()
#define Y imag()

const double EPS = 1e-10;

bool EQ(double a,double b){
  return fabs(a-b) < EPS;
}

typedef complex<double> Point;

namespace std {
  bool operator == (const Point &a, const Point &b) {
    return EQ(a.X, b.X) && EQ(a.Y, b.Y);
  }
  bool operator < (const Point &a, const Point &b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
struct Segment {
  Point p1, p2;
  Segment(){};
Segment(Point p1, Point p2) : p1(p1), p2(p2) {};
};

typedef Segment Line;
double dot(Point a, Point b){
  return a.X * b.X + a.Y * b.Y;
}
double cross(Point a, Point b){
  return a.real() * b.imag() - a.imag() * b.real();
}

Point project(Segment s, Point p) {
  double r = dot(p - s.p1, s.p2 - s.p1) / norm(s.p2 - s.p1);
  return s.p1 + (s.p2 - s.p1) * r;
}

Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}

bool isOrthogonal(Line l1, Line l2) {
  return EQ(dot(l1.p1 - l1.p2, l2.p1 - l2.p2), 0.0);
}
bool isParallel(Line l1, Line l2) {
  return EQ(cross(l1.p1 - l1.p2, l2.p1 - l2.p2), 0.0);
}

bool intersectLP(Line l, Point p) {
  return EQ(cross(l.p2 - p, l.p1 - p), 0.0);
}
bool intersectSP(Segment s, Point p) {
  return EQ(abs(s.p1 - p) + abs(p - s.p2), abs(s.p2 - s.p1));
}

const int COUNTER_CLOCKWISE = +1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = +2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;
int ccw(Point a, Point b, Point c) {
  Point x = b - a;
  Point y = c - a;
  if(cross(x, y) > EPS) return COUNTER_CLOCKWISE;
  if(cross(x, y) < -EPS) return CLOCKWISE;
  if(dot(x, y) < -EPS) return ONLINE_BACK;
  if(norm(x) < norm(y)) return ONLINE_FRONT;
  return ON_SEGMENT;
}

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

  Line x1,x2;
  for(int i=0;i<n;i++){
    cin >> x1.p1.X >> x1.p1.Y >> x1.p2.X >> x1.p2.Y;
    cin >> x2.p1.X >> x2.p1.Y >> x2.p2.X >> x2.p2.Y;
    
    if(isParallel(x1,x2)){
      printf("2\n");
    }else if(isOrthogonal(x1,x2)){
      printf("1\n");
    }else{
      printf("0\n");
    }


  }

  return 0;
}

Measured memory_bytes: 1184
x = input()
a,b,c,d = x.split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

ans = []
ans.append(a*c)
ans.append(a*d)
ans.append(b*c)
ans.append(b*d)

print(max(ans))


Measured memory_bytes: 9172
////////////////////////  : |)  W H I T E C L O U D : |)   ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    ll sum=0,n,i;
    cin>>n;
    ll arr[n+2];
    for(i=1; i<=n; i++)cin>>arr[i];
    for(i=2; i<=n; i++)
    {
        if(arr[i]<arr[i-1])
        {
            sum+=(arr[i-1]-arr[i]);
            arr[i]=arr[i-1];
        }
    }
    cout<<sum<<endl;


    return 0;
}







Measured memory_bytes: 5212
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
using ll = long long int;

int main(){
    int H,N;
    cin >> H >> N;
    vector<int> A(N,0);
    for(int i=0;i<N;i++) cin>>A[i];
    int total = accumulate(A.begin(),A.end(),0);
    if(total>=H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
from math import factorial
def comb(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))
S = sorted(S)
S.append('ZZZZZZZZZZ')
ans = 0
count = 1
for i in range(1,len(S)):
  if S[i] == S[i-1]:
    count += 1
  else:
    if count > 1:
      ans += comb(count, 2)
    count = 1
print(ans)


Measured memory_bytes: 66648
n, k, q = map(int, input().split())
point = [0] * (n+1)
for _ in range(q):
  a = int(input())
  point[a] += 1

for i in range(1, n+1):
  if k + point[i] > q:
    print('Yes')
  else:
    print('No')


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF 1e16

#define MAX_N 1000

ll n,m;
ll s[22],d[111];
ll dp[101][1<<16];
ll sum[1<<16];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,n)cin>>s[i];
    rep(i,m)cin>>d[i];
    sort(d,d+m);
    memset(sum,0,sizeof(sum));
    rep(S,1<<n){
      rep(i,n){
        if(((S>>i)&1)==1){
          sum[S]+=s[i];
        }
      }
    }
    rep(i,m)rep(S,1<<n){
      dp[i+1][S]=dp[i][S]+abs(d[i]-sum[S]);
      rep(j,n){
        if(((S>>j)&1)==0)continue;
        int S_=S^(1<<j);
        minch(dp[i+1][S],dp[i+1][S_]);
      }
    }
    cout<<dp[m][(1<<n)-1]<<endl;
  }
	return 0;
}

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

const int MAX_N = (int)(2 * 1e5 + 5);

int n, p[MAX_N];

int q[MAX_N];
int maxpartlen = 1;

int ans;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &(p[i]));

  for (int i = 0; i < n; ++i) {q[p[i] - 1] = i;}

  int cur = 1;
  for (int i = 1; i < n; ++i) {
    if (q[i] > q[i - 1]) cur += 1;
    else {cur = 1;}
    maxpartlen = max(maxpartlen, cur);
  }

  ans = n - maxpartlen;

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class ABC133_A
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int a = int.Parse(str[1]);
            int b = int.Parse(str[2]);
            if(n * a <= b)
            {
                Console.Write(n * a);
            }
            else
            {
                Console.Write(b);
            }
        }
    }
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long a2, b2, c2; //実際取る枚数
    if (k <= a) {
        a2 = k;
        b2 = 0;
        c2 = 0;
    }else if(k <= a+b){
        a2 = a;
        b2 = k - a;
        c2 = 0;
    }else {
        a2 = a;
        b2 = b;
        c2 = k - a - b;
    }
    cout << a2 - c2 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 10000000000

int n, m;
vector<vector<int>> g;
vector<int> dp(int(1e5 + 10), 1);
int longestPath(int x)
{
    if (dp[x] != 1)
        return dp[x];
    
    for (int s: g[x])
        dp[x] = max(1+longestPath(s), dp[x]);
    return dp[x];
}


int main()
{
    cin >> n >> m;
    g.assign(n, vector<int>());
    for (int i = 0; i < m; ++i)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
    }
    int ans = -3;
    for (int i = 0; i < n; ++i)
    {
        ans = max(longestPath(i) - 1, ans);
    }
    cout << ans << endl;
    
    return 0;
}

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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  Int ans=0;
  for(Int i=0;i<n;i++) ans+=s[i]-'0';
  for(Int i=0;i<n-1;i++){
    if(s[i]=='0') continue;
    string t=s;
    t[i]--;
    for(Int j=i+1;j<n;j++) t[j]='9';
    Int res=0;
    for(Int j=0;j<n;j++) res+=t[j]-'0';
    chmax(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
const long long oo=1e18;
const int N=200000+10;
long long sum[N];
int main(){
	// freopen("in.txt","r",stdin);
	int n;read(n);
	for(int i=1;i<=n;++i){
		int x;read(x);
		sum[i]=sum[i-1]+x;
	}
	long long ans=oo;
	int l=1,r=3;
	for(int i=2;i<n;++i){
		long long mn=oo;
		for(;l<i;++l){
			if(!chkmin(mn,abs(sum[i]-2*sum[l])))
				break;
		}
		--l;
		chkmax(r,i+1);
		mn=oo;
		for(;r<=n;++r){
			if(!chkmin(mn,abs(sum[n]-2*sum[r]+sum[i])))
				break;
		}
		--r;
		long long mx=0;mn=oo;
		chkmax(mx,sum[l]);chkmax(mx,sum[i]-sum[l]);chkmax(mx,sum[r]-sum[i]);chkmax(mx,sum[n]-sum[r]);
		chkmin(mn,sum[l]);chkmin(mn,sum[i]-sum[l]);chkmin(mn,sum[r]-sum[i]);chkmin(mn,sum[n]-sum[r]);
		chkmin(ans,mx-mn);
	}
	write(ans),putchar('\n');
	return 0;
}

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

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

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

int main()
{
    int N;
    cin >> N;
    ll res = 1;
    for(int i = 0; i < N; ++i) {
        ll a; cin >> a;
        res = lcm(res, a);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n,x,m = readInts()
lis = []
prv = None
dic = defaultdict(int)
for i in range(m):
    if i == 0:
        A = x%m
        lis.append(A)
        dic[A] = 1
    else:
        A = (A*A)%m
        if dic[A]:
            prv = A
            break
        else:
            dic[A] = 1
        lis.append(A)
cnt = None
for i in range(len(lis)):
    if lis[i] == prv:
        cnt = i
        break
if cnt == None:
    cnt = len(lis)
front_arr = lis[:cnt]
loop_arr = lis[cnt:]
if x == 0:
    print(0)
    exit()
len_loop_arr = len(loop_arr)
if n < cnt:
    ans = sum(front_arr[:n])
else:
    ans = sum(front_arr)
    sum_loop_arr = sum(loop_arr)
    n -= cnt

    loop = n//len_loop_arr
    rest = n - (loop*len_loop_arr)
    mid = loop * sum_loop_arr
    ans += mid
    ans += sum(loop_arr[:rest])
print(ans)


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

const int MAXN = 55;
int n, x[MAXN], y[MAXN];
map<pair<int, int> , int> mp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++) {
		vector<pair<int, int> > tmp;
		for (int j = 0; j < n; j++)
			tmp.push_back({ x[i] - x[j], y[i] - y[j] });
		sort(tmp.begin(), tmp.end());
		tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
		for (int i = 0; i < tmp.size(); i++)
			if (!(tmp[i].first == 0 && tmp[i].second == 0))
				mp[tmp[i]]++;
	}
	int ans = 0;
	for (map<pair<int, int>, int>::iterator it = mp.begin(); it != mp.end(); it++)
		ans = max(ans, (*it).second);
	cout << n - ans;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        var S = ReadLine();

        var m = S[0];
        var max = 1;
        var c = S[0] == '0' ? 1 : 0;
        var s = 0;
        for (int i = 1; i < N; i++)
        {
            if (m == '0')
            {
                if (S[i] == '0')
                {

                }
                else
                {

                }
            }
            else
            {
                if (S[i] == '0')
                {
                    c++;
                    if (c > K)
                    {
                        if (S[s] == '1')
                        {
                            while (S[s]=='1')
                            {
                                s++;
                            }
                        }
                        while (S[s]=='0')
                        {
                            s++;
                        }
                        if (s > i) i = s;
                        c--;
                    }
                    

                }
                else
                {
                    


                }
            }
            if (c <= K) max = Math.Max(max, i - s + 1);
            m = S[i];
        }
        WriteLine(max);

    }
}


Measured memory_bytes: 13536