akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int l, r;
    if (n%2 == 1) {
        l = a[n/2];
        r = b[n/2];
    }
    else {
        l = a[n/2] + a[n/2-1];
        r = b[n/2] + b[n/2-1];
    }
    cout << r - l + 1 << endl; 
    return 0;
}


Measured memory_bytes: 4740
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	bool OK = 0;
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j <= N; j++) {
			if (N*i + (M - 2 * i)*j == K) OK = 1;
		}
	}
	if (OK) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;

  int ans = (N - 2) * 180;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

ll W[310000],E[310000];

int main(){
  ll N,ans=310000;
  cin>>N;
  string s;
  cin>>s;

  for(int i=0;i<N-1;i++){
    W[i+1]=W[i];
    if(s[i]=='W') W[i+1]++; 
  }

  for(int i=N-1;i>0;i--){
    E[i-1]=E[i];
    if(s[i]=='E') E[i-1]++; 
  }
  for(int i=0;i<N;i++){
    ans=min(ans,W[i]+E[i]);
  }
  cout<<ans<<endl;

  
}


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

ll dp[100005];
ll arr[100005];

int main() {
    ll n;
    cin>>n;
    for(ll x=0; x<n; x++)cin>>arr[x];
    dp[0]=0;
    if(n==2){
        cout<<abs(arr[0]-arr[1]);
    }
    else {
        dp[1]=abs(arr[1]-arr[0]);
        for(ll x=2; x<n; x++){
            dp[x]=min(dp[x-1]+abs(arr[x]-arr[x-1]), dp[x-2]+abs(arr[x]-arr[x-2]));
        }
        cout<<dp[n-1];
    }
    return 0;
}


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

int penalty(int a){
    if (a%10 == 0){
        return 0;
    }
    else {
        return(10 - a%10);
    }    
}

int main(){
    vector<int> vec(5);
    //時間のこと
    int mintime, i, j, time;
    for(i=0;i<5;i++){
        cin >> vec.at(i);
    }
    mintime = 643;
    for(i=0;i<5;i++){
        time = 0;
        for(j=0;j<5;j++){
            time += vec.at(j) + penalty(vec.at(j));
        }
        time -= penalty(vec.at(i));
        if (time < mintime){
            mintime = time;
        }
    }

    cout << mintime << "\n";


    return 0;
}

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

using namespace std;

