akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
#include <cassert>
using namespace std;

#define maxn 60
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
const ll MOD = 1000000007;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll f[maxn][5][5];
string s1, s2;

ll dp(int i, int x, int y) {
    if (i==n) return 1;
    if (f[i][x][y]>-1) return f[i][x][y];
    f[i][x][y] = 0;
    if (s1[i]==s2[i]) {
        FOR(j, 0, 2) {
            if (x!=j && y!=j) f[i][x][y] += dp(i+1, j, j);
        }
    }
    else {
        FOR(p, 0, 2) FOR(q, 0, 2) {
            if (p!=q && p!=x && q!=y) f[i][x][y] += dp(i+2, p, q);
        }
    }
    return f[i][x][y]%=MOD;
}

int main() {
    //freopen("cdominoes.inp", "r", stdin);
    //freopen("", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> s1 >> s2;
    memset(f, -1, sizeof(f));
    cout << dp(0, 3, 3);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	char x,y;
	cin>>x>>y;
	int a,b;
	a=x;
	b=y;
	if(a<b){
		cout<<"<";
	}
	if(a>b){
		cout<<">";
	}
	if(a==b){
		cout<<"=";
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    string s, t; cin >> s >> t;
    ll ans = 1;
    
    int bef = -1, now = 1;
    rep(i, n){
        // pr(ans);
        if(s[i]==t[i]) now = 1;
        else now = 2;

        if(bef<0) {
            if(now==2) {ans *= 6; i++;}
            else ans *= 3;
        }else if(bef==2 && now==2){
            ans *= 3;
            i++;
        }else if(bef==2 && now==1){
            ans *= 1;
        }else if(bef==1 && now==1){
            ans *= 2;
        }else if(bef==1 && now==2){
            ans *= 2;
            i++;
        }
        ans %= MOD;
        bef = now;
    }

    pr(ans);
    return 0;}

Measured memory_bytes: 3600
n = STDIN.gets.to_i
vs = STDIN.gets.strip.split(" ").map(&:to_i)

def count(a)
  cnt = {}
  a.each { |v| cnt[v] ||= 0; cnt[v] += 1 }
  cnt.sort_by { |v, cnt| cnt }.reverse
end

def reverse?(a, b, n)
  return true if a[0][1] < b[0][1]
  return false unless a[0][1] == b[0][1]
  aa = a[1] ? a[1][1] : (n/2 - a[0][1])
  bb = b[1] ? b[1][1] : (n/2 - b[0][1])
  return true if aa > bb
  false
end

a = []
b = []
vs.each_with_index do |v, i|
  if i % 2 == 0
    a << v
  else
    b << v
  end
end

ca = count(a)
cb = count(b)
ans = 0
aa = [
  ca,
  cb
]
if reverse?(aa[0], aa[1], n)
  aa = aa.reverse
end

used = {}
aa.each do |c|
  no_ans = true

  c.each do |v, cnt|
    next if used[v]
    used[v] = true
    ans += n/2 - cnt
    no_ans = false
    break
  end

  if no_ans
    ans += n / 2
  end
end
puts ans

Measured memory_bytes: 22008
let rec grading g =
  let s = Scanf.scanf "%d %d %d\n" (fun x y z->(x,y,z)) in
  let grade x = match x with
    (-1,-1,-1) -> g
  | (-1,_,_) | (_,-1,_) -> grading (g^"F\n")
  | (m,f,r) when m+f >= 80 -> grading (g^"A\n")
  | (m,f,r) when m+f >= 65 -> grading (g^"B\n")
  | (m,f,r) when m+f >= 50 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 && r >= 50 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 -> grading (g^"D\n")
  | (m,f,r) when m+f < 30 -> grading (g^"F\n")
  | _ -> ""
  in grade s;;

let () = grading "" |> print_string;;

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

#define INF 1e9

int main(void){
  int v, e;
  cin >> v >> e;

  int s, t;
  vector< vector<int> >edge(v, vector<int>(v, INF));
  for(int i=0; i<e; i++){
    cin >> s >> t;
    cin >> edge[s][t];
  }
  
  vector< vector<int> >dp((1 << v), vector<int>(v, INF));
  dp[0][0] = 0;

  int cost;
  for(int i=0; i<(1<<v); i++)
    for(int j=0; j<v; j++)
      for(int k=0; k<v; k++){
	if((i&(1<<k)) != 0)
	  continue;
	cost = dp[i][j] + edge[j][k];
	if(cost < dp[i|(1<<k)][k])
	  dp[i|(1<<k)][k] = cost;
      }
  
  if(dp[(1<<v)-1][0] == INF)
    cout << -1 << endl;
  else
    cout << dp[(1<<v)-1][0] << endl;
  
  return 0;
}

Measured memory_bytes: 6192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) abs((a)-(b))<EPS
using namespace std;
typedef double D;
const D EPS = 1e-8;

