akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n;
  in(n);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  sort(all(c));
  a = 1;
  rep(i, n - 1){
    if(c[i] != c[i + 1])
      a++;
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = [list(map(int,input().split())) for _ in range(N)]
L = []

for i in range(2**N):
  A = [0 for _ in range(M+1)]
  for j in range(N):
    if i & (1<<j):
      for k in range(M+1):
        A[k] += C[j][k]
  flag = True
  for i in range(M):
    if A[i+1] < X:
      flag = False
  if flag:
    L.append(A[0])

if L == []:
  L.append(-1)
print(min(L))

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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for ( int i = 0; i < 3; ++i ) {
    if ( s[i] == t[i] ) ++cnt;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
ans=0
for x in range(a+1):
    #y+z=b-x
    minn=min(a,b-x)
    for y in range(minn+1):
        z=b-x-y
        if 0<=z and z<=a:
            ans+=1
print(ans)


Measured memory_bytes: 9104
using System;

class Program
{
    static void Main(string[] args)
    {
        int k = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        if (s.Length <= k)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine($"{s.Substring(0, k)}" + "...");
        }
    }
}

Measured memory_bytes: 27520
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d",&n);
    long a[n],d[n],sum = 0;
    long i;
    for(i=0;i<n;i++){
        scanf("%ld",&(a[i]));
    }
    for(i=0;i<n;i++){
        sum += a[i];
    }

    long j;
    long temp=sum,c;
    temp=0;
       for(i=1;i<n;i++){
           if(i%2!=0){
               temp+=a[i];
           }
       }


            d[0] = sum-2*temp;
            
            for(j=1;j<n;j++){
                c = 2*a[j-1] - d[j-1];
                d[j] = c;
               
            }
        

       
        
    

    for(i=0;i<n;i++){
        printf("%ld ",d[i]);
    }
    printf("\n");



    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 110;
const double eps = 1e-6;



int main()
{
    int n, res = 0;
    cin >> n;
    while(n--)
    {
        int x;
        cin >> x;
        x--;
        res += x;
    }

    cout << res << endl;
    return 0;
}


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

int main(){
  int H, W;
  char pixel;
  cin >> H >> W;
  rep(i, W+2){
    sharp();
  }
  cout <<endl;
  rep(i, H){
    sharp();
    rep(j, W){
      cin >> pixel;
      cout << pixel;
    }
    sharp();
    cout << endl;
  }
  rep(i, W+2){
    sharp();
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private boolean isTakahashi(int m, int d) {
		if (d < 10) {
			return false;
		}

		int d1 = d % 10;
		int d10 = d / 10;

		return d1 >= 2 && d10 >= 2 && d1 * d10 == m;

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int M = sc.nextInt();
		int D = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int m = 1; m <= M; m++) {
			for (int d = 1; d <= D; d++) {
				if (isTakahashi(m, d)) {
					ans++;
				}
			}
		}

		out.println(ans);

	}

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


Measured memory_bytes: 21972
s = raw_input()

words = ['dream', 'dreamer', 'erase', 'eraser']
flag = True

while len(s) >= 5 and flag:
  for i in range(len(words)):
    if s[-len(words[i]):] == words[i]:
      s = s[:-len(words[i])]
      break
  else:
    flag = False
    print 'NO'
    break

if flag:
  print 'YES'


Measured memory_bytes: 2820
#include <stdio.h>
#include <string.h>

const char *pchar[] = {
    "", " abcde", " fghij", " klmno",
    " pqrst", " uvwxy", " z.?! "
};

int main(void) {
    char buf[201], out[101];
    int i, len;

    while (gets(buf) != NULL) {
        len = strlen(buf);
        if (len & 1) goto NA;
        for (i = 0; i < len; i+=2) {
            if (buf[i] < '1' || '6' < buf[i] ||
                buf[i+1] < '1' || '5' < buf[i+1]) goto NA;
            out[i/2] = pchar[buf[i]-'0'][buf[i+1]-'0'];
        }
        out[i/2] = '\0';
        puts(out);
        continue;

        NA:
        puts("NA");
    }
    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<ll> v(n-1);
    for(auto& i : v) cin >> i;

    ll ans = v[0];
    REP(i, n-2){
        ans += min(v[i], v[i+1]);
    }
    ans += v.back();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    using namespace std;
     
    struct node {
        int c, s, f;
    };
     
    int N;
    vector<node> info;
     
    int main() {
        cin >> N;
        int c, s, f;
        for(int i = 0; i < N-1; i++) {
    	cin >> c >> s >> f;
    	info.push_back(node{c, s, f});
        }
     
        int sz = info.size();
        for(int i = 0; i < sz; i++) {
    	int current_time = 0;
    	
    	for(int j = i; j < sz; j++) {
    	    if (current_time < info[j].s) {
    		current_time += info[j].s - current_time;
    	    } else if (current_time % info[j].f != 0) {
    		current_time += info[j].f - (current_time % info[j].f);
    	    }
     
    	    current_time += info[j].c;
    	}
    	cout << current_time << endl;
        }
        cout << 0 << endl;
        
        return 0;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, M; cin >> N >> M;
    long long ans = (N-M) * 100 + M * 1900;
    ans *= pow(2, M);
    cout << ans << endl;
}

Measured memory_bytes: 4060
function main()
  
  (N,X,Y) = map(x -> parse(Int,x), split(readline()))
  
  dict = Dict()
  
  for i in 1:N-1
    
    check = 0
    for j in i:N
      check = min(j-i, abs(X-i) + abs(Y-j) + 1)
      dict[check] = get(dict, check, 0) + 1
    end
    
  end
  
  for i in 1:N-1
    println(get(dict, i, 0))
  end
  
end

main()

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

int main(){
    int line[40]={};
    int linenum;
    int change;
    cin>>linenum>>change;
    for(int i=1; i<linenum+1; i++){
        line[i]=i;
    }
    int sw,ap;
    char waste;
    for(int i=0; i<change; i++){
        cin>>sw>>waste>>ap;
        swap(line[sw],line[ap]);
    }
    for(int i=1; i<linenum+1; i++){
        cout<<line[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

int A, B, M;
int P[1 << 18], Q[1 << 18];
int X[1 << 18], Y[1 << 18], Z[1 << 18];

int main() {
	cin >> A >> B >> M;
	for (int i = 1; i <= A; i++) cin >> P[i];
	for (int i = 1; i <= B; i++) cin >> Q[i];

	int Answer = (1 << 30);
	for (int i = 1; i <= M; i++) {
		cin >> X[i] >> Y[i] >> Z[i];
		Answer = min(Answer, P[X[i]] + Q[Y[i]] - Z[i]);
	}
	int minp = (1 << 30), minq = (1 << 30);
	for (int i = 1; i <= A; i++) minp = min(minp, P[i]);
	for (int i = 1; i <= B; i++) minq = min(minq, Q[i]);
	Answer = min(Answer, minp + minq);

	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
//#include <math.h>
//#include <istream>
//#include <sstream>
using namespace std;

int main()
{
	int ANS1 = 0;
	int ANS2 = 0;
	int ANS = 0;
	string str;
	vector<char> H;

	getline(cin, str);
	for (int i = 0; i < str.size(); i++)
	{
		H.push_back(str[i]);
	}

	for (int i = 0; i < H.size(); i++)
	{
		if (i % 2 == 0 && H[i] == '0')
		{
			ANS1 = ANS1;
		}
		if (i % 2 != 0 && H[i] == '1')
		{
			ANS1 = ANS1;
		}
		if (i % 2 == 0 && H[i] == '1')
		{
			ANS1 = ANS1 + 1;
		}
		if (i % 2 != 0 && H[i] == '0')
		{
			ANS1 = ANS1 + 1;
		}
	}

	for (int i = 0; i < H.size(); i++)
	{
		if (i % 2 == 0 && H[i] == '0')
		{
			ANS2 = ANS2 + 1;
		}
		if (i % 2 != 0 && H[i] == '1')
		{
			ANS2 = ANS2 + 1;
		}
		if (i % 2 == 0 && H[i] == '1')
		{
			ANS2 = ANS2;
		}
		if (i % 2 != 0 && H[i] == '0')
		{
			ANS2 = ANS2;
		}
	}
	ANS = min(ANS1, ANS2);
	cout << ANS << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int k;cin>>k;
   string s ;cin>>s;
   int n =s.length();
   if(k>=n){
       cout<<s<<endl;
   }
   else{
       rep(i,k){
           cout<<s[i];
       }
       cout<<"..."<<endl;
   }
   
}

Measured memory_bytes: 3624
package main

import(
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	cnt := 1
	for i := 0; i < 2; i++ {
		if s[i] == 'R' && s[i+1] == 'R'{
			cnt++
		}
	}
	if s == "SSS"{
		fmt.Println(0)
	}else{
		fmt.Println(cnt)
	}
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll MOD=1e9+7;

int N;
vi G[MAX];
void input(){
    cin>>N;
    rep(_,N-1){
        int a, b;
      	cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
}

ll dp[MAX][2];
ll dfs(int v, int par, int col){
    if(dp[v][col]!=-1)return dp[v][col];
  	ll tmp=1;
    if(col==1){
        rep(i,sz(G[v])){
            int u=G[v][i];
            if(u!=par) tmp=(tmp*dfs(u, v, 0))%MOD;
        }
    }
    else{
        rep(i,sz(G[v])){
            int u=G[v][i];
            if(u!=par) tmp=(tmp*(dfs(u, v, 0)+dfs(u, v, 1)))%MOD;
        }
    }
  	dp[v][col]=tmp;
  	return tmp;
}

ll ans;
void solve(){
    rep(i,N)rep(col,2)dp[i][col]=-1;
    ans=(dfs(0,-1,0)+dfs(0,-1,1))%MOD;
}

void output(){
    cout<<ans<<endl;
}

int main(){
    input();
    solve();
    output();
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e8+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
 
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int x,y;
	cin>>x>>y;
	if(abs(x-y)<=1)
	{
		cout<<"Brown";
	}
	else
		cout<<"Alice";
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int ans;

    scanf("%d", &n);
    if (100 < n && n <= 111) {
        ans = 111;
    } else if ((n/100)*111 < n) {
        ans = ((n/100) + 1)*111;
    } else {
        ans = (n/100)*111;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

int get_digit(int num){
  int digit=0;
  while(num!=0){
    num /= 10;
    digit++;
  }
  return digit;
}

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    if(get_digit(i+1) % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <algorithm>
using namespace std;
#define all(a) (a).begin(),(a).end()

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<double> a(n),b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(all(b));
    for(int i = 0; i < n; i++){
        auto itr1 = upper_bound(all(b),a[i]);
        auto itr2 = lower_bound(all(b),a[i]);
        int more = b.end()-itr1;
        int less = itr2-b.begin();
        int even = itr1-itr2;
        cout << 1*(even-1)+3*less << "\n";
    }
    return 0;
}



Measured memory_bytes: 4508
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

struct UnionFind
{
    vector<int> parent;
    vector<int> rank;

    UnionFind(int n) : parent(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x)
    {
        if (parent[x] == x)
            return x;
        return parent[x] = root(parent[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry)
            return;

        if (rank[rx] < rank[ry])
            parent[rx] = ry;
        else
        {
            parent[ry] = rx;
            if (rank[rx] == rank[ry])
                rank[rx]++;
        }
    }
    bool same(int x, int y)
    {
        int rx = root(x), ry = root(y);
        return rx == ry;
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> X(n),Y(n); 
    vector<pair<int,pair<int,int>>> edge;
    UnionFind uf(d5);
    for(int i=0;i<n;i++){
        cin>>X[i].first>>Y[i].first;
        X[i].second=Y[i].second=i;
    }
    sort(All(X));
    sort(All(Y));
    for(int i=0;i<n-1;i++){
        edge.push_back(make_pair(abs(X[i].first-X[i+1].first),make_pair(X[i].second,X[i+1].second)));
        edge.push_back(make_pair(abs(Y[i].first-Y[i+1].first),make_pair(Y[i].second,Y[i+1].second)));
    }
    sort(All(edge));
    int res = 0;
    for (auto e : edge) {
        int u = e.second.first;
        int v = e.second.second;
        int cost = e.first;
        if (uf.same(u,v))continue;
        uf.unite(u,v);
        res += cost;
    }
    cout << res << endl;
}

Measured memory_bytes: 13296
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	String S = sc.next();
	char[] c = S.toCharArray();

	int count = 0;
	for (int i = 0, j = c.length - 1; i < c.length / 2; i++, j--) {
	    if (c[i] != c[j])
		count++;
	}

	System.out.println(count);
    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
    
    int i;
    int N[32];
    std::vector<int> data{1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cin >> i;
  	
    	std::cout << data[i-1];
   
  	

    return 0;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
    int n;
    int a,b;
    cin>>n;
    if(n==2){
        cin>>a;
        cin>>b;
        cout<<a+b<<endl;
    }
    else cout<<"Hello World"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def linearSearch(l, key):
    m = len(l)
    l.append(key)
    i = 0
    while l[i] != key:
        i += 1
    l.pop()
    if i == m:
        return "NOT_FOUND"
    return i


if __name__ == '__main__':

    n = int(input())
    S = [int(s) for s in input().split(" ")]
    q = int(input())
    T = [int(t) for t in input().split(" ")]

    count = 0
    for t in T:
        if linearSearch(S, t) != "NOT_FOUND":
            count += 1

    print(count)



Measured memory_bytes: 6556
from collections import deque

k = int(input())

d = [-1,0,1]

que = deque()
for i in range(1,10):
    que.append(i)

cnt = 0
while que:
    p = que.popleft()
    cnt += 1
    if cnt == k:
        print(p)
        break
    for i in d:
        if 0 <= int(str(p)[-1]) + i <= 9:
            que.append(int(str(p) + str(int(str(p)[-1]) + i)))


Measured memory_bytes: 10904
#include <bits/stdc++.h>
using namespace std;
int main()  {
  string s;
  string t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s) {
    a -= 1;
  }
  else {
    b -= 1;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
/*input
3
10 20 10
*/
 
// author - Madhav Thakker
 
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace std;
 
#define ll long long
#define ld long double
#define int ll
#define endl '\n'

typedef pair<int, int> pii; 
typedef pair<ld, ld> pdd;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 
 
// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
const int MOD = 1e9+7;
 
 
int fast_pow(int a, int b){
	int res = a, ret = 1;
	while(b>0){
		if(b%2)
			ret = (ret*res)%MOD;
		res = (res*res)%MOD;b/=2;
	}
	return ret;
}
 
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';
// str = to_string(n)
// stoi , stoll, stol
// sort(arr, arr+n, greater<int>());
// fill(prefix.begin(), prefix.end(), 0);
// 
// 
 
 
 
////
const int maxN = 1e5+7;
int arr[maxN];
int dp[maxN];
////


signed main(){
 
	fastio;
	time_t time_t1, time_t2;
	time_t1 = clock();
 
	////////////////////////////////

	int t = 1;
	// cin >> t ;

	while(t--){
		memset(dp, 0, sizeof dp);
		int n;
		cin >> n;
		
		for (int i = 0; i < n; ++i){
			cin >> arr[i];
		}
		dp[0] = 0;
		dp[1] = abs(arr[1] - arr[0]) + dp[0];
		dp[2] = abs(arr[2] - arr[0]) + dp[0];
		dp[2] = min(dp[2], abs(arr[2] - arr[1]) + dp[1]);
		
		for (int i = 3; i < n; ++i){
			dp[i] = abs(arr[i] - arr[i-1]) + dp[i-1];
			dp[i] = min(dp[i], abs(arr[i] - arr[i-2]) + dp[i-2]);
		}

		cout << dp[n-1] << endl;
	}
 	
	///////////////////////////////
	// 
 
	time_t2 = clock();
	// cerr << "time taken :" << time_t2 - time_t1 << endl;
 
	return 0;
}


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

template<typename T> struct SegmentTree {
  using F = function<T(T, T)>;

  int n;
  T init;
  F f;
  vector<T> data;

  SegmentTree() {}
  SegmentTree(int n_, vector<T> v = vector<T>(),
      F f = [](T a, T b) { return min(a, b); }, T init = INT_MAX)
      : f(f), init(init) {
    n = 1;
    while(n < n_) n *= 2;
    data.assign(2 * n - 1, init);
    if(n_ == v.size()) build(v);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  void update(int k, T x) {
    k += n - 1;
    data[k] = x;
    while (k > 0) {
      k = (k - 1) / 2;
      data[k] = f(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return init;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

struct Tree {
  using P = pair<int, int>;

  int n;
  int time;
  vector<vector<int>> g;
  vector<int> num;
  vector<P> depth;
  vector<int> eulerTour;
  SegmentTree<P> seg;

  Tree(int n)
    : n(n), time(0), g(n),
      num(n), depth(n * 2 - 1), eulerTour(n * 2 - 1) {}

  void init(int r) {
    dfs(r, r, 0);
    SegmentTree<P>::F f = [](P a, P b) { return min(a, b); };
    seg = SegmentTree<pair<int, int>>(n * 2 - 1, depth, f, {INT_MAX, -1});
  }
  void addEdge(int s, int t) {
    g[s].push_back(t);
    g[t].push_back(s);
  }
  void dfs(int u, int p, int d) {
    num[u] = time;
    eulerTour[time] = u;
    depth[time] = {d, time};
    ++time;
    for (auto&& v : g[u]) {
      if (v != p) {
        dfs(v, u, d + 1);
        eulerTour[time] = u;
        depth[time] = {d, time};
        ++time;
      }
    }
  }
  int lowestCommonAncestor(int u, int v) {
    int i = num[u];
    int j = num[v];
    if (i > j) swap(i, j);
    return eulerTour[seg.query(i, j + 1).second];
  }
};

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

  int n; cin >> n;
  Tree t(n);
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    while (k--) {
      int c; cin >> c;
      t.addEdge(i, c);
    }
  }

  t.init(0);
  int q; cin >> q;
  while (q--) {
    int u, v; cin >> u >> v;
    cout << t.lowestCommonAncestor(u, v) << endl;
  }
  return 0;
}



Measured memory_bytes: 21212
#include<stdio.h>
int main()
{
  int i,j,h,w;
  while(1){
    scanf("%d%d",&h,&w);
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0 || i==h-1 || j==0 || j==w-1){
	  printf("#");
	}
	else{
	  printf(".");
	}  
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import Data.List

main = do
  s <- getLine

  putStrLn $ solve s

  where
    solve s
      | length s < 26 = s ++ [head $ ['a'..'z'] \\ s]
      | length s == 26 = aux (reverse s) []
      where
        aux [] _ = show (-1)
        aux (c:cs) xs = if null f then aux cs (c:xs) else reverse $ (head f) : cs
          where f = sort $ filter (>c) xs


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, x;std::cin >> n >> x;
  re(i, n+1){
    re(j, n+1){
      ll k = x-1000*i-5000*j;
      if(k<0||k%10000!=0||i+j+k/10000!=n) continue;
      std::cout << k/10000 << " " << j << " " << i << '\n';
      return 0;
    }
  }
  std::cout << "-1 -1 -1" << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;

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

	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if(m1 < m2 || (m1 == 12 && m2 == 1)){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>; // (city, city)

struct UnionFind {
    vector<int> rank;
    vector<int> parent;

    void init(int n) {
        rank = vector<int>(n);
        parent = vector<int>(n);
        iota(parent.begin(), parent.end(), 0);
    }

    int find(int x) {
        return (parent[x] == x ? x : parent[x] = find(parent[x]));
    }

    void unite(int x, int y) {
        int px = find(x);
        int py = find(y);

        if(px == py)  return;

        if(rank[px] < rank[py])  parent[px] = py;
        else if(rank[px] > rank[py]) parent[py] = px;
        else  parent[px] = py, rank[py]++;
    }
};

int n, k, l;
UnionFind road;
UnionFind railway;

int main() {
    cin >> n >> k >> l;
    road.init(n+1);
    railway.init(n+1);

    for(int i = 1; i <= k; i++) {
        int p, q;
        cin >> p >> q;
        road.unite(p, q);
    }

    for(int i = 1; i <= l; i++) {
        int r, s;
        cin >> r >> s;
        railway.unite(r, s);
    }

    map<P, int> mp;
    for(int i = 1; i <= n; i++)
        mp[P(road.find(i), railway.find(i))]++;

    for(int i = 1; i <= n; i++) {
        cout << mp[P(road.find(i), railway.find(i))];
        cout << (i == n ? "\n" : " ");
    }
}

Measured memory_bytes: 15104
import java.util.*;
public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    int[] L = new int[M];
    int[] R = new int[M];

    for (int i = 0; i < M; i++) {
      L[i] = sc.nextInt();
      R[i] = sc.nextInt();
    }

    sc.close();

    int min = 0;
    int max = N;

    for (int i = 0; i < M; i++) {
      min = Math.max(L[i], min);
      max = Math.min(R[i], max);
    }

    if (max < min){
      System.out.println(0);
    } else {
      System.out.println(max - min + 1);
    }
 
  }

}

Measured memory_bytes: 66344
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sunuke = Integer.parseInt(sc.next());
		int okasi = Integer.parseInt(sc.next());
		Set<Integer> count = new HashSet();

		for (int i = 0; i < okasi; i++) {
			int okasi2 = Integer.parseInt(sc.next());
			for(int j = 0; j < okasi2; j++) {
				count.add(sc.nextInt());
			}
		}

		System.out.println(sunuke - count.size());

	}


}

Measured memory_bytes: 46296
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n ,k;
    cin >> n >> k;
    int sum=1;
    for(int i=0; i<n; i++){
        if(sum<k){
            sum+=sum;
        }else{
            sum+=k;
        }
    }
    cout << sum << endl;
    
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

const string yes = "Yay!";
const string no = ":(";

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

    int x, y;
    cin >> x >> y;

    int res = 0;
    if (x == 1 && y == 1)
        res += 400000;

    if (x < 4)
        res += 100000 * (4 - x);

    if (y < 4)
        res += 100000 * (4 - y);

    cout << res << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll len = 0;
  rep(i,n) {
    cin >> a[i];
    len += a[i];
  }
  ll hal=0, ans=len;
  rep(i,n) {
    hal += a[i];
    ans = min(ans, abs(hal-(len-hal)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
/*
AizuOnline A1240
Title Unreliable Message
*/
#include <stdio.h>
#include <string.h>
//Global data section
char message[7][26];
char via[7];
int N;
char msgr_member[]="JCEAPM";
//
void revJ(char * from,char * to)
{
        strncpy(to+1,from,strlen(from)-1);
        to[0]=from[strlen(from)-1];
}
void revC(char * from,char * to)
{
        strncpy(to,from+1,strlen(from)-1);
        to[strlen(from)-1]=from[0];
        to[strlen(from)]='\0';
}
void revE(char * from,char * to)
{
        int l;

        l=strlen(from);
        if(l % 2)
        {
                strncpy(to,from+l/2+1,l/2);
                strncpy(to+l/2+1,from,l/2);
                to[l/2]=from[l/2];
        }
        else
        {
                strncpy(to,from+l/2,l/2);
                strncpy(to+l/2,from,l/2);
        }
}
void revA(char * from,char * to)
{
        int i,l;
        l=strlen(from);
        for(i=0;i<l;i++)
                to[i]=from[l-1-i];
        to[l]='\0';
}
void revP(char * from,char * to)
{
        int i;
        char c;


        for(i=0;i<strlen(from);i++)
        {
                c=from[i];
                if(c=='0')
                        *to='9';
                else if(isdigit(c))
                        *to=c-1;
                else
                        *to=c;
                to++;
        }
        *to='\0';
}
void revM(char * from,char * to)
{
        int i;
        char c;
        //printf("M\n");

        for(i=0;i<strlen(from);i++)
        {
                c=from[i];
                if(c=='9')
                        *to='0';
                else if(isdigit(c))
                        *to=c+1;
                else
                        *to=c;
                to++;
        }
        *to='\0';
}

reverse_convert(int msgr,char * from,char  * to)
{
        //printf("msgr=%c from=%s\n",msgr,from);

        if(msgr=='J')
                revJ(from,to);

        else if(msgr=='C')
                revC(from,to);
        else if(msgr=='E')
                revE(from,to);
        else if(msgr=='A')
                revA(from,to);
        else if(msgr=='P')
                revP(from,to);
        else if(msgr=='M')
                revM(from,to);

}
main()
{
        int i,j,msgr,len;

        scanf("%d",&N);
        for(i=0;i<N;i++)
        {
                scanf("%s",via);
                memset(&message[0][0],'\0',26*7);
                scanf("%s",&message[0][0]); 


                len=strlen(via);
                for(j=0;j<len;j++)
                {
                        msgr = via[len-j-1];
                        reverse_convert(msgr,&message[j][0],&message[j+1][0]);
                }
                printf("%s\n",&message[j][0]);
        }
return(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while (true)

int main(){
    
    int A,B,C;
    cin >> A >> B >> C;
    cout << max({A,B,C}) * 10 + A + B + C - max({A,B,C}) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[10];
  int i,moji=0,sum=0;
  
  scanf("%s", &s);
  
  for(i=0;i<10;i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
      moji++;
    else
      moji=0;
      
    if(moji>sum)
        sum=moji;
  }
  
  printf("%d", sum);

  return 0;
}

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

#define FOR(i,x,y) for(int i = (x);i < (y);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) (int) (x).size()
typedef long long ll;

int N,M;
int ball [100001];
bool is_red [100001];
int red [100001],white [100001];

int main()
{
	scanf("%d%d",&N,&M);
	fill(ball,ball + 100001,1);
	is_red [1] = true;
	FOR(i,0,M){
		int x,y;
		scanf("%d%d",&x,&y);
		ball [x]--;
		ball [y]++;
		if(is_red [x] == true){
			is_red [y] = true;
		}
		if(ball [x] == 0){
			is_red [x] = false;
		}
	}

	int ans = 0;
	for(int i = 1;i <= N;i++){
		ans += is_red [i];
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 768
import itertools
n,m,q=map(int,input().split())
Q=[list(map(int,input().split())) for i in range(q)]

l = list(itertools.combinations_with_replacement([i+1 for i in range(m)], n))

MAX=0
for i in l:
    ans=0
    for g in range(q):
        a,b,c,d = Q[g]
        if i[b-1]-i[a-1]==c:
            ans+=d
    MAX=max(ans,MAX)
print(MAX)


Measured memory_bytes: 21628
from collections import deque
N=int(input())
A=list(map(int,input().strip().split(' ')))
q=deque([])
for i in range(len(A)):
    if i%2==0:
        q+=[A[i]]
    else:
        q.appendleft(A[i])
ans=0
if (len(A)-1)%2==1:
    ans=(list(q))
else:
    ans=(list(q)[::-1])
ans=[str(x) for x in ans]
print(" ".join(ans))

Measured memory_bytes: 122532
n = int(input())
Ps = list(map(int, input().split()))

prev = False
ans = 0
for i in range(n):
    if Ps[i] == i+1:
        ans += 1
        if prev:
            ans -= 1
            prev = False
        else:
            prev = True
        continue
    prev = False
print(ans)


Measured memory_bytes: 20508
rooms = []
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])

num = int(raw_input())
for i in range(num):
    b,f,r,v = map(int, raw_input().split())
    rooms[b-1][f-1][r-1] += v

for number, room in enumerate(rooms):
    for row in room:
        print ' ' + ' '.join(map(str, row))
    if len(rooms) - 1 > number:
        print('####################')

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

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<max(0,(n-h+1)*(n-w+1))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  int ans=0;
  cin>>h>>w;
  char a[h][w];
  queue<pair<int,int>> q;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#'){q.push(pair<int,int> (i,j));}
    }
  }
  vector<vector<int>> distance(h, vector<int> (w, 0));
  while(q.size()){
    pair<int,int> start=q.front(); q.pop();
    int x=start.first;
    int y=start.second;
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    for(int i=0;i<4;i++){
      int cx=x+dx[i];
      int cy=y+dy[i];
      if(0<=cx&&cx<h&&0<=cy&&cy<w&&a[cx][cy]=='.'&&distance[cx][cy]==0){
        distance[cx][cy]=distance[x][y]+1;
        q.push(pair<int,int>(cx,cy));
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,distance[i][j]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13328
#include<iostream>
#include<sstream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int b[n];
	for(int i=n-1;i>-1;--i){
		b[i]=a[i];
		if((i+1)*2-1>=n)
			continue;
		for(int j=(i+1)*2-1;j<n;j+=(i+1))
			b[i]^=b[j];
	}
	stringstream sout;
	int tot=0;
	for(int i=0;i<n;++i)
		if(b[i]){
			++tot;
			sout<<i+1<<' ';
		}
	cout<<tot<<endl;
	while(sout>>tot)
		cout<<tot<<' ';
	return 0;
}

Measured memory_bytes: 3460
#include <stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A + B + 1 >= C) printf("%d\n", B + C);
	else printf("%d\n", B * 2 + A + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1736
use std::io;
use std::collections::HashMap;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();
    let mut map: HashMap<char, i64> = HashMap::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let c: char = buf.chars().next().unwrap();
        if c != 'M' && c != 'A' && c != 'R' && c != 'C' && c != 'H' {
            continue;
        }
        let i: i64 = match map.get(&c) {
            Some(i) => *i,
            None => 0
        };
        map.insert(c, i + 1);
    }
    let ans: i64 = match map.len() {
        3 => map.values().map(|&v| v).fold(1, |a, b| a * b),
        4 => {
            let vs = map.values().map(|&v| v).collect::<Vec<i64>>();
            vs[0] * vs[1] * vs[2] + vs[1] * vs[2] * vs[3] + vs[2] * vs[3] * vs[0] + vs[3] * vs[0] * vs[1] },
        5 => {
            let vs = map.values().map(|&v| v).collect::<Vec<i64>>();
                vs[0] * vs[1] * vs[2] +
                vs[1] * vs[2] * vs[3] +
                vs[2] * vs[3] * vs[4] +
                vs[3] * vs[4] * vs[0] +
                vs[4] * vs[0] * vs[1] +
                vs[0] * vs[1] * vs[3] +
                vs[1] * vs[2] * vs[4] +
                vs[2] * vs[3] * vs[0] +
                vs[3] * vs[4] * vs[1] +
                vs[4] * vs[0] * vs[2]
        },
        _ => 0
    };
    println!("{}", ans);
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int x;
    cin >> x;
    int ans = 0;
    for(ans = 0; ans*(ans+1)<2*x; ans++)continue;
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<queue>
#include<iomanip>
using namespace std;
int latte(string str){
    stringstream ss(str);
    int n;
    ss>>n;
    return n;
}
struct data{
    string str;
    int n;
    data(string a,int b):str(a),n(b){}
    data(){}
};
int main(){
    string str="";
    while(cin>>str,str!="0000"){
        int memo[10000];
        fill(memo,memo+10000,-1);
        queue<data>Q;
        Q.push(data(str,0));
        while(!Q.empty()){
            data ins=Q.front();Q.pop();
            str=ins.str;int n=ins.n;
            if(memo[latte(str)]!=-1)continue;
            memo[latte(str)]=n;
            string a,b;
            a=b=str;
            sort(a.rbegin(),a.rend());sort(b.begin(),b.end());
            int to=latte(a)-latte(b);
            stringstream ss;
            ss<<to;
            string to_;
            ss>>setw(4)>>setfill('0')>>to_;
            if(to_.length()!=4)for(int i=0;i<4-to_.length();i++)to_="0"+to_;
            //cout<<a<<"-"<<b<<"="<<to_<<endl;
            Q.push(data(to_,n+1));
        }
        if(memo[6174]==-1)cout<<"NA"<<endl;
        else cout<<memo[6174]<<endl;
    }
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N, M;
priority_queue<int> que;

int main()
{
    cin >> N >> M;
    vector<pair<int, int>> p(N);
    rep(i, N)
    {
        int a, b;
        cin >> a >> b;
        pair<int, int> pp = make_pair(a, b);
        p[i] = pp;
    }
    sort(p.begin(), p.end());

    ll ans = 0;
    int cur = 0;
    for (int i = 0; i <= M; i++)
    {
        while (cur < N && p[cur].first <= i)
        {
            que.push(p[cur].second);
            cur++;
        }

        if (!que.empty())
        {
            int t = que.top();
            ans += t;
            que.pop();
        }
    }

    cout << ans << endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<long long int> H(N);
  for(int i=0; i<N; i++){
    cin>>H.at(i);
  }
  long long int ans = 0;
  sort(H.begin(), H.end());
  
  if(N<K) cout<<"0"<<endl;
  else {
  for(int i=0; i<K; i++){
    H.pop_back();
  }
  for(long long int a : H){
    ans=ans+a;
  }
   cout<<ans<<endl;
  }
 
 
}



Measured memory_bytes: 1792
debug = False

if debug:import time
if debug:start = time.time()

n = int(input())
R = [0]*n
R_min = 10**9

R = [int(input()) for i in range(n)]

maximum_profit = -10**9
for i in range(1, n):
    R_min = R[i-1] if R[i-1] < R_min else R_min
    profit = R[i] - R_min
    maximum_profit = profit if profit > maximum_profit else maximum_profit
print(maximum_profit)

if debug:print(time.time() - start)

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

int main(){
  string a; cin >>a; int n,i;
  n = a.length(); bool q=1;

  for(i=0; i<=(n/2)/2; i++)
  if(!(a[i]==a[n/2-i-1]&&a[i]==a[n/2+i+1]&&a[i]==a[n-i-1]))
  {q=0; break;}

  if(q){cout <<"Yes";}
  else{cout <<"No";}

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int card_number, number, card[4][13], count_1, count_2;
	char input_pattern, pattern[] = { 'S','H','C','D' }, n;

	for (count_1 = 0; count_1 < 4; count_1++)
	{
		for (count_2 = 0; count_2 < 13; count_2++)
		{
			card[count_1][count_2] = 0;
		}
	}

	scanf("%d", &card_number);

	for (count_1 = 0; count_1 < card_number; count_1++)
	{
		scanf("%c", &n);
		scanf("%c %d", &input_pattern, &number);

		if (input_pattern == 'S')
		{
			card[0][number - 1] = 1;
		}

		if (input_pattern == 'H')
		{
			card[1][number - 1] = 1;
		}

		if (input_pattern == 'C')
		{
			card[2][number - 1] = 1;
		}

		if (input_pattern == 'D')
		{
			card[3][number - 1] = 1;
		}
	}

	for (count_1 = 0; count_1 < 4; count_1++)
	{
		for (count_2 = 0; count_2 < 13; count_2++)
		{
			if (card[count_1][count_2] == 0)
			{
				printf("%c %d\n", pattern[count_1], (count_2 + 1));
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<math.h>
using namespace std;

int n;
//vector<int, int> v;
int sum = 0;

int go(int b)
{
	int t = 0;
	while (b % 2 == 0)
	{
		b /= 2;
		t++;
	}
	return t;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int a = 0;
		scanf("%d", &a);
		//v.push_back(a);
		sum += go(a);
	}
	printf("%d\n", sum);
}

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

int a,b,c,d,res;

int main(){
	cin>>a>>b>>c>>d;
	if(b>c){
		if(a<c){
			if(b<d){
				res=b-c;
			}
			else{
				res=d-c;
			}
		}
		else{
			if(d<b){
				res=d-a;
			}
			else{
				res=b-a;
			}
		}
	}
	else{
		res=0;
	}
	if(res<0){
		res=0;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

queue<P> q;

int H,W;
char A[1000][1000];
int d[1000][1000];

int bfs(){
    int x=0; int y = 0;
    while(q.size()){
        P p = q.front(); q.pop();
        x = p.first; y = p.second;
        REP(i,0,4){
            int nx = x + dx[i]; int ny = y + dy[i];
            if (0<=nx && nx < H && 0<=ny && ny<W && A[nx][ny]!='#' && d[nx][ny]==inf){
                d[nx][ny] = d[x][y] + 1;
                q.push(P(nx,ny));
            }
        }
    }
    return d[x][y];
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i,0,H)REP(j,0,W) d[i][j]=inf;
    REP(i,0,H)REP(j,0,W){
        cin >> A[i][j];
        if (A[i][j]=='#'){
            q.push(P(i,j));
            d[i][j]=0;
        }
    }
    CO(bfs());
    return 0;
}

Measured memory_bytes: 13328