int main() {
  int s;cin>>s;
  vector<int> vec(1100000);
  int cnt=0;
  while(1){
    cnt++;
      vec[s-1]++;
    if(vec[s-1]==2)break;
    if(s%2==0)s=s/2;
    else s=3*s+1;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 7488
import io
import os

from collections import Counter, defaultdict, deque


def solve(A, B, C, K):
    k = 0
    while A >= B:
        B *= 2
        k += 1
    while B >= C:
        C *= 2
        k += 1
    assert A < B < C
    if k <= K:
        return "Yes"
    return "No"


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
    A, B, C = [int(x) for x in input().split()]
    K, = [int(x) for x in input().split()]  

    ans = solve(A, B, C, K)
    
    print(ans)


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

int main(void){
    long long int a,b,A,B;
    cin>>a>>b;
    long long int x;
    x=a*b;
    if(a>b){
        A=a;
        B=b;
    }else{
        A=b;
        B=a;
    }
    long long int r;
    r=A%B;
    while(r!=0){
    A=B;
    B=r;
    r= A%B;
  }
  cout<<x/B<<endl;

    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n=0;
    while(cin>>n){
        if(n==0)break;
        int a[n];
        int ans=0;
        for(int i=0;i<n/4;i++){
            cin>>a[i];
            ans+=a[i];
        }
        cout<<ans<<endl;
        
        
    }
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll dp[n][2];

    rep(i,n){
        if(i == 0){
            dp[i][0] = a[i];
            dp[i][1] = -a[i];
        }else{
            dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i]);
            dp[i][1] = max(dp[i-1][0] - a[i], dp[i-1][1] + a[i]);
        }
    }
    cout << dp[n-1][0] << endl;
    return 0;
}
 
 


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll N, A;
  cin >> N >> A;
  vector<ll> x(N);
  ll lb=0;
  ll ub=0;
  REP(i,N) {
    ll xi;
    cin >> xi;
    x[i] = xi - A;
    if (x[i]<0){
      lb += x[i];
    } else if (x[i]>0){
      ub += x[i];
    }
  }

  // dp
  vector<vector<ll>> dp(N+1, vector<ll>(ub-lb+1,0));
  dp[0][0-lb] = 1;

  REP(i, N){
    ll xi = x[i];
    REP(j, ub-lb+1){
      if (j+xi<ub-lb+1 && j+xi>=0){
        dp[i+1][j+xi] += dp[i][j];
      }
      dp[i+1][j] += dp[i][j]; // not pick x[i]
    }
  }
  
  cout << dp[N][0-lb]-1 << "\n";
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    char a, b; cin >> a >> b;
    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  int n;
  string s;
  cin >> n >> s;
  if (s.length() > n) {
    cout << s.substr(0, n) << "...";
  } else {
    cout << s;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll x,y;cin>>x>>y;
    ll ans=0;
    if(x*y>0){
        if(y<x){
            ans=x-y+2;
        }
        if(y>x){
            ans=y-x;
        }
    }else if(x*y==0){
        if(x==0){
            if(y<0)ans=-y+1;
            else ans=y;
        }else{
            if(y<x){
                ans=x-y+1;
            }
            if(y>x){
                ans=y-x;
            }
        }
    }else{
        if(x>y){
            if(x>=-y){
                ans=x+y+1;
            }else{
                ans=-y-x+1;
            }
        }
        if(x<y){
            if(-x<=y){
                ans=1+y+x;
            }else{
                ans=-x-y+1;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dx[] = {1,0,-1,-1,0,1};
const int dy[] = {1,1,0,-1,-1,0};
inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,n,x,y,cnt,z = 100;
  while(cin >> t >> n && t+n){
    vector<vector<ll>> v(200,vector<ll>(200,inf));

    rep(i,n){
      cin >> x >> y;
      x += z;
      y += z;
      v[x][y] = -1;
    }
    cin >> x >> y;
    x += z;
    y += z;
    cnt = 1;
    queue<pll> q;
    q.push(mp(x,y));
    ll d = 0;
    v[x][y] = d;
    while(q.size()){
      auto Q = q.front();q.pop();
      d = v[Q.fi][Q.se];
      if(d >= t) continue ;
      rep(i,6){
        ll nx = Q.fi + dx[i],ny = Q.se + dy[i];
        if( v[nx][ny] == inf){
          q.push(mp(nx,ny));
          ++cnt;
          v[nx][ny] = d+1;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3232
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = float("inf")

for i in range(N-K+1):
    lef = x[i]
    rig = x[i+K-1]
    ans = min(ans, abs(lef)+abs(rig-lef), abs(rig)+abs(rig-lef))
print(ans)


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

const int MAX_R = 1e5 + 3;
bool p[MAX_R+5];
int r[MAX_R+5];

void init() {
    for(int i = 0; i <= MAX_R + 1; ++i) p[i] = true;
    p[0] = p[1] = false;
    int i = 2;
    while(i <= MAX_R) {
        for(int j = 2; j*i <= MAX_R; ++j) p[j*i] = false;
        while(p[++i] == false);
    }
    for(int i = 0; i <= MAX_R; ++i) {
        r[i] = r[i-1];
        if(i > 0 && p[i] && p[(i+1)/2]) ++r[i];
    }
}

int main()
{
    int Q;
    cin >> Q;
    init();
    int c[Q+2];
    for(int i = 0; i < Q; ++i) {
        int L, R;
        cin >> L >> R;
        c[i] = r[R] - r[L-1];
    }
    for(int i = 0; i < Q; ++i) cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>


int main()
{

    int n,a,b,c,d;char mm[200100];
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    a--;b--;c--;d--;
    scanf("%s",mm);
    if (c<d)
    {
        int flag=1;
        while (b<d)
        {
            if(mm[b+1]=='.') b+=1;
            else{
                if(mm[b+2]=='.') b+=2;
                else break;
            }
        }
        if (b!=d) {printf("No");return 0;}
        while (a<c)
        {
            if(mm[a+1]=='.') a+=1;
            else{
                if(mm[a+2]=='.') a+=2;
                else break;
            }
        }
        if(a!=c){printf("No");return 0;}
        printf("Yes");
        return 0;
    }

    while(1)
    {
        if (a==c && b==d) {printf("Yes");return 0;}
        int flag=1;
        int oa=a,ob=b;
        while (a<c)
        {
            if(mm[a+1]=='.' && (a+1)!=b) a+=1;
            else{
                if(mm[a+2]=='.' && (a+2)!=b) a+=2;
                else break;
            }
        }
        if (b<d){
            if (mm[b+1]=='.' && (b+1)!=a ) b+=1;
            else if(mm[b+2]=='.' && (b+2)!=a ) b+=2;
        }

        if (oa==a && ob==b) {printf("No");return 0;}
    }

}


Measured memory_bytes: 384
N, M = map(int, input().split())

Nl = [[] for i in range(N)]
# Pl = []

for i in range(M):
    P, Y = map(int, input().split())
    # Pl.append(P-1)
    Nl[P-1].append({"year": Y, "index": i, "pref": P-1})
newl = []
for i in Nl:
    i.sort(key=lambda x: x["year"])
    num = 1
    for j in i:
        j["order"] = num
        num += 1
    newl += i


newl.sort(key=lambda x: x["index"])

for i in newl:

    print("{:06}".format(i["pref"]+1), end="")
    print("{:06}".format(i["order"]))


Measured memory_bytes: 130520
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int s;
    cin >> s;
    set<int> values{ s };
    for (int m = 1;;)
    {
        if (s % 2 == 0) s /= 2;
        else s = s * 3 + 1;
        ++m;
        if (values.find(s) != values.end())
        {
            cout << m << endl;
            break;
        }
        values.insert(s);
    }
}


Measured memory_bytes: 256
n = int(input())
n1 = n
p = 2
primes = []

while n1 != 1:
    if n1%p == 0:
        n1 /= p
        primes.append(p)
    elif n1 == 999993031:
        primes = [999993031]
        break
    else:
        p += 1
print((str(n)+":"),*primes,sep = " ")


Measured memory_bytes: 5604
import heapq


N, M = map(int, input().split())
Work = [tuple(map(int, input().split())) for _ in range(N)]

Work.sort()
now = 1
Q = []
ans = 0
for day, reward in Work:
    if day > M:
        break
    if now > M:
        break
    if day == now:
        heapq.heappush(Q, -reward)
    else:
        while day - now > 1:
            if len(Q) > 0:
                a = heapq.heappop(Q)
                ans += a
            now += 1
        if len(Q) > 0:
            a = heapq.heappop(Q)
            ans += a
        heapq.heappush(Q, -reward)
        now = day
while M - now >= 0:
    if len(Q) > 0:
        a = heapq.heappop(Q)
        ans += a
    now += 1

print(-ans)

Measured memory_bytes: 81368
n = int(input())
b = list(map(int, input().split()))
b = b + [b[-1]]

a = [0] * (n)
for i in range(n):
    if i==0:
        a[i] = b[0]
    else:
        a[i] = min(b[i], b[i-1])
        
print(sum(a))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int wt=0,kt=0;
		int[] w=new int[10];
		int[] k=new int[10];
		for(int i=0;i<10;i++){
			w[i]=sc.nextInt();
		}
		for(int i=0;i<10;i++){
			k[i]=sc.nextInt();
		}
		Arrays.sort(w);
		wt=w[9]+w[8]+w[7];
		Arrays.sort(k);
		kt=k[9]+k[8]+k[7];
		System.out.println(wt+" "+kt);
	}
}

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

namespace abc_061
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a[2]>=a[0]&&a[2]<=a[1]?"Yes":"No");
        }
    }
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int a, b;

int main(){
  cin >> a >> b;
  if(a >= 10 || b >= 10){
    cout << -1 <<endl;
  }else{
    cout << a * b <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;cin >> s;
    ll sz=s.size();
    ll ans=0;
    ll pop=0;
    vl dp1(sz+1,0);
    vl dp0(sz+1,0);
    dp0[0]=1;
    rep(i,sz){
        dp1[i+1]=dp1[i]*3;
        dp1[i+1]%=MOD;
        if(s[i]=='0'){
            dp0[i+1]=dp0[i];
            dp0[i+1]%=MOD;
        }
        else{
            dp0[i+1]+=2*dp0[i];
            dp0[i+1]%=MOD;
            dp1[i+1]+=dp0[i];
            dp1[i+1]%=MOD;
        }
    }
    cout << (dp1[sz]+dp0[sz])%MOD <<endl;
}

Measured memory_bytes: 2048
def examA():
    AB = [I() for _ in range(2)]
    for i in range(1,4):
        if not i in AB:
            ans = i
            break
    print(ans)
    return

def examB():
    return

def examC():
    return

def examD():
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 38384
import java.util.*;
public class Main
{
	public static class process
	{
		String name;
		int time;
		public process(String n, int t)
		{
			name=n;
			time=t;
		}
		public String getName()
		{
			return this.name;
		}
		
		public int getTime()
		{
			return this.time;
		}
		
		public void run(int t)
		{
			if(this.time-t<0)
			{
				this.time=0;
			}
			else
			{
				this.time = this.time - t;
			}
		}
	}
	
	public static void main(String[] args)
	{
		Queue<process> q = new LinkedList<process>();
		Scanner in = new Scanner(System.in);
		int procs = in.nextInt();
		int lot = in.nextInt();
		for(int c = 0; c < procs ; c++)
		{
			q.add(new process(in.next(),in.nextInt()));
		}
		in.close();
		
		//start of algorithm
		int runTime = 0;
		while(!q.isEmpty())
		{
			process p = q.poll();
			int remainingPTime = p.getTime();
			p.run(lot);
			if(p.time == 0)
			{
				runTime+= remainingPTime;
				System.out.println(p.getName()+" "+runTime);
			}
			else 
			{
				runTime+=lot;
				q.add(p);
			}
		}
	}
}


Measured memory_bytes: 75280
import  java.util.Scanner;

public class Main {
	
	void run(){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int[] c = new int[4];
		for(int i=0;i<s.length;i++) {
			if(s[i]=='K')c[0]++;
			if(s[i]=='U')c[1]++;
			if(s[i]=='P')c[2]++;
			if(s[i]=='C')c[3]++;
		}
		System.out.println(Math.min(c[0], Math.min(c[1], Math.min(c[2], c[3]))));
	}

	public static void main(String[] args) {
		new Main().run();
	}

}



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

int main(){
    list<char> s;
    string a;
    cin >> a;
    for(int i = 0; i < a.length(); i++){
        s.push_back(a[i]);
    }
    int q, r = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        int k; cin >> k;
        if(k == 1){
            r++;
        }else if(k == 2){
            int h; cin >> h;
            char t; cin >> t;
            if(h == 2 && r % 2 == 0){
                s.push_back(t);
            }else if(h == 2 && r % 2 == 1){
                s.push_front(t);
            }else if(h == 1 && r % 2 == 0){
                s.push_front(t);
            }else{
                s.push_back(t);
            }
        }
    }

    if(r % 2 == 1){
        reverse(s.begin(),s.end());
    }
    
    std::for_each(s.cbegin(), s.cend(), [](char x){
        std::cout << x;
    });
    cout << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    string s; cin >> s;
    bool ans = s[2]==s[3] && s[4]==s[5];
    cout << (ans ? "Yes":"No") << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll x;
	cin>>x;
	ll ans = 0LL;
	ans = (x-1LL)*x/2LL;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#define PI 3.14159265358979

using namespace std;

int main(){
  int n,s[1000];
  for(int i=0;i < 1000;i++) s[i] = 0;
  double m = 0,v = 0;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i < n;i++){
      cin >> s[i];
      m += (double)s[i];
    }
    m /= n;

    for(int i=0;i < n;i++){
      v += (double)(s[i] - m)*(s[i] - m);
    }
    v /= n;
    printf("%.8lf\n",sqrt(v));
    for(int i=0;i < 1000;i++) s[i] = 0;
    m = v = 0;
  }
  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
char C[55][55];
int H,W;
int dp[55][55];
int visit[55][55];
int X[] = {-1,0,1,0};
int Y[] = {0,-1,0,1};
bool ok(int a,int b) {
 if(a>=0 && a<H && b>=0 && b<W) return true;
 return false;
}
void solve(int a,int b) {
  queue< pair<int,int> > Q;
  Q.push(make_pair(a,b));
  visit[0][0] = 1;
  dp[0][0] = 0;
  while(!Q.empty()) {
    int a = Q.front().first;
    int b = Q.front().second;
    Q.pop();
    for(int i=0;i<4;i++) {
        int na = a+X[i];
        int nb = b+Y[i];
        if(ok(na,nb) && visit[na][nb] == 0 && C[na][nb] == '.') {
            visit[na][nb] = 1;
            dp[na][nb] = dp[a][b]+1;
            Q.push(make_pair(na,nb));
        }
    }
  }
}
int main() {
  cin >> H >> W;
  int white = 0;
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++) {
        cin >> C[i][j];
        if(C[i][j] == '.') white++;
        dp[i][j] = 10000;
        visit[i][j] = 0;
    }
  }
  solve(0,0);
  int ans = dp[H-1][W-1]+1;
  if(ans >= 10000) puts("-1");
  else printf("%d\n",white-ans);
  return 0;
}


Measured memory_bytes: 256
W,H,N = map(int, input().strip().split(' '))
x1,x2 = 0,W
y1,y2 = 0,H
for _ in range(N):
  x,y,a = map(int, input().strip().split(' '))
  if a == 1:
    x1 = max(x1, x)
  elif a == 2:
    x2 = min(x2, x)
  elif a == 3:
    y1 = max(y1, y)
  else:
    y2 = min(y2, y)
  

s = max(0, (x2-x1))*max(0, (y2-y1))
print(s)

Measured memory_bytes: 38384
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,l,a[100005]={},x,f=0;
  cin >> n >> l;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++) {
    if(a[i]+a[i+1]>=l) {
      x=i,f=1;
      break;
    }
  }
  if(!f) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for(int i=0; i<x; i++) {
    cout << i+1 << endl;
  }
  for(int i=n-2; i>=x; i--) {
    cout << i+1 << endl;
  }
}

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