int n,b;
D d,p[11],h[11];

bool check(D H, D W){
  D a = -4*H/W/W;
  rep(i,n){
    D x = p[i];
    while(x+EPS>W)x -= W;
    if(EQ(x,0))return false;
    if(a*(x-W/2)*(x-W/2)+H +EPS < h[i])return false;
  }
  return true;
}

int main(){
  cin >> d >> n >> b;
  rep(i,n)cin >> p[i] >> h[i];

  D res = 1e12;
  rep(i,b+1){
    D w = d/(i+1);
    D l = w/4, r = 1e12;
    rep(azu,99){
      D mid = (l+r)/2;
      if(check(mid,w))r = mid;
      else l = mid;
    }
    D vy = sqrt(2*l), vx = w/2/vy;
    res = min(res, sqrt(vy*vy + vx*vx));
  }
  cout << fixed << setprecision(5) << res << endl;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M);
  
  for (int i = 0; i < M; i++){
    cin >> k[i];
    for (int j = 0; j < k[i]; j++){
      int swi; cin >> swi;
      swi--;
      s[i].push_back(swi);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  
  int count = 0;
  for (int bit = 0; bit < (1 << N); bit++){
    bool bitlight = true;
    for (int i = 0; i < M; i++){
      int eachcount = 0;
      for (int j = 0; j < (int)s[i].size(); j++){
        if (bit & (1 << s[i][j])) eachcount++;
      }
      if (eachcount % 2 != p[i]) bitlight = false;
      if (!bitlight) break;
    }
    if (bitlight) count++;
  }
  
  cout << count << endl;
}
      
      
      
    
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N;

int main(){
	cin >> N;
	ll res = 0LL;
	int cnt = 0;
	ll min_abs = 1LL << 60;
	for(int i = 0; i < N; i++){
		ll A;
		cin >> A;
		res += abs(A);
		min_abs = min(min_abs, abs(A));
		if(A < 0LL) cnt++;
	}
	if(cnt % 2 == 0) cout << res << endl;
	else cout << res - 2 * min_abs << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    while (true) {
        int n,w;
        cin >> n >>w;
        if (n == 0) break;
        vector<int> hist(1000,0);
        for (int i=0; i<n; i++) {
            int p;
            cin >> p;
            p/=w;
            hist[p]++;
        }
        int num=0,t=0;
        
        rep(i, 1000){
            num = max(num,hist[i]);
            if(hist[i]!=0)t=i;
        }
        double ans=0.01;
        if(t==0 or num == 0){
            cout << 0.01 << endl;
            continue;
        }
        rep(i, 1000){
            ans += ((double)hist[i]/num)*(1-(double)i/t);
        }
        printf("%.6lf\n",ans);
    }
}

Measured memory_bytes: 1220
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	class point{
		public int x;
		public int y;
		point(int x,int y){
			this.x = x;
			this.y = y;
		}
		point rot(int seed){
			if(seed == 0){
				return new point(this.x,this.y);
			}else if(seed == 1){
				return new point(-this.x,-this.y);				
			}else if(seed == 2){
				return new point(this.y,-this.x);				
			}else{// if(seed == 3){
				return new point(-this.y,this.x);								
			}
		}
		point org(point target){
			point ret = new point(this.x - target.x,this.y - target.y);
			return ret;
		}
		public boolean equ(point target){
			return this.x == target.x && this.y == target.y ;
		}
	}
	class polyline{
		public int m = 0;
		public point[] p;
		polyline(){}
		polyline(int m,Scanner sc){
			this.m  =m;
			p = new point[m];
			point org = new point(sc.nextInt(),sc.nextInt());
			p[0] = org.org(org);
			for(int i = 1; i < m; i++){
				p[i] = new point(sc.nextInt(),sc.nextInt());
				p[i] = p[i].org(org);
			}
		}
		polyline[] generate8(){
			polyline ret[] = new polyline[8];
			for(int i =0 ; i < 4; i ++){
				point[] a = new point[m];
				point org = p[0];
				for(int j = 0; j < m;j++){
					a[j] = p[j].org(org).rot(i);	
				}
				ret[i] = new polyline();
				ret[i].m = m;
				ret[i].p = a;
			}
			for(int i =0 ; i < 4; i ++){
				point[] a = new point[m];
				point org = p[m-1];
				for(int j = 0; j < m;j++){
					a[j] = p[m-j-1].org(org).rot(i);
				}
				ret[i+4] = new polyline();
				ret[i+4].m = m;
				ret[i+4].p = a;
			}
			return ret;
		}
		boolean equ(polyline target){
			if(this.m != target.m){
				return false;
			}
			for(int i =0;i < m;i++){
				if(!this.p[i].equ(target.p[i])){
					return false;
				}
			}
			return true;
		}
		void print(){
			System.out.println(this.m);
			for(int i = 0;i < m; i++){
				System.out.println(this.p[i].x + " " + this.p[i].y);
			}
			System.out.println();
		}
	}
	void run(){
		for(;;){
			int n = sc.nextInt();
			if(n == 0) break;
			polyline base1 =new polyline(sc.nextInt(),sc);
			polyline[] base = base1.generate8();
			/*
			for(int i = 0; i < 8 ; i++){
				System.out.println("base "+i);
				base[i].print();
			}
			*/
			for(int i = 0; i < n; i++){
				polyline lines = new polyline(sc.nextInt(),sc);
			/*
				System.out.println("lines "+(i+1));
				lines.print();
				System.out.println("------ ");
			*/	
				for(int j = 0; j < 8; j++){
					if(lines.equ(base[j])){
						System.out.println(i+1);
						continue;
					}
				}
			}
			System.out.println("+++++");
		}
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

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

    int ans = (n * (n - 1) + m * (m - 1)) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ESequenceSum {
public:

    ll f(ll a, ll m) {
      return (a*a)%m;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, x, m; cin >> n >> x >> m;

      vector<vector<ll>> next(40, vector<ll>(m));
      vector<vector<ll>> dp(40, vector<ll>(m));
      rep(i, m) {
        dp[0][i] = i;
        next[0][i] = f(i, m);
      }

      for(int k=1; k<40; k++) {
        rep(i, m) {
          next[k][i] = next[k-1][next[k-1][i]];
          dp[k][i] = dp[k-1][i] + dp[k-1][next[k-1][i]];
        }
      }

      ll now = x;
      ll ret = 0;
      for(int k=0; k<40; k++) {
        if (n&(1LL<<k)) {
          ret += dp[k][now];
          now = next[k][now];
        }
      }

      cout << ret << endl;


    }
};

signed main() {
  ESequenceSum solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 66660
#include "bits/stdc++.h"

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int> l(N);
    for (auto &elem : l) {
        cin >> elem;
    }

    sort(l.begin(), l.end());

    int64_t res = 0;
    for (int mid = 0; mid < N; ++mid) {
        for (int low = mid - 1; low >= 0; --low) {
            auto it = lower_bound(l.begin(), l.end(), l[mid] + l[low]);
            size_t ng = distance(it, l.end());
            res += (N - 1 - mid) - ng;
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
ACGT = []
others = 'BDEFHIJKLMNOPQRSUVWXYZ'
for i in range(N):
    fl = True
    for j in range(i+1,N+1):
        tmp_S = S[i:j]
        M = len(tmp_S)
        for k in range(M):
            if tmp_S[k] in others:
                fl = False
        if fl==False:
            break
        ACGT.append(tmp_S)
len_ACGT = [len(x) for x in ACGT]
print(max(len_ACGT)) if len(len_ACGT)>0 else print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int N=2001;
int deep[N],n,k,head[N],cnt;
struct node{
	int u,v,nex;
}x[N<<1];
void add(int u,int v){
	x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
}
int ans,minn;
void dfs(int f,int fath){
	deep[f]=deep[fath]+1;
	if(deep[f]>(k/2)) ans++;
	for(int i=head[f];i!=-1;i=x[i].nex){
		if(x[i].v==fath) continue;
		dfs(x[i].v,f);
	}return;
}
int main(){
	memset(head,-1,sizeof(head));
	n=read(),k=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		add(u,v),add(v,u);
	}
	if(k&1){
		ans=0,minn=INT_MAX;
		for(int u=1;u<=n;u++){
			for(int i=head[u];i!=-1;i=x[i].nex){
				ans=0;
				int v=x[i].v;
				deep[v]=-1;
				dfs(u,v);
				deep[u]=-1;
				dfs(v,u);
				minn=min(minn,ans);
			}
		}
	}else{
		ans=0,minn=INT_MAX;
		for(int u=1;u<=n;u++){
			ans=0;
			deep[0]=-1;
			dfs(u,0);
			minn=min(minn,ans);
		}
	}printf("%d\n",minn);
}


Measured memory_bytes: 384
#include<stdio.h>

/*??°?????????*/
void swap(int *x, int *y) {
	int temp = *x;
	*x = *y;
	*y = temp;
}

int main(void) {
	int N, a[100], i, j, k=0;
	/*printf("??´??°?????\????????????????????????");*/
	scanf("%d", &N);
	/*printf("%d??????????´??????\????????????????????????",N);*/
	for (i = 0; i < N; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				swap(&a[j], &a[j - 1]);
				k++;
			}
		}
	}
	for (i = 0; i < N; i++)
		printf("%d%s", a[i], i < N-1 ? " " : "\n");
	printf("%d\n", k);
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int p[N]; 
    for(int i=0;i<N;i++) cin >> p[i];
    int cnt = 0;
    for(int i=1;i<=N;i++){
        if(p[i-1] != i) cnt++;
    }
    if(cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main (String[] args) throws IOException {
		BufferedReader tec=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		for(String line;(line=tec.readLine())!=null;){
			StringTokenizer st=new StringTokenizer(line);
			int n=Integer.parseInt(st.nextToken());
			int m=Integer.parseInt(st.nextToken());
			int[]arr=new int[n];
			Arrays.fill(arr, 1);
			int cont=1;
			boolean []pos=new boolean[n];
			pos[0]=true;
			for (int i = 0; i < m; i++) {
				st=new StringTokenizer(tec.readLine());
				int a=Integer.parseInt(st.nextToken())-1;
				int b=Integer.parseInt(st.nextToken())-1;
				arr[a]--;
				arr[b]++;
				if(pos[a]){
					if(!pos[b])
						cont++;
					pos[b]=true;					
				}
				if(arr[a]==0){
					if(pos[a])
						cont--;
					pos[a]=false;					
				}				
			}
			out.println(cont);
		}
		out.close();
	}
}

Measured memory_bytes: 40272
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	int N;
	int[] a;
	
	public int gcd(int x,int y){
		return y == 0 ? x : gcd(y,x%y);
	}
	
	public int lcm(int x,int y){
		return x * y / gcd(x,y);
	}
	
    public void solve() {
		N = nextInt();
		a = new int[N];
		int sum = 1;
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			sum = lcm(sum,a[i]);
		}
		out.println(sum);
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 24396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, a;
    cin >> N;
    map<int, int> m;
    int over = 0;
    rep(i, N)
    {
        cin >> a;
        if (a >= 3200)
        {
            over++;
        }
        else
        {
            m[a / 400]++;
        }
    }
    cout << max((int)m.size(), 1) << " " << m.size() + over;
    return 0;
}

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

vector<long> ans;

void dfs(long n, int d) {
  ans.push_back(n);
  if (d == 10) return;
  int end = n % 10;
  int mi = max(0, end - 1);
  int mx = min(9, end + 1);
  for (int i = mi; i <= mx; i++) dfs(n * 10 + i, d + 1);
}

int main() {
  int K;
  cin >> K;
  for (int i = 1; i <= 9; i++) dfs(i, 1);
  sort(ans.begin(), ans.end());
  cout << ans.at(K - 1) << "\n";
}

Measured memory_bytes: 2420
s=list(input())
ans=[]
for i in range(1<<(len(s)-1)):
    tmp=0
    num=s[0]
    for j in range(len(s)-1):
        if (i>>j)%2==0:
            num+=s[j+1]
        else:
            tmp+=int(num)
            num=s[j+1]
        #print(num)
    tmp+=int(num)
    ans.append(tmp)
print(sum(ans))

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

const char *ptr;
vector<int> var[5], U;

vector<int> parse();

vector<int> factor(){
	if(*ptr == '('){
		++ptr;
		vector<int> x = parse();
		++ptr;
		return x;
	}
	if(*ptr == 'c'){
		++ptr;
		vector<int> x = factor();
		vector<int> y;
		set_difference(U.begin(), U.end(), x.begin(), x.end(), back_inserter(y));
		return y;
	}
	return var[*ptr++ - 'A'];
}

vector<int> parse(){
	vector<int> tmp, y, x = factor();
	back_insert_iterator<vector<int> > it(tmp);

	while(1){
		tmp.clear();
		if(*ptr == 'u'){
			++ptr;
			y = factor();
			set_union(x.begin(), x.end(), y.begin(), y.end(), it);
		}
		else if(*ptr == 'i'){
			++ptr;
			y = factor();
			set_intersection(x.begin(), x.end(), y.begin(), y.end(), it);
		}
		else if(*ptr == 'd'){
			++ptr;
			y = factor();
			set_difference(x.begin(), x.end(), y.begin(), y.end(), it);
		}
		else if(*ptr == 's'){
			++ptr;
			y = factor();
			set_symmetric_difference(x.begin(), x.end(), y.begin(), y.end(), it);
		}
		else{
			break;
		}

		x.swap(tmp);
	}
	
	return x;
}

int main(){
	string s;
	char ch;
	int n;

	while(1){
		for(int i = 0; i < 5; ++i){
			var[i].clear();
		}

		while(1){
			cin >> ch >> n;
			if(!cin) return 0;
			if(ch == 'R') break;
			var[ch - 'A'].resize(n);
			for(int i = 0; i < n; ++i){
				cin >> var[ch - 'A'][i];
			}
		}

		U.clear();
		for(int i = 0; i < 5; ++i){
			sort(var[i].begin(), var[i].end());
			var[i].erase(unique(var[i].begin(), var[i].end()), var[i].end());
			U.insert(U.end(), var[i].begin(), var[i].end());
		}
		sort(U.begin(), U.end());
		U.erase(unique(U.begin(), U.end()), U.end());

		cin >> s;
		ptr = s.c_str();

		vector<int> ret = parse();
		if(ret.empty()){
			puts("NULL");
		}
		else{
			printf("%d", ret[0]);
			for(int i = 1; i < ret.size(); ++i){
				printf(" %d", ret[i]);
			}
			puts("");
		}
	}
}

Measured memory_bytes: 1232
n = int(input())
color = list(input())
left = 0
right = len(color) - 1
ans = 0
while left<right:
    if(color[left]=='W' and color[right]=='R'):
        ans += 1
        left += 1
        right -=1
    if color[left] == 'R':
        left+=1
    if color[right] == 'W':
        right -=1
print(ans)



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

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

  int ans = 0;
  for (int i = 0; i < N; i += 2) {
    if (a[i] % 2 == 1) {
      ++ans;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/
vector<int> arr[1009];
map<pair<int,int>,int> m;
struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;
vector<vector<int>> vec;

int main(){
    string s,t;

    vec.assign(26,vi());
    cin >> s >> t;

    ll idx = 0;
    for(auto let : s){
        vec[let - 'a'].pb(idx++);
    }


    idx = -1;
    ll cc = 0;
    for(auto let : t){
        int pos = let - 'a';
        if(sz(vec[pos]) == 0){
            return cout << -1,0;
        }
        auto it = upper_bound(all(vec[pos]),idx);
        if(it == vec[pos].end()){
            idx = vec[pos][0];
            cc+= s.length();
        }else{
            idx = *it ;
        }
    }
    cout << cc + idx + 1;


}















Measured memory_bytes: 1216
x = input()

str_list = list(x)
dict_ = {
    "D":"A",
"E":"B",
"F":"C",
"G":"D",
"H":"E",
"I":"F",
"J":"G",
"K":"H",
"L":"I",
"M":"J",
"N":"K",
"O":"L",
"P":"M",
"Q":"N",
"R":"O",
"S":"P",
"T":"Q",
"U":"R",
"V":"S",
"W":"T",
"X":"U",
"Y":"V",
"Z":"W",
"A":"X",
"B":"Y",
"C":"Z"
    }

for a in str_list:
    print(dict_.get(a) , end = "")
print()


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel A(N); rep(i,N) cin >> A[i];

    if(N % 2 == 0) {
        ll ans1 = 0LL;
        sort(rall(A));
        rep(i,N/2) {
            if(i == N/2 - 1) ans1 += A[i];
            else ans1 += 2 * A[i];
        }
        sort(all(A));
        rep(i,N/2) {
            if(i == N/2 - 1) ans1 -= A[i]; 
            else ans1 -= 2 * A[i];
        }
        cout << ans1 << endl;
        return 0;
    }
    else {
        ll ans1 = 0LL;
        sort(rall(A));
        rep(i,N/2) ans1 += 2 * A[i];
        sort(all(A));
        rep(i,(N+1)/2) {
            if(i == (N+1)/2 -1 or i == (N+1)/2 - 2 ) ans1 -= A[i]; 
            else ans1 -= 2 * A[i];
        }

        ll ans2 = 0LL;
        sort(rall(A));
        rep(i,(N+1)/2) {
            if(i == (N+1)/2 - 1 or i == (N+1)/2 - 2) ans2 += A[i];
            else ans2 += 2 * A[i]; 
        }
        sort(all(A));
        rep(i,N/2) {
            ans2 -= 2 * A[i];
        }
        cout << max(ans1, ans2) << endl;
        return 0;
    }
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstring>
using namespace std;
char s[100005];
int n;
signed main(){
	cin>>(s+1);
	n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1') return cout<<-1,0;
	for(int i=1;i<n;++i)if(s[i]^s[n-i]) return cout<<-1,0;
	int now=1;
	for(int i=2;i<=n;++i){
		cout<<now<<" "<<i<<endl;
		if(s[i-1]=='1')now=i;
	}
	return 0;
} 

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}
vl fact(200001,1),inv(200001,1);
ll comb(ll n, ll k) {
    if (k < 0 || n < 0 || k > n)
        return 0;
    if (k == 0 || k == n)
        return 1;
    ll res = (fact[n] * inv[k]) % mod;
    res = (res * inv[n - k]) % mod;
    return res;
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++) {
        fact[i]=(fact[i-1]*i)%mod;
        inv[i] = power(fact[i],mod-2,mod);
    }
    ll ans=0;
    for(ll i=0;i<=min(n-1,m);i++) {
        ll res = comb(n,i);
        res*=comb(n-1,i);
        res%=mod;
        ans=(ans+res)%mod;
    }
    cout<<ans;

}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<int> g[n + 1];
    int h[n + 1];
    memset(h, 0, sizeof(h));
    int a, b;
    for (int i = 0; i < n - 1 + m; ++i) {
        cin >> a >> b;
        g[a].push_back(b);
        h[b]++;
    }

    queue<int> que;
    for (int i = 1; i < n; ++i) {
        if (h[i] == 0) {
            que.push(i);
        }
    }

    int parents[n + 1];
    memset(parents, 0, sizeof(parents));
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        for (auto c: g[p]) {
            h[c]--;
            if(h[c] == 0) {
                que.push(c);
                parents[c] = p;
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        cout << parents[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n%10==3) printf("bon\n");
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
    printf("pon\n");
    else printf("hon\n");
}

Measured memory_bytes: 1664
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int lsb(long long in){
	int ret=0;
	while(in){
		ret++;
		in>>=1;
	}
	return ret;
}

int main(){
	long long A,B;
	cin>>A>>B;

	if(A==B){
		cout<<1<<endl;
		return 0;
	}

	while(lsb(A)==lsb(B)){
		long long t=1LL<<(lsb(A)-1);
		A-=t;
		B-=t;
	}

	int lsbnow=lsb(B)-1;

	long long ans=0;

	long long t1 = (1LL<<lsbnow)-A;
	long long t2 = (1LL<<lsb(B-(1LL<<lsbnow)));

	if(t1+t2>1LL<<lsbnow){
		ans = (1LL<<lsbnow) + t1;
	}else{
		ans = t1+t1+t2;
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





void solve() {
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int cnt = 0;
    rep(i, n) if (a[i] < 0) cnt++;
    
    ll sum = 0;
    rep(i, n) a[i] = abs(a[i]);
    sort(all(a));
    
    rep(i, n) sum += a[i];
    // out(sum);
    if (cnt % 2 != 0) sum -= 2 * a[0];
    // out(cnt);
    // outa(a, n);
    out(sum);
}


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



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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000
void solve() {
	string s; cin >> s ;
	ll q; cin>> q;
	bool f = 0 ;
	while(q--) {
		ll t; cin >> t ;
		if(t==1) f=(f+1)%2;
		else {
			string c; cin >> t >> c; 
			if(t==1) {
				if(f==0) s.insert(0,c);
				else s+=c;
			}
			else {
				if(f==0) s+=c;
				else s.insert(0,c);
			}
		}
	}
	if(f==0) cout << s ;
	else {
		for(auto i =s.rbegin();i!=s.rend();++i) cout << *i ;
	}
}

int main() {

    fast;
	ll t=1;
	// cin>>t;
	rep(t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007



void solve(void)
{

  int N;
  cin>>N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int ANS = INF;
  for (int A = -100; A <= 100; A++)
  {
    int cost = 0;
    for (int i = 0; i < N; i++)
    {
      cost += (vec[i] - A)*(vec[i] - A);
    }
    ANS = min(ANS,cost);
  }

  cout<<ANS<<endl;
  
  
  
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

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

int main(){
  int m,n,a,b;
  int result[51]={0};
  
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    if(a!=b){
      result[a]++;
      result[b]++;
    }
  }

  for(int i = 1; i <= n; i++){
    cout << result[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    int w, h, n;
    int x, y, a;
    int l, r, u, d;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	if(l < r && d < u) out((r - l) * (u - d));
	else out(0);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	w = r = sc.nextInt();
	h = u = sc.nextInt();
	n = sc.nextInt();
	l = d = 0;
	
	for(int i = 0; i < n; i++) {
	    x = sc.nextInt();
	    y = sc.nextInt();
	    a = sc.nextInt();

	    if(a == 1 && l < x) l = x;
	    if(a == 2 && x < r) r = x;
	    if(a == 3 && d < y) d = y;
	    if(a == 4 && y < u) u = y;
	}
    }
    
    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


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

void solver(){
	//type your code here
	ll n , m ;
	cin >> n >> m;
	vector<pair<ll,ll>> v(n);
	for(auto &i:v){
		cin >> i.first >> i.second;
	}
	sort(v.begin() , v.end());
	ll cost = 0;
	for(int i = 0 ; i < n ; ++i){
		ll choosen = min(v[i].second,m);
		m -= choosen;
		cost += choosen * v[i].first;
	}
	cout << cost << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int queries = 1;
	//(cin >> queries);
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
int main(){
	int H,W;
	while(true){
		std::cin >> H >>W;
		if(H == 0&&W == 0)break;
		for(int a = 0;a < H;a++){
			for(int b = 0;b < W;b++){
				if(a == 0||a == H - 1||b == 0||b == W - 1){
					std::cout << "#";
				}else{
					std::cout << ".";
				}
			}
			std::cout << std::endl;
		}
		std::cout <<std::endl;
	}
}

Measured memory_bytes: 2996
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

int a[100100];
int w[100100];
int na[100100];
int n, l, t;
vector<LL> ti[2];

int model(int p, int t) {
	ti[0].clear();
	ti[1].clear();
	FOR(i, 0, n) {
		if (i == p) {
			continue;
		}
		if (w[i] == 1) {
			LL dist = a[p] - a[i];
			if (dist < 0) {
				dist += l;
			}
			ti[0].push_back(dist);
		}
		else {
			LL dist = a[i] - a[p];
			if (dist < 0) {
				dist += l;
			}
			ti[1].push_back(dist);
		}
	}
	sort(ti[0].begin(), ti[0].end());
	sort(ti[1].begin(), ti[1].end());
	int dir = w[p] - 1;
	int x = 0;
	int y = 0;
	LL dist[2] = { 0, 0 };
	int pos[2] = {0, 0};
	while (1) {
		dir ^= 1;
		if (ti[dir].size() == 0) {
			break;
		}
		if (ti[dir][pos[dir]] + dist[dir ^ 1] > t + t) {
			break;
		}
		dist[dir] = ti[dir][pos[dir]];
		ti[dir ^ 1].push_back(dist[dir ^ 1] + l);
		pos[dir]++;
	}
	dir ^= 1;
	LL res = a[p];
	if (dir == 0) {
		res += t;
		res %= l;
		res -= dist[0];
		while (res < 0) {
			res += l;
		}
	}
	else {
		res += dist[1];
		res %= l;
		res -= t;
		while (res < 0) {
			res += l;
		}
	}
	return res;
}

int goClockWise(int p, int t) {
	return (p + t) % l;
}

int goCounterClockWise(int p, int t) {
	t %= l;
	p -= t;
	if (p < 0) {
		p += l;
	}
	return p;
}
int at[100100];

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	scanf("%d%d%d", &n, &l, &t);
	FOR(i, 0, n) {
		scanf("%d%d", &a[i], &w[i]);
	}
	if (n == 1) {
		if (w[0] == 1) {
			cout << goClockWise(a[0], t) << endl;
		}
		else {
			cout << goCounterClockWise(a[0], t) << endl;
		}
		return 0;
	}
	int v1 = model(0, l);
	int v2 = model(1, l);
	int shift = -1;
	FOR(i, 0, n) {
		int ne = i + 1;
		if (ne == n) {
			ne = 0;
		}
		if ((v1 == a[i]) && (v2 == a[ne])) {
			shift = i;
			break;
		}
	}
	
	LL temp = shift;
	temp *= (t / l);
	shift = temp % n;
	FOR(i, 0, n) {
		if (w[i] == 1) {
			at[i] = goClockWise(a[i], t % l);
		}
		else {
			at[i] = goCounterClockWise(a[i], t % l);
		}
	}
	sort(at, at + n);
	v1 = model(shift, t % l);
	v2 = model((shift + 1) % n, t % l);
	shift = -1;
	FOR(i, 0, n) {
		int ne = i + 1;
		if (ne == n) {
			ne = 0;
		}
		if ((v1 == at[i]) && (v2 == at[ne])) {
			shift = i;
			break;
		}
	}
	if (shift == -1) {
		throw;
	}
	FOR(i, 0, n) {
		printf("%d\n", at[shift]);
		shift++;
		if (shift == n) {
			shift = 0;
		}
	}
	
#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000000000000000
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define pii pair<ll, pair<ll, char>>
const ll mod = 1000000007;
//ll n;
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
}
ll solve() {
	ll n;
	cin>>n;
	ll ans = 0;
	generatePrimeFactors(); 
	for(int i = 1; i <= n-1; i++) {
		ans += calculateNoOFactors(n-i);
	}
	return ans;
}
int main() {
	io
	ll t = 1;
	//cin>>t;
	while(t--) {
		cout<<solve()<<endl;
		//solve();
	}
}


Measured memory_bytes: 7552
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<string.h>
#define fornt(k,n) for(int i=k; i<n; ++i)
#define fornt2(p,n) for(int j=p; j<n; ++j)
#define pb push_back
#define ll long long
#define sc(n) scanf("%d",&n)
#define sc2(x,y) scanf("%d %d",&x,&y)
#define scl(n) scanf("%lld",&n)
#define scl2(x,y) scanf("%lld %lld",&x,&y)
#define pr(n) printf("%d\n",n)
#define prl(n) printf("%lld\n",n)
#define pry printf("YES\n")
#define prn printf("NO\n")
using namespace std;

const int MAX=1e6+7;
unsigned ll a[MAX],b[MAX],x[MAX],y[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
    int n,m,k,cnt;
    cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=1;i<n;i++)
	a[i]+=a[i-1];
	for(int i=0;i<m;i++)
	cin>>b[i];
	for(int i=1;i<m;i++)
	b[i]+=b[i-1];
	unsigned ll ans1=0,ans2=0,sum=0;
	for(ll i=0;i<n;i++)
	{
		sum=a[i];
		unsigned ll temp=k-sum;
		if(temp>k)break;
		unsigned ll pos=upper_bound(b,b+m,temp)-b;
		ans1=max(pos+i+1,ans1);
	}
	sum=0;
	for(ll i=0;i<m;i++)
	{
		sum=b[i];
		unsigned ll temp=k-sum;
		if(temp>k)break;
		unsigned ll pos=upper_bound(a,a+n,temp)-a;
		ans2=max(pos+i+1,ans2);
	}
	cout<<max(ans1,ans2);
    return 0;
}


Measured memory_bytes: 6296
#include<stdio.h>
int main(){
int n,m,cont,now,max,i,input[100000];
while(1){
scanf("%d%d",&n,&m);
if(n==0 && m ==0)
break;
for(i=0;i<n;i++)
scanf("%d",&input[i]);
now = 0;
for(i=0;i<m;i++)
now += input[i];
max=now;
cont = m;
for(i=m;i<n;i++){
now-=input[i-m];
now+=input[i];
if(now>max)
max=now;
}
printf("%d\n",max);
}
}

Measured memory_bytes: 0