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

using namespace std;

int main() {
  int N;
  cin >> N;
  double answer = 0.0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      answer += x;
    } else {
      answer += x * 380000.0;
    }
  }
  cout << answer;

  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int score = 0;
  int x;
  int a, b;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    if (K - x > x)
      score += 2 * x;
    else
      score += 2 * (K - x);
  }

  cout << score << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

bool is753(int x, int n){
  if(x>n) return false;
  string xx = to_string(x);
  int cnt[3] = {0,0,0};
  for(int i=0;i<(int)xx.size();i++){
    if((char)xx[i]=='3')cnt[0]++;
    if((char)xx[i]=='5')cnt[1]++;
    if((char)xx[i]=='7')cnt[2]++;
  }
  if(cnt[0]*cnt[1]*cnt[2]) return true;
  return false;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> v(9);
  v[0] = {3,5,7};
  for(int i=1;i<9;i++){
    for(int j=0;j<(int)v[i-1].size();j++){
      v[i].pb(v[i-1][j]*10+3);
      v[i].pb(v[i-1][j]*10+5);
      v[i].pb(v[i-1][j]*10+7);
    }
  }
  int ans = 0;
  for(int i=0;i<9;i++){
    for(int j=0;j<(int)v[i].size(); j++){
      if(is753(v[i][j],N))ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
ll a[100];
ll aaa[100];
ll maxx = -2;
ll id = -1;
vector<pair<ll ,ll> > ans;
void print()
{
        cout << ans.size() << endl;
        for(auto i : ans)
                cout << i.first << " " << i.second << endl;
}
void do1()
{
        for(ll i=1;i<=n;i++)
        {
                if(i == id) continue;
                ans.push_back(make_pair(id , i));
        }
        for(ll i=2;i<=n;i++)
        {
                ans.push_back(make_pair(i-1, i));
        }
        print();
}
void do2()
{
        for(ll i=1;i<=n;i++)
        {
                if(i == id) continue;
                ans.push_back(make_pair(id , i));
        }
        for(ll i=n;i>=2;i--)
        {
                ans.push_back(make_pair(i , i-1));
        }
        print();
}
bool check()
{
        for(ll i=2;i<=n;i++)
        {
                if(a[i] >= a[i-1]) continue;

                return false;
        }
        return true;
}
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++)
        {
                cin >> a[i];
                aaa[i] = abs(a[i]);
        }
        if(check())
        {
                cout << "0\n";
                return 0;
        }
        for(ll i=1;i<=n;i++)
        {
                if(maxx < aaa[i])
                {
                        maxx = aaa[i];
                        id = i;
                }
        }
        if(a[id] > 0)
        {
               // cout << "11111\n";
                do1();
        }else
        {
                do2();
        }
        return 0;
}


Measured memory_bytes: 256
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
w = a
i = 0
while i < 100:
 if  a%b == c:
  print("YES")
  break
 else:
  a = a+w
  i = i+1
if i ==100:
 print("NO")
else:
 a = a

Measured memory_bytes: 3064
a = int(input())

import math
b = int(math.sqrt(a))

if a == b ** 2:
    x = [0, 0, b, 0, 0, b]
elif a == b * (b + 1):
    x = [0, 0, b, 0, 0, b + 1]
elif a > b * (b + 1):
    x = [0, 0, (b + 1) ** 2 - a, b + 1, b + 1, 1]
elif a < b * (b + 1):
    x = [0, 0, 1, b + 1, b, b * (b + 1) - a]

x_string = map(str, x)
print(' '.join(x_string))

Measured memory_bytes: 38256
package main
import (
  "fmt"
  "math"
)

func main() {
  var (
    N float64
    A float64
    B float64
  )
  fmt.Scan(&N)
  fmt.Scan(&A)
  fmt.Scan(&B)

  fmt.Println(math.Min(N * A, B))
  
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for (int _ = 1; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> res(n);
    vector<int> c[3];
    for (int i = 1; i <= n; i++) {
        c[i%3].push_back(i);
    }
    vector<vector<int>> a(2);
    function<void(int,int,int)> dfs = [&](int u, int p,int depth){
        a[depth&1].push_back(u);
        for (int v:g[u])if(v!=p){
            dfs(v,u,depth+1);
        }
    };
    dfs(0,-1,0);
    if (a[0].size() > a[1].size()) swap(a[0], a[1]);

    auto take = [](vector<int>& v){
        int x = v.back(); v.pop_back();
        return x;
    };

    if (a[0].size() <= c[0].size()) {
        while (a[0].size()) {
            int u = a[0].back(); a[0].pop_back();
            int x = c[0].back(); c[0].pop_back();
            res[u] = x;
        }
        for (int i:{0,1,2}) {
            while (c[i].size()) {
                int u = take(a[1]);
                int x = take(c[i]);
                res[u] = x;
            }
        }
    } else {
        assert(c[1].size() <= a[0].size());
        assert(c[2].size() <= a[1].size());
        while (c[1].size()) {
            res[take(a[0])] = take(c[1]);
        }
        while (c[2].size()) {
            res[take(a[1])] = take(c[2]);
        }
        for (int i:{0,1}) {
            while (a[i].size()) {
                res[take(a[i])] = take(c[0]);
            }
        }
    }

    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 21144
#include <iostream>
#include <vector>
#include <random>
using namespace std;
typedef long long int ll;

int card[1100][1100];
int seq[1100];

int main(){
	int n,k; cin >> n >> k;
	for(int i=0;i<k;i++){
		for(int j=0;j<n/2;j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	random_device rnd;
	mt19937 mt(rnd());
	while(1){
		for(int i=0;i<n;i++){
			seq[i]=mt()%2;
		}
		bool ok=true;
		for(int i=0;i<k;i++){
			int sum=0;
			for(int j=0;j<n/2;j++){
				sum+=seq[card[i][j]];
				if(sum>3*n/8)ok=false;
			}
			if(sum<n/8)ok=false;
			if(!ok)break;
		}
		if(ok){
			for(int i=0;i<n;i++){
				cout << seq[i];
			}
			cout << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 5252
#include<iostream>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	long long a[114514];
	a[1] = 0;
	for (int i = 2; i <= n; i++) {
		int p; cin >> p;
		a[i] = a[i - 1] + p;
	}
	long long ans = 0; int k = 1;
	for (int i = 0; i < m; i++) {
		int l; cin >> l;
		if (l > 0)ans += a[k + l] - a[k];
		else ans += a[k] - a[k + l];
		k += l;
	}
	cout << ans%100000 << endl;
	return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X -= Z;
    cout << X / (Y + Z) << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] == 'C' && s[j] == 'F') {
        return cout << "Yes" << endl, 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
w = [input()]
for i in range(n-1):
    tmp = input()
    if w[i][-1] == tmp[0]:
        flg = tmp in w
        if flg == False:
            w.append(tmp)
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9160
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    for i in range(n):
        for j in range(i, i+2):
            if a[j] >= b[i]:
                a[j] -= b[i]
                ans += b[i]
                break
            else:
                ans += a[j]
                b[i] -=  a[j]
                a[j] = 0
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24420
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100009], b[100009];

int main(){
    int n, k, mask;
    scanf("%d %d",&n, &k);    
    for(int i = 0; i < n; i++){
        scanf("%d %d", a+i, b+i);
    }
    k++;
    long long ans = 0;
    for(int bit = 30; bit >= 0; bit--){
        if((k >> bit) & 1){
            mask = k ^ (1<<bit);
            mask |= (1<<bit) - 1;
            long long cur = 0;
            for(int i = 0; i < n; i++){
                if((a[i] & mask) == a[i]){
                    cur += b[i];
                }
            }
            ans = max(ans, cur);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  int a,b,c,d;
  bool ans=false;
  cin >> a >> b >> c >> d;
  
  if(abs(a-b)<=d && abs(b-c)<=d) ans=true;
  else if(abs(a-c) <= d) ans = true;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
a = sorted(a, key=lambda x: x[1])

br = a[0][1]
cnt = 1
for i in range(m-1):
    if a[i+1][0] >= br:
        br = a[i+1][1]
        cnt += 1
print(cnt)

Measured memory_bytes: 31524
# C - Subarray Sum
N,K,S = map(int, input().split())
A = []
count = 0
if N == 1:
    A.append(S)
    A = [str(a) for a in A]
    A = " ".join(A)
    print(A)
    exit()
else:
    while count < K:
        A.append(S)
        count += 1

    if N - len(A) > 0:
        if S < 1000000000:
            while len(A) < N:
                A.append(S + 1)
        else:
            while len(A) < N:
                A.append(S - 1)

    else:
        pass
    A = [str(a) for a in A]
    A = " ".join(A)
    print(A)

Measured memory_bytes: 56992
#include<stdio.h>
#include<string.h>
int main(void){
  char S[99];
  int lens,i;
  scanf("%s",S);
  lens = strlen(S);
  for(i=0; i<(lens-1)/2; i++){
    if(S[i] != S[lens -i-1]){
      printf("No\n");
      return 0;
    }
  }

  for(i=0; i < (lens-1)/2; i++){
    if(S[i]!=S[(lens-1)/2-i-1]){
      printf("No\n");
      return 0;
    }
  }

  for(i=0; i<(lens-3)/2; i++){
    if(S[(lens+3)/2-1+i]!=S[lens-1-i]){
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;

}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

int main(){
    int h,w; cin >> h >> w;
    vector<string> gd(h);
    rep(i,h) cin >> gd[i];
    mint ans[h+1][w+1];
    rep(i,h+1) ans[i][0]=0;
    rep(i,w+1) ans[0][i]=0;
    ans[0][1]=1;
    rep(i,h)rep(j,w){
        if(gd[i][j]=='#'){
            ans[i+1][j+1]=0;
            continue;
        }
        ans[i+1][j+1]=ans[i][j+1]+ans[i+1][j];
    }
    /*rep(i,h+1){
        rep(j,w+1){
            printf("%d ",ans[i][j]);
        }
        puts("");
    }*/
    cout << ans[h][w].x << endl;
return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>

void trace(int A[], int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertSort(int A[], int N){
    int j, i, v;
    for(i=1;i<N;i++){
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];
    scanf("%d", &N);
    for(i=0;i<N;i++) scanf("%d", &A[i]);
    trace(A,N);
    insertSort(A,N);

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    ll n,a,b;
    cin >> n >> a >>b;
    if((n-n/(a+b)*(a+b))>a)cout << n/(a+b)*a+a << endl;
    else cout << n/(a+b)*a+n-n/(a+b)*(a+b) << endl;
    
    return 0;
}


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

const int kSize = 100000;
int A[kSize];

int partition(int p, int r) {
    int x = A[r];
    int i = p - 1;

    for (int j = p; j <= r - 1; ++j) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }

    swap(A[i + 1], A[r]);
    return i + 1;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    int ans = partition(0, n - 1);
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            cout << A[i];
        } else if (i == ans) {
            cout << " " << '[' << A[i] << ']';
        } else {
            cout << " " << A[i];
        }
    }
    
    cout << endl;
    return 0;
}



Measured memory_bytes: 3424
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] abt = Console.ReadLine().Split();
            var a = int.Parse(abt[0]);
            var b = int.Parse(abt[1]);
            var t = int.Parse(abt[2]);
            var ret = 0;

            for (var i = a; i <= t; i += a) ret += b;
            Console.WriteLine(ret);
        }


    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int x;
  cin >> x;
  cout << x / 3 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int A = 0, B = 0, C = 0, D = 0;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes";
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No";
            break;
        }
    }
}

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

int main()
{long long N,A,B,C,D,E;
 
 cin >> N >> A >> B >> C >> D >> E;
 
 long long X = min(min(min(min(A,B),C),D),E);
 
 
 long long Y = (( N + X - 1 ) / X ) + (long long) 4 ;
 
 cout << Y <<endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
using namespace std;

int main(){
  int w,h;
  cin >> w >> h;
  int m = max(h,w);
  int n;
  cin >> n;
  int ans = 0;
  while(true){
    ans++;
    if(ans * m >= n) break;
  }
  cout << ans;
  
  return 0;
}

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

int main (void) {
    
    int a, b, c, d;
    int ans1, ans2;

    cin >> a >> b >> c >> d;

    ans1 = a * b;
    ans2 = c * d;


    if (ans1 < ans2 ) {
        cout <<  ans2 << endl;
    }else if (ans1 == ans2) {
        cout << ans1 << endl;
    }else{
        cout << ans1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const int MAX_N = 1e5;
ll N;
ll t[MAX_N], a[MAX_N];
ll s[MAX_N], ss[MAX_N];
ll MOD = 1e9 + 7;
void solve() {
  ss[0] = 100;
  ss[N-1] = 1;
  if (N == 1 && t[0] != a[0]) {
    cout << 0 << endl;
    return;
  }
  REP(i, N) {
    if (i > 0 && t[i] != t[i - 1]) {
      s[i] = t[i];
      ss[i]+= 100;
    }
    if (i > 0 && a[N - i - 1] != a[N - i]) {
      s[N - i - 1] = a[N -  i - 1];
      ss[N - i - 1] += 1;
    }
  }
  REP(i, N) {
    if (ss[i] == 0) {
      s[i] = MIN(t[i], a[i]);
    } else if (ss[i] == 101 && t[i] != a[i]) {
      cout << 0 << endl;
      return;
    } else {
      if ((ss[i] == 100 && t[i] > a[i]) || (ss[i] == 1 && t[i] < a[i])) {
        cout << 0 << endl;
        return;
      }
    }
  }

  ll ans = 1;
  REP(i, N) {
    if (ss[i] > 0) continue;
    ans *= (s[i] % MOD);
    ans %= MOD;
  }
  cout << ans % MOD << endl;
}

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

  cin >> N;
  REP(i, N) {
    cin >> t[i];
  }
  REP(i, N) cin >> a[i];
  solve();
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=300010;

struct UnionFind {
    vector<int> data;
    //size_分のデータを用意
    UnionFind(int size_) : data(size_, -1) { }
    //xとyの属する集合を併合
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    //xとyが同じ集合に属するか
    bool findSet(int x, int y) { return root(x) == root(y); }
    //xの根を求める
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    //
    int size(int x) { return -data[root(x)]; }
};

int main(){
	int n,m,k;
	cin>>n>>m>>k;
	int a[m], b[m];
	int c[k], d[k];
	int next[n];
	REP(i,n)next[i]=0;
	REP(i,m){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		next[a[i]]++;
		next[b[i]]++;
	}
	UnionFind uf(n);
	REP(i,m){
		if(!uf.findSet(a[i],b[i])){
			bool set=uf.unionSet(a[i],b[i]);
		}	
	}
	int ans[n];
	REP(i,n)ans[i]=0;

	REP(i,k){
		cin>>c[i]>>d[i];
		c[i]--; d[i]--;
		if(uf.findSet(c[i],d[i])){
			ans[c[i]]--;
			ans[d[i]]--;
		}
	}

	REP(i,n){
		ans[i]+=uf.size(i)-next[i];
	}

	REP(i,n){
		cout<<ans[i]-1;
		if(i!=n-1)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{
	int n,a[100001],j=0,o=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0) o++;
		else j++;
	}
	if(j%2!=0) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> que;
    rep(i,N) {
        ll A;
        cin >> A;
        que.push(A);
    }
    rep(i,M) {
        ll A = que.top(); que.pop();
        A >>= 1;
        que.push(A);
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4324
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <climits>

using namespace std;

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define printi(x) printf("%d ", x)
#define printiln(x) printf("%d\n", x)
#define printiarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1])
#define scani(x) scanf("%d", &x)
#define scaniarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}
#define scans(str) scanf("%s",str)
#define scanc(ch) scanf("%c", &ch)

int main() {
    int n,k;
    scani(n);
    scani(k);
    int w[n];
    scaniarray(w,n);
	//printiarray(w,n);
    int r = 0;
	int max = INT_MIN;
	int min = INT_MAX;
    rep(i,0,n-1) {
        r += w[i];
    	if(w[i] > max) max = w[i];
    	if(w[i] < min) min = w[i];
    }
	//printiln(r);
    int l = 0;
    
    int mid;
	int j = 0;
	int ans = r;
    while (l+1 < r) {
        mid = (l+r) / 2;
    	//printi(l);
    	//printi(mid);
    	//printiln(r);
    	int a = 0;
    	
    	j = 0;
    	if(mid < max) {
    		//printf("dame -1\n");
    		l = mid;
    		continue;
    	}
    	
        rep(i,0,n-1) {

        	if(a+w[i] > mid) {
            	//printi(a);
        		a = 0;
                j++;
        	} 
        	if(a+w[i] <= mid) {
        		a += w[i];
        		if(i==n-1) {
        			//printi(a);
        			j++;
        		}
        	}
        }
    	if(j > k) {
    		//printf("dame ");
    		l = mid;
    	} else {
    		//printf("ok ");
    		r = mid;
    		ans = r;
    	}
    	//printiln(-1);
    }
    printiln(ans);
    
    
    
    return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int a[200050],f[200050],st[200050];
bool b[200050];
vector<int> p[200050];
int main(){
	int n,i,x=0,y,t,cnt=1,sl=-1;
	long long k;
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;++i){
		scanf("%d",a+i);
		p[a[i]].push_back(i);
	}
	do{
		f[x]=cnt;
		t=lower_bound(p[a[x]].begin(),p[a[x]].end(),x)-p[a[x]].begin();
		if((y=p[a[x]][(t+1)%p[a[x]].size()])<=x)++cnt;
		if(++y==n){++cnt;y=0;}
		x=y;
	}while(!f[x]);
	if(k>=f[x])k=(k-f[x])%(cnt-f[x]);
	else x=0;
	while(k>1){
		t=lower_bound(p[a[x]].begin(),p[a[x]].end(),x)-p[a[x]].begin();
		if((y=p[a[x]][(t+1)%p[a[x]].size()])<=x)--k;
		if(++y==n){--k;y=0;}
		x=y;
	}
	for(i=x;i<n;++i)if(!b[a[i]])b[st[++sl]=a[i]]=1;
	else{
		while(sl>=0&&st[sl]!=a[i])b[st[sl--]]=0;
		--sl;
		b[a[i]]=0;
	}
	if(k)for(i=0;i<n;++i)if(!b[a[i]])b[st[++sl]=a[i]]=1;
	else{
		while(sl>=0&&st[sl]!=a[i])b[st[sl--]]=0;
		--sl;
		b[a[i]]=0;
	}
	for(i=0;i<=sl;++i)printf("%d ",st[i]);
	putchar('\n');
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, m, k; cin>>n>>m>>k;
    char arr[10][10];
    for(i = 0; i < n; i++){
        getchar();
        for(j = 0; j < m; j++) cin>>arr[i][j];
    }
    int cnt = 0;
    for(i = 0; i < (1<<n); i++){
        for(j = 0; j < (1<<m); j++){
            int total = 0;
            for(int x = 0; x < n; x++){
                for(int y = 0; y < m; y++){
                    if((i&(1<<x)) && (j&(1<<y)) && arr[x][y] == '#') total++;
                }
            }
            if(total == k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: usize,
        w: usize
    }
    println!("{}", (n + 1 - h) * (n + 1 - w));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a[100],k;
	for(int i=0;i<5;i++)
	{	
		cin>>a[i];
	}
	cin>>k;
	if(a[4]-a[0]<=k)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>

#define int long long

using namespace std;

const int INF = 1e17 + 7;

void solve() {
    string str;
    cin >> str;
    int s = 0;
    for (auto c : str) s += c - '0';
    cout << (s % 9 ? "No" : "Yes");
}

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

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 3380
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = ll(1e18) + 1;

int main(void)
{
    ll n, k;
    ll r, s, p;
    string t;
    int i, j;
    int point;
    vector<pair<ll, char>> dp;
    ll ans;

    cin >> n >> k >> r >> s >> p >> t;

    dp.resize(k);

    if (t[0] == 'r')
    {
        dp[0].first = p;
        dp[0].second = 'p';
    }
    else if (t[0] == 's')
    {
        dp[0].first = r;
        dp[0].second = 'r';
    }
    else
    {
        dp[0].first = s;
        dp[0].second = 's';
    }

    rep(i, 1, n)
    {
        if (t[i] == 'r')
        {
            if (dp[i % k].second != 'p')
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first + p, dp[i % k].first);
                dp[i % k].second = 'p';
            }
            else
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first, dp[i % k].first);
                dp[i % k].second = 'n';
            }
        }
        else if (t[i] == 's')
        {
            if (dp[i % k].second != 'r')
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first + r, dp[i % k].first);
                dp[i % k].second = 'r';
            }
            else
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first, dp[i % k].first);
                dp[i % k].second = 'n';
            }
        }
        else if (t[i] == 'p')
        {
            if (dp[i % k].second != 's')
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first + s, dp[i % k].first);
                dp[i % k].second = 's';
            }
            else
            {
                dp[i % k].first = max(dp[(i - 1 + k) % k].first, dp[i % k].first);
                dp[i % k].second = 'n';
            }
        }
    }

    ans = 0;

    rep(i, 0, k)
    {
        ans = max(ans, dp[i].first);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
A = [int(_)-1 for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

ans = 0
for i in range(N):
    ans += B[A[i]]
    if i > 0 and A[i] - A[i-1] == 1:
        ans += C[A[i-1]]
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int min = 1;
		int max = n+1;
		
		for(int i = 0; i < m;i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			
			min = Math.max(l, min);
			max = Math.min(r, max);
		}
		
		int size = Math.max(0, max-min+1);
		
		
		System.out.println(size);
	}
}


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

int n,m;

int main()
{
    cin >> n >> m;
    if(n < m) swap(n,m);

    if(m == 1)
    {
        if(n == 1) cout << 1 << endl;
        else cout << n-2 << endl;
    }
    else cout << (long long) (n-2) * (m-2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000000
#define M 1000001

typedef struct card{
	char key[15];
	struct card *next;
}card;

card *a[M];

long long convert(char str[]){
	int x=0;
	long p=1;
	
	for(int i=0;i<strlen(str);i++){
		x+=(str[i]-'A')*p;
		p*=5;
	}
	
	return x%M;
}

void insert(char str[]){
	card *new=malloc(sizeof(card));
	new->next=NULL;
	strcpy(new->key,str);
	
	card **p=&a[convert(str)];
	
	while((*p)!=NULL)
		p=&((*p)->next);
	
	(*p)=new;
	
	return;
	
}

int find(char str[]){
	long long hash=convert(str);
	card *p=a[hash];
	
	while(p!=NULL){
		if(strcmp(p->key,str)==0)
			return 1;
		p=p->next;
	}
	
	return 0;
	
}


int main(){
	int n,i;
	char com[10];
	char str[15];
	
	for(i=0;i<M;i++)
		a[i]=NULL;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		
		if(com[0]=='i'){
			insert(str);
		}
		
		else {
			if(find(str))
				printf("yes\n");
			else 
				printf("no\n");
		}
		
	}
	
	return 0;
	
}


Measured memory_bytes: 27376
package main

import "fmt"

func process(in string) (ret string) {
	if tail := in[len(in)-1 : len(in)]; tail != "s" {
		ret = in + "s"
	} else {
		ret = in + "es"
	}
	return
}

func main() {
	var in string
	fmt.Scanln(&in)

	ret := process(in)
	fmt.Println(ret)
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration
int N ;
vector<vector<ll>> vect;
ll dp[3][MAXN];

ll solve(int n, int t) {
	if (n >= N) return 0;
	if (dp[t][n]>=0) return dp[t][n];
	ll sol = 0;

	for(int k = 0 ; k < 3 ; ++k){
		if(k!=t){
			sol = max ( sol, solve(n+1 , k ) + vect[t][n] );
		}
	}
	return dp[t][n]=sol ;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin >> N;
	vect.resize(3,vector<ll>(N));
	for(int i = 0 ; i < N ; ++i){
		for(int j = 0 ; j < 3 ; ++j){
			cin >> vect[j][i];
		}
	}

	ll ans = 0;
	int start = 0;

	ans = max( solve(start, 0) , solve(start, 1));
	ans = max( ans 			  , solve(start, 2));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12784
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner teclado = new Scanner(System.in);
		int N=teclado.nextInt(),X=teclado.nextInt();
		int quant=0;
		int v[] = new int[N];
		int r[] = new int[N+1];
		for(int y = 0; y<N;y++) {
			v[y]=teclado.nextInt();
			}
		r[0]=0;
		for(int y=1; y<= N; y++) {
			int z = y-1;
			r[y]= r[z] + v[z];
			
		}
		for(int y=0;y<=N;y++) {
			if(r[y]<=X) {
				quant = quant+1;
			}
		}
		System.out.println(quant);
	}
}


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

using namespace std;

int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if( !(A&1) || !(B&1) || !(C&1) )
        puts("0");
    else
    {
        vector<int> v;
        v.push_back(A);
        v.push_back(B);
        v.push_back(C);
        sort(v.begin(),v.end());
        printf("%lld\n",(long long)v[0]*v[1]);
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n=int(input())
dct=defaultdict(int)

for i in range(n):
  s=input()
  sort_s="".join(sorted(s))
  dct[sort_s]+=1
ans=0
for k,v in dct.items():
  ans+= v*(v-1)//2
print(ans)

Measured memory_bytes: 18148
n=int(input())
import math
import itertools
x=[]
y=[]
total=0
factorial=math.factorial(n)
for i in range(n):
    X,Y=map(int,input().split())
    x.append(X)
    y.append(Y)
index_lis=[i for i in range(n)]#N!通り並べるために使う配列
P=itertools.permutations(index_lis,n)#N!通り並べる
for p in P:
    for i in range(n-1):
        tmp=math.sqrt((x[p[i+1]]-x[p[i]])**2+(y[p[i+1]]-y[p[i]])**2)
        total+=tmp
print(total/factorial)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define mp make_pair

int main() {
    int N;
    scanf("%d", &N);
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a[i]);
    }

    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += abs(a[i]);
    }

    vector<pii> path;
    if (a[0] > 0) {
        sum -= a[0] * 2;
        int cur = a[0];
        for (int i = 1; i < N - 1; ++i) {
            path.push_back(mp(cur, a[i]));
            cur -= a[i];
        }
        path.push_back(mp(a[N - 1], cur));
    } else if (a[N - 1] < 0) {
        sum += a[N - 1] * 2;
        path.push_back(mp(a[N - 1], a[N - 2]));
        int cur = a[N - 1] - a[N - 2];
        for (int i = N - 3; i >= 0; --i) {
            path.push_back(mp(cur, a[i]));
            cur = cur - a[i];
        }
    } else {
        int cur = a[0];
        for (int i = 1; i < N - 1; ++i) {
            if (a[i] >= 0) {
                path.push_back(mp(cur, a[i]));
                cur = cur - a[i];
            }
        }

        path.push_back(mp(a[N - 1], cur));
        cur = a[N - 1] - cur;
        for (int i = 1; i < N - 1; ++i) {
            if (a[i] < 0) {
                path.push_back(mp(cur, a[i]));
                cur = cur - a[i];
            }
        }
    }
    printf("%d\n", sum);
    for (int i = 0; i < path.size(); ++i) {
        printf("%d %d\n", path[i].first, path[i].second);
    }
    return 0;
}



Measured memory_bytes: 3188
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, i, minb, maxa;
	int a[100000], b[10000];

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%d %d", &a[i], &b[i]);
		if (i == 0){
			minb = b[i];
			maxa = a[i];
		}
		else{
			if (maxa < a[i]){
				minb = b[i];
				maxa = a[i];
			}
		
		}

	}
	printf("%d", minb + maxa);
	

	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();

   int[] ai = {a+b,a-b,a*b};
   Arrays.sort(ai);
 
   System.out.println(ai[2]);
 }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vi dp(n,1 << 30);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long double ld;

bool ok(int n, vector<string> g, vector<string> cls) {
	vector<bitset<14>> inDeg(n), outDeg(n);

	for (int i = 1; i < n; i++) {
		if (cls[i].size() != i) {
			return false;
		}
		for (int j = 0; j < i; j++) {
			if (g[i][j] == '1') {
				outDeg[i][cls[i][j] - 'a'] = true;
				inDeg[j][cls[i][j] - 'a'] = true;
			} else {
				outDeg[j][cls[i][j] - 'a'] = true;
				inDeg[i][cls[i][j] - 'a'] = true;
			}
		}
	}

	bool ok = true;

	for (int i = 0; i < n && ok; i++) {
		for (int j = 0; j < 14; j++) {
			if (outDeg[i][j] && inDeg[i][j]) {
				ok = false;
				break;
			}
		}
	}

	return ok;
}

bool solvable(int n, const vector<string>& g) {
	mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
	int iter = 50000;

	while (iter--) {
		vector<string> cls(n);
		uniform_int_distribution<char> uid('a', 'n');
		vector<bitset<14>> inDeg(n), outDeg(n);

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				cls[i] += uid(gen);

				if (g[i][j] == '1') {
					outDeg[i][cls[i][j] - 'a'] = true;
					inDeg[j][cls[i][j] - 'a'] = true;
				} else {
					outDeg[j][cls[i][j] - 'a'] = true;
					inDeg[i][cls[i][j] - 'a'] = true;
				}
			}
		}

		bool ok = true;

		for (int i = 0; i < n && ok; i++) {
			for (int j = 0; j < 14; j++) {
				if (outDeg[i][j] && inDeg[i][j]) {
					ok = false;
					break;
				}
			}
		}

		if (ok) {
			return true;
		}
	}

	return false;
}

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