int main(){

  string s;
  int stk[100];
  int indx=0;
  int i=0;

  getline(cin,s);

  while(i < (int)s.size()){

    if(s[i] == ' '){
    }
    else if(s[i]=='+'){
      stk[indx-2]+=stk[indx-1];
      indx--;
    }
    else if(s[i]=='-'){
      stk[indx-2]-=stk[indx-1];
      indx--;
    }
    else if(s[i]=='*'){
      stk[indx-2]*=stk[indx-1];
      indx--;
    }
    else{
      stk[indx]=0;
      while(s[i]!=' '){
	stk[indx]*=10;
	stk[indx]+=s[i]-'0';
	i++;
      }
      i--;
      indx++;
    }

    i++;

  }
  
  cout << stk[0] << endl;

  return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(A <= C && C <= B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int a[3][3];
    forn(i, 3) forn(j, 3) cin >> a[i][j];
    int n; cin >> n;
    while (n--) {
        int x; cin >> x;
        forn(i, 3) forn(j, 3) if(a[i][j] == x) a[i][j] = 0;
    }
    bool ok = false;
    forn(i,3){
        ok = true;
        forn(j, 3) if(a[i][j]) ok = false;
        if(ok) break;
        ok = true;
        forn(j, 3) if(a[j][i]) ok = false;
        if(ok) break;
    }
    if (!ok) {
        ok = true;
        forn(i,3) if(a[i][i]) ok = false;
    }
    if (!ok) {
        ok = true;
        forn(i,3) if(a[2-i][i]) ok = false;
    }

    cout << (ok ? "Yes" : "No") << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long long n;
    long long m,l,s,a;
    scanf("%lld",&n);
    for(long long i = 1;i <= n;i++){
        scanf("%lld",&a);
        if (i == 1) {
            l = a;
            m = a;
            s = a; 
        }
        else{
            if(m > a){m = a;}
            if(l < a){l = a;}
            s += a;
        }
        }
    printf("%lld %lld %lld\n",m,l,s);    
        return 0;}


Measured memory_bytes: 2736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int main()
{
	//input;output;
	int arr[Maxn<<1];
	LL sum[Maxn<<1],ans;
	int n;
	while(~scanf("%d",&n))
	{
		ans=Inf;
		memset(sum,0,sizeof(sum));
		for(int i=1;i<=n;i++)
			scanf("%d",arr+i),sum[i]=sum[i-1]+arr[i];
		for(int i=1;i<n;i++)
			ans=min(ans,abs(2*sum[i]-sum[n]));
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

vll getPrimeFactorize(ll m) {
    vll v;
    for (int i = 1; i <= sqrt(m); i++) {
        if (m % i == 0) v.push_back(i), v.push_back(m / i);
    }
    sort(all(v));
    return v;
}

int main()
{
    ll N, M; cin >> N >> M;
    vll v = getPrimeFactorize(M);
    ll mn;
    for (ll x : v) {
        if (M / x >= N) {
            mn = x;
        } else {
            break;
        }
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,i;
    long long a,min = 1000000,max = -1000000,sum = 0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        if (a<min) min=a;
        if (a>max) max=a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			Integer N = sc.nextInt();
			HashMap<String, Integer> soinsuMap = new HashMap<>();

			for (int i = N;i>=2;i--) {
				soinsuMap = soinbunkai(soinsuMap,i);
			}

			long ret =1;
			for(int i : soinsuMap.values()) {
				ret = ret * (i+1) % 1000000007;
			}

			System.out.println(ret);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private HashMap<String,Integer> soinbunkai(HashMap<String,Integer> map, int n){
		HashMap<String, Integer> ret;
		if (map == null) ret = new HashMap<>();
		else ret = map;

		int nnum = n;
		for (int i=2;i<=n;i++){
			while (nnum%i==0) {
				nnum/=i;
				String stri = Integer.toString(i);
				if (ret.containsKey(stri)) ret.put(stri, ret.get(stri)+1);
				else ret.put(stri, 1);

				if (nnum == 1) break;
			}
		}
		return ret;
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
struct Data {
	string name;
	int start, max;
	bool operator <(Data b) {
		return this->start < b.start;
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, q;
		cin >> n >> q;
		if (!n)break;
		vector<Data> v(n);
		REP(i, n) {
			cin >> v[i].name >> v[i].max >> v[i].start;
			v[i].start -= v[i].max - 1;
		}
		sort(ALL(v));
		REP(i, q) {
			int a;
			cin >> a;
			int p = -1;
			REP(j, n) {
				if (v[j].start <= a&&v[j].start+v[j].max-1>=a) {
					p = j;
					cout << v[j].name << " " << a-v[j].start+1 << endl;
					break;
				}
			}
			if (p == -1) {
				cout << "Unknown" << endl;
			}
			


		}
	}
	return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_128
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] ap = ReadInts();
            int val = ap[0] * 3 + ap[1];
            WriteLine(val / 2);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;

  string s;
  std::cin >> s;

  int red = 0;
  int blue = 0;

  for(size_t i = 0; i < (int)s.size(); i++){
    char ch = s.at(i);
    if (ch == 'R') red++;
    else blue++;
  }

  if (red > blue) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  
}


Measured memory_bytes: 256
n = int(input())
ps = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
cnts = []
ans = 0

for p in ps:
    cnt = 0
    for i in range(1,100):
        add = n//(p**i)
        if add != 0:
            cnt += add
        else:
            break
    cnts.append(cnt)

# 75
ans += sum(1 if x>=74 else 0 for x in cnts)

# 25 * 3
ans += sum(1 if x>=24 else 0 for x in cnts) * (sum(1 if x>=2 else 0 for x in cnts) - 1)

# 15 * 5
ans += sum(1 if x>=14 else 0 for x in cnts) * (sum(1 if x>=4 else 0 for x in cnts) - 1)

# 5 * 5 * 3
ans += (sum(1 if x>=4 else 0 for x in cnts) * (sum(1 if x>=4 else 0 for x in cnts) - 1) * (sum(1 if x>=2 else 0 for x in cnts) - 2)) // 2

print(ans)

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

using namespace std;

int main()
{
    int n,v,l,i,j,m,p,f;
    cin>>n;
    int a[n],dp[n];
    cin>>a[0]>>a[1];
    dp[0]=0;
    dp[1]=fabs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        cin>>a[i];
        dp[i]=min(((fabs(a[i]-a[i-2]))+dp[i-2]),(fabs(a[i]-a[i-1])+dp[i-1]));
    }
    cout<<dp[n-1];
}















Measured memory_bytes: 1024
N, A, B = map(int, input().split())

def keta_sum(x):
    li = list(map(int, str(x)))
    return sum(li)
answer = 0
for i in range(1,N+1):
    if A<=keta_sum(i) and keta_sum(i)<=B:
        answer += i
print(answer)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;

public class p1173{
	p1173(){
		string str;
		char[] ch;
		Stack<char> stk;// = new Stack<char>();
		bool f;
		
		while((str=Console.ReadLine()) != null && str != "."){
			stk = new Stack<char>();
			ch = str.ToCharArray();
			f = true;
			
			for(int i = 0; i < ch.Length && f; ++i){
				if(ch[i] == '(' || ch[i] == '[') stk.Push(ch[i]);
				else if(ch[i] == ')'){
					if(stk.Count == 0){
						f = false;
						break;
					}
					if(stk.Peek() != '(') f = false;
					stk.Pop();
				} else if(ch[i] == ']'){
					if(stk.Count == 0){
						f = false;
						break;
					}
					if(stk.Peek() != '[') f = false;
					stk.Pop();
				}
			}
			if(stk.Count > 0) f = false;
			
			Console.WriteLine("{0}", (f? "yes": "no"));
			stk.Clear();
		}
	}
	
	public static int Main(string[] args){
		new p1173();
		return 0;
	}
}

Measured memory_bytes: 5944
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int A = cin.nextint;
        int B = cin.nextint;
        int AB = cin.nextint;
        int X = cin.nextint;
        int Y = cin.nextint;

        if (A + B <= AB * 2)
        {
            WriteLine(A * X + B * Y);
            return;
        }
        int buy = Math.Min(X, Y);
        long ans = AB * 2 * Math.Min(X, Y);
        X -= buy;
        Y -= buy;
        ans += Math.Min(A, AB * 2) * X + Math.Min(B, AB * 2) * Y;

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  int result[n] = {};
  int i;
  for (i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    result[a[i] - 1]++;
    result[b[i] - 1]++;
  }
  for (i = 0; i < n; i++) {
    cout << result[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if((x - r >= 0)&&(x + r <= W)){
            if((y - r >= 0)&&(y + r <= H)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }

    }
}



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


int main() {
    int N;
    cin >> N;
    vector<int> B(N-1, 0);
    rep(i,N-1) {
        cin >> B.at(i);
    }
    
    vector<int> A(N, 0);
    rep(i,N-1) {
        if (i == 0) A.at(i) = B.at(i);
        else {
            A.at(i) = min(B.at(i-1), B.at(i));
        }
    }
    A.at(N-1) = B.at(N-2);
    int ans = 0;
    rep(i,N) ans += A.at(i);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
	// ?¨??????\???????????????????????????????????????
	Scanner sc= new Scanner(System.in);
	int w = sc.nextInt();
	int n = sc.nextInt();
	int[] values = new int[w];
	//?£??????¬??°?????????????????????
	for(int i= 0; i< values.length; i++) {
	values[i] = i+ 1;
	}
	for(int i= 0; i< n; i++) {
	String str= sc.next();
	String[] ab = str.split(",");
	int a = Integer.parseInt(ab[0]) -1;
	int b = Integer.parseInt(ab[1]) -1;
	
	int c;
	c=values[a];
	values[a]=values[b];
	values[b]=c;
	// a??¨b????????£???values??????????????????
	}
	// values??????????????????
	for(int i= 0; i< values.length; i++) {
		System.out.printf("%d\n",values[i]);
	}
	}
	}

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


int main() {
  int n;
  cin >> n;
  if(n <= 999) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


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

    int64 ans = 0;
    bool flag = false;
    int64 i = 1;
    for (int j=0; j<n; j++) {
        if (a[j] != i) ans++;
        else i++,flag=true;
    }

    cout << (flag? ans : -1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

vector<int> G[100001],Q[100001];
set<int> group[100000];
vector<bool> seen;
int cnt(0);
int group_num[100001] = {0};
void dfs(int v) {
  group[cnt].insert(v); 
  group_num[v] = cnt;
  seen[v] = true;
  for (auto next_v : G[v]) { 
      if (seen[next_v]) continue;
      dfs(next_v); // 再帰的に探索
  }
}

int main(){
  int N,M,K;
  cin>>N>>M>>K;
	seen.assign(N, false);
  for (int i(0);i<M;i++){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i(1);i<=N;i++){
    if (seen[i]) continue; // v が探索済みだったらスルー
    dfs(i); // v が未探索なら v を始点とした DFS を行う
    cnt++;
  }
  int block[100001] = {0};
  for (int i(0);i<K;i++){
    int a,b;
    cin>>a>>b;
    if (group_num[a] == group_num[b]){
      block[a]++;
      block[b]++;
    }
  }
  int renketu[100001] = {0};
  for (int i(0);i<cnt;i++){
    //for (int j(0);j<int(group[i].size());j++){
    for (auto j:group[i]){
      renketu[j] = int(group[i].size());
    }
  }
  //int block[100000] = {0};
  //for (int i(1);i<=N;i++) cout << renketu[i] <<" ";
  for (int i(1);i<=N;i++){
    cout << renketu[i] - int(G[i].size()) - 1 - block[i]<<" ";
    //cout << renketu[i] - int(G[i].size()) - 1 - int(Q[i].size()) << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 19968
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int main()
{
	int a; char s[10];
	int b[4] = {0};
	while(~scanf("%d,%s",&a,&s)){
		string c(s);
		if(c == "A")b[0]++;
		else if(c == "B")b[1]++;
		if(c == "AB")b[2]++;
		if(c == "O")b[3]++;
	}
	printf("%d\n%d\n%d\n%d\n",b[0],b[1],b[2],b[3]);
}

Measured memory_bytes: 0
n,m=map(int,input().split())
h=list(map(int,input().split()))
crime=[0]*n

for i in range(m):
 a,b=map(int,input().split())
 crime[a-1]=max([crime[a-1],h[b-1]]) 
 crime[b-1]=max([crime[b-1],h[a-1]])

ans=0
for i in range(n):
 if h[i]>crime[i]:
  ans+=1

print(ans)

Measured memory_bytes: 20056
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N,a,b;
std::vector<LL>A;

int main()
{
	in >> N;
	A.resize(N);
	rep(i, N) in >> A[i];
	std::sort(A.begin(), A.end(),std::greater<LL>());
	rep(i, N)
	{
		if (i % 2 == 0) a += A[i];
		else b += A[i];
	}
	out << a - b << std::endl;
	return 0;
}

Measured memory_bytes: 256