#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	auto START = chrono::steady_clock::now();
#endif

	int a, b;
	cin >> a >> b;

	if (b >= a) {
		cout << "unsafe";
	} else {
		cout << "safe";
	}
#ifdef LOCAL
	cerr << "Working time: " << chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - START).count()
			 << " ms.";
#endif

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

class union_find {
private:
    vector<ll> par;
    vector<ll> ran;
    vector<ll> m_size;
public:
    union_find(ll n);
    ll find(ll x);
    void unite(ll x, ll y);
    bool same(ll x, ll y);
    ll size(ll x);
};

union_find::union_find(ll n){
    par.resize(n);
    ran.resize(n, 0);
    m_size.resize(n, 1);
    REP(i,n) par[i] = i;
};

ll union_find::find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    ll t = size(x)+size(y);
    m_size[x] = m_size[y] = t;
    if (ran[x] < ran[y]) {
        par[x] = y;
        //size[y] += size[x];
    } else {
        par[y] = x;
        //ize[x] += size[y];
        if (ran[x]==ran[y]) ran[x]++;
    }
};

ll union_find::size(ll x) {
    if (par[x] == x) return m_size[x];
    return size(par[x] = find(par[x]));
}

bool union_find::same(ll x, ll y) {
    return (find(x) == find(y));
};

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> x[m];
    REP(i,n) {
        int k; cin >> k;
        REP(j,k) {
            int l; cin >> l; --l;
            x[l].push_back(i);
        }
    }
    union_find uf(n);
    for (auto &&X : x) {
        if (X.size() <= 1) continue;
        for (int j = 0; j < X.size()-1; ++j) {
            uf.unite(X[j], X[j+1]);
        }
    }
    if (uf.size(0) == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 5496
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		long N = stdIn.nextInt();
		long mod = 1000000007;
		long all = 1;
		long rmEight = 1;
		long rmNine = 1;
		long rmEightNine = 1;
		
		for(long i = 0; i < N ; i ++) {
			all = (all * 10) % mod;
			rmEight = (rmEight * 9) % mod;
			rmNine = (rmNine * 9) % mod;
			rmEightNine = (rmEightNine * 8) % mod;
		}
		
		long ans = all;
		ans -= rmNine;
		if(ans < 0) {
			ans += mod;
		}
		ans -= rmEight;
		if(ans < 0) {
			ans += mod;
		}
		ans += rmEightNine;
		System.out.println(ans % mod);
	}
}

Measured memory_bytes: 